git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Johannes Sixt <j6t@kdbg.org>
To: Peter Hunkeler <phunsoft@gmx.net>
Cc: "brian m. carlson" <sandals@crustytoothpaste.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: Sat, 30 Oct 2021 18:44:54 +0200	[thread overview]
Message-ID: <4c88e2ae-e42f-491a-2b97-aa1f92c392d5@kdbg.org> (raw)
In-Reply-To: <c5507ba6-6e31-b143-9791-0bcff54acb64@gmx.net>

Am 30.10.21 um 15:21 schrieb Peter Hunkeler:
> Pardon my ignorance, but I'm unlear as to how to proceed further with my
> issue.
> What is the proper process to report a bug, and get a consense whether
> it is accepted or rejected?

Writing a message to this mailing list is all the process that exists.
You brought forward arguments in a civil manner why you think the
current behavior is not correct. That's appreciated. However, it doesn't
automatically mean that something will be changed.

In your particular case...

> Am 28.10.2021 um 14:08 schrieb Peter Hunkeler:
>> Am 28.10.2021 um 00:07 schrieb brian m. carlson:
>>> I should point out here that it isn't intended for pre-commit hooks to
>>> be used this way; they're intended to verify that the commit meets some
>>> standards, not to modify it, although it is of course possible to do.
>>>
>> I can accept that comment. However:
>>
>> - wouldn't you agree that git should work consistently? It does not in
>> this case. If there is anything to be commited in the index, then the
>> "git add" from within the pre-commit hook *is* respected in this commit.
>> If there is *nothing* to be commited, except from what was added by the
>> pre-commit exit, then it is ignored *for this commit*, but it is added
>> and will be commited next time. This is inconsistent behaviour.
>>
>> - if the decision will be *not* to allow adding from within a pre-commit
>> hook, then the "git add" should be rejected. And the documentation
>> should say so.

... it is clearly stated (and brian repeated it) that the pre-commit
hook is intended to check the commit for "correctness" (whatever that
means for the project). `git add` is not automatically forbidden,
because it would be an unreasonable engineering effort to forbid things
that "do not merely check" the commit. (What if a user has to use `git
add` as part of some exotic check? For example, it is possible to `git
add` to some temporary throw-away index that is different from the one
that is about to be committed.)

Even though the documentation does not say explicitly that the commit
must not be changed, it is implicit in the stated intent (that the
commit is only checked). Depending on that some particular behavior
works for you sometimes is then your own business, and when it breaks
you get to keep both parts.

In conclusion, the pre-commit hook behaves as designed and nothing has
to be changed.

-- Hannes

  reply	other threads:[~2021-10-30 16:44 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
2021-10-28 12:08   ` Peter Hunkeler
2021-10-30 13:21     ` Peter Hunkeler
2021-10-30 16:44       ` Johannes Sixt [this message]
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=4c88e2ae-e42f-491a-2b97-aa1f92c392d5@kdbg.org \
    --to=j6t@kdbg.org \
    --cc=git@vger.kernel.org \
    --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).