git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: "brian m. carlson" <sandals@crustytoothpaste.net>,
	Peter Hunkeler <phunsoft@gmx.net>,
	Git Mailinglist <git@vger.kernel.org>
Subject: Re: Git not commiting anything if file created and "git add"ed in pre-commit hook is the only file in the staging area
Date: Wed, 27 Oct 2021 18:32:13 -0700	[thread overview]
Message-ID: <xmqqy26erl2a.fsf@gitster.g> (raw)
In-Reply-To: <YXnVuhyPuFFfJ8zq@coredump.intra.peff.net> (Jeff King's message of "Wed, 27 Oct 2021 18:42:02 -0400")

Jeff King <peff@peff.net> writes:

>> The commit history does not explain why we must do this _after_ invoking
>> run_status, but if the comment is incorrect and we re-read it
>> immediately, then this problem would go away.  I lack the relevant
>> context to determine whether this is appropriate, but if folks think
>> this is advisable, then I can write up a patch this weekend.  It should
>> be relatively trivial.
>
> There's some related discussion of this area in:
>
>   https://lore.kernel.org/git/CADv3qkGq3jA8iXsjhrqfsUX=gW+KOuLyeVgDzmku1tUpsMdvtw@mail.gmail.com/
>
> I don't find it particularly enlightening as to the history, but it does
> point to other people wanting to re-read before run_status().

Ah, OK.  Because we call run_status() to see if there is anything
"committable" is there in the part of the changes that the user
prepared (before hooks futzed with the index), and reject if (for
example) there is nothing to commit, we deliberately refuse the case
where the invoker of "git commit" does *nothing* and the only change
between HEAD and the index to be committed after the hook runs is
what was done by the hook.  IOW, the current behaviour was designed
specifically to handle the case that started this thread.

Interesting.  I think the reasoning makes sense, and having to say
allow-empty, and being able to bypass by saying allow-empty, is a
feature from the point of view of that design.



  reply	other threads:[~2021-10-28  1:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-27 19:03 Git not commiting anything if file created and "git add"ed in pre-commit hook is the only file in the staging area Peter Hunkeler
2021-10-27 22:07 ` brian m. carlson
2021-10-27 22:42   ` Jeff King
2021-10-28  1:32     ` Junio C Hamano [this message]
2021-10-28 12:08   ` Peter Hunkeler
2021-10-30 13:21     ` Peter Hunkeler
2021-10-30 16:44       ` Johannes Sixt
2021-10-30 21:25         ` Junio C Hamano
2021-11-02 13:13           ` Peter Hunkeler

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=xmqqy26erl2a.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    --cc=phunsoft@gmx.net \
    --cc=sandals@crustytoothpaste.net \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).