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

git-check checks all files, not just changed? #40

Open
dsedivec opened this issue Apr 4, 2019 · 4 comments
Open

git-check checks all files, not just changed? #40

dsedivec opened this issue Apr 4, 2019 · 4 comments
Labels
enhancement New feature or request

Comments

@dsedivec
Copy link

dsedivec commented Apr 4, 2019

Thanks for writing the git-check plug-in! I was surprised, though, to find that it checks my whole tree, not just staged changes against the prior commit (if any).

Should it be calling git diff-index with --cached, and preferring HEAD, when it exists, to ${EMPTY_COMMIT}?

@jumanjiman
Copy link
Member

Hi @dsedivec

There are two use cases:

  • Check only the files that are part of the current commit as a pre-commit hook
  • Check the entire tree in case of pre-commit run --all-files

Since the second use case covers the first (and then some, admittedly), I lazily implemented the second use case. I'm certainly open to support both individually.

Do you know if there's a way to detect if pre-commit is invoked with --all-files?

@dsedivec
Copy link
Author

dsedivec commented Apr 9, 2019

Hi @jumanjiman!

There are two use cases:

  • Check only the files that are part of the current commit as a pre-commit hook
  • Check the entire tree in case of pre-commit run --all-files

Since the second use case covers the first (and then some, admittedly), I lazily implemented the second use case. I'm certainly open to support both individually.

Do you know if there's a way to detect if pre-commit is invoked with --all-files?

OK, I didn't think of --all-files, good point. Can you set pass_filenames: True in the hook's definition, and then just pass all of the file names on the command line into git diff-index?

@jumanjiman
Copy link
Member

OK, I didn't think of --all-files, good point. Can you set pass_filenames: True in the hook's definition, and then just pass all of the file names on the command line into git diff-index?

That's a nifty thought to try.

i'll have to play with it and see if I can somehow also support the exclude* options.

@zaufi
Copy link

zaufi commented Nov 30, 2023

I also hit this issue ;-(

Having a repo with so many files and adopting changes in the pre-commit hooks I run it w/ -a and see that this hook forks a lot of git diff-index --check some-hash processes w/ the same hash (meaning that it ignores all that 100500 files given as parameters and performs the same command 100500 times!)

PS It's running for 30 minutes already and still not finished ;-()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants