Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
nelhage opened this issue Feb 19, 2021 · 0 comments

Comments

@nelhage
Copy link

nelhage commented Feb 19, 2021

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant