git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "C. Scott Ananian" <cscott@laptop.org>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: precommit hook broken with "git commit <filename>"
Date: Tue, 12 Apr 2011 19:09:18 -0400	[thread overview]
Message-ID: <BANLkTimm0CBP_vX1ZFoyLa7QR5qgnCgZKw@mail.gmail.com> (raw)
In-Reply-To: <7vvcyjnpvj.fsf@alter.siamese.dyndns.org>

On Tue, Apr 12, 2011 at 5:04 PM, Junio C Hamano <gitster@pobox.com> wrote:
> "C. Scott Ananian" <cscott@laptop.org> writes:
>
>> 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.

Thanks for the quick answer.  You're right, of course.  Our tests were
subtly broken.  Now that we understand how it's supposed to work,
everything looks fine.

Great work on git, btw.  Yet another case where something I think
might be broken turns out to be working correctly (and smartly) all
along, or was recently fixed, etc...
 --scott

      reply	other threads:[~2011-04-12 23:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-12 15:17 precommit hook broken with "git commit <filename>" C. Scott Ananian
2011-04-12 21:04 ` Junio C Hamano
2011-04-12 23:09   ` C. Scott Ananian [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BANLkTimm0CBP_vX1ZFoyLa7QR5qgnCgZKw@mail.gmail.com \
    --to=cscott@laptop.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).