-
-
Notifications
You must be signed in to change notification settings - Fork 767
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
post-checkout hook prevents pre-commit hooks from working with unstaged files #1418
Comments
hmmm indeed, there's probably two approaches to fixing this -- pre-commit could set a special environment variable that it will skip running everything (basically pingpong to itself) # underscore prefixed as it is not a public interface
_PRE_COMMIT_SKIP_POST_CHECKOUT=1 or it could force the hooks to not run by pointing to some path which does not exist git -c core.hooksPath=/dev/null checkout ... iirc the latter doesn't work in older versions of git so you might need to try some stuff out there with building git 1.8 from source 🤔 |
alternatively, it could apply the patch it acquired in reverse ( |
It seems the Is the |
2.9 is too recent so |
it seems the plumbing equivalent is |
Hi there!
Most important thing first: pre-commit is great, it makes managing git hooks trivial and when combined with static analysis hooks, helps our team immeasurably - thanks for all the hard work.
We have pre-commit hooks that run a bunch of checks, and thanks to #1339, a post-checkout hook that does some workspace analysis and prints a few warnings if needed.
Unfortunately this seems to have broken the "stash unstaged changes" behaviour when committing - the stash runs a git checkout to clear the working directory before running the hooks, and that fails because of the post-checkout hook. I'd expect that the working directory to be cleared as normal, commit OK and then the working directory to be restored as it does without the post-checkout hook, as the actual mechanism behind removing the unstaged changes and restoring them is hidden from the user.
Below is a quick test to reproduce it:
Unfortunately there seems to be no easy way to skip the post-checkout hook when clearing the unstaged files with
git checkout
.Happy to open a PR to help fix this, just unsure what to do - I could swap the
git checkout
for agit stash save --keep-index --include-untracked
but I assume it is using checkout for reason.The text was updated successfully, but these errors were encountered: