Re: precommit hook broken with "git commit <filename>"
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Apr 12, 2011, 21:04 UTC
- Message-ID
- <7vvcyjnpvj.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <BANLkTimB=TZ1gP-18ywbZUOZSbDamkRwCg@mail.gmail.com>
"C. Scott Ananian" <cscott@laptop.org> writes:
Show 8 quoted lines
> It appears that "git commit <filename>" breaks the git precommit hook. > Every other git command updates the index to make the > commit-about-to-be-made before running the precommit hook, and indeed > the 'pre-commit.sample' distributed with git assumes that the index > reflects the commit. However, in the case of "git commit <filename>" > the man page states "the commit will ignore changes staged in the > index, and instead record the current content of the listed files > (which must already be known to git)".
Doesn't the command call the pre-commit hook with GIT_INDEX_FILE environment set to the temporary index used to create the (partial) commit? The sample pre-commit hook runs "diff --cached" between that index and HEAD (or the empty tree), and should show the change about to be committed.