Skip to content

pretty-quick --staged in pre-commit has odd behavior in conjunction with git commit PATH… #124

@nelhage

Description

@nelhage

If I have pretty-quick --staged as a pre-commit hook, and I commit some files directly, I get a weird state where the commit and the working tree end up with the formatted files, but the index still has the old, unformatted files.

Starting from https://github.com/nelhage/pretty-quick-bugreport, we can see this as follows:

[nelhage@monolithique:~/code/pretty-quick-repro]$ echo $'function f( a,  b) {}' >> main.js 
[nelhage@monolithique:~/code/pretty-quick-repro]$ git ci main.js -m 'testing'                                          
🔍  Finding changed files since git revision 41b9102.   
🎯  Found 1 changed file.                  
✍  Fixing up main.js.                                                                                                  
  EvEverythingsiswawesome!   s                                                                                         
[master 8601415] testing                     
 1 file changed, 1 insertion(+)                                                                                        
[nelhage@monolithique:~/code/pretty-quick-repro]$ git --no-pager diff HEAD
[nelhage@monolithique:~/code/pretty-quick-repro]$ git --no-pager diff 
diff --git a/main.js b/main.js
index 56ddb1c..f3cb734 100644
--- a/main.js
+++ b/main.js
@@ -1,4 +1,4 @@
 function testFunc(a, b) {
   return a + b;
 }
-function f( a,  b) {}
+function f(a, b) {}
[nelhage@monolithique:~/code/pretty-quick-repro]$ git --no-pager diff --cached 
diff --git a/main.js b/main.js
index f3cb734..56ddb1c 100644
--- a/main.js
+++ b/main.js
@@ -1,4 +1,4 @@
 function testFunc(a, b) {
   return a + b;
 }
-function f(a, b) {}
+function f( a,  b) {}
[nelhage@monolithique:~/code/pretty-quick-repro]$ git status
On branch master
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        modified:   main.js

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   main.js

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions