git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [BUG REPORT] git-gui invokes prepare-commit-msg hook incorrectly

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 6, 2024, 18:15 UTC
Message-ID
<xmqqtth2petz.fsf@gitster.g>
In-Reply-To
<752d41f9-6ce3-4c31-a0a2-4960c7dc1b2b@kdbg.org>
Johannes Sixt <j6t@kdbg.org> writes:
Show 17 quoted lines
> My take-away is:
>
> - The commit message that is entered in the edit box must appear in the
> commit unmodified. There is no such concept as "comment lines" in git
> gui's commit message edit box. The commit-msg hook can overrule
> nevertheless as a means to enforce message hygiene, but otherwise the
> user must have full authority.
>
> - A commit message template and the MERGE_MSG file are populated in a
> manner that is suitable for `git commit`, i.e. can (and do) contain
> comment lines. It is, therefore, necessary to remove them when their
> text is used to populate git gui's edit box.
>
> I suggest that removing comment lines ("message-washing") should not
> happen as a post-processing step, but as a preprocessing step when text
> is gathered from particular sources that are known to contain
> inessential cruft.
I agree most of the things you said, but with one reservation.

There may be two classes of comments CLI "git commit" users would be seeing, ones coming from the "git commit" itself that describe what CLI "git commit" does (e.g., "lines starting with '#' are ignored", "absolutely empty message buffer aborts the command"), and others coming from project specific template and other mechanisms that describe what the project expects (e.g., "please keep your lines shorter than 72 columns").

I agree that it makes perfect sense not to show the former at all to the end-user in git-gui UI, especially if git-gui does not ignore lines starting with '#' or abort commit with an empty message.

I am not sure if it is safe to strip the latter out of user's view, though.

Previous: Johannes SixtNext: Johannes Sixt
Message 6 of 10 in “[BUG REPORT] git-gui invokes prepare-commit-msg hook incorrectly”
  1. brianmlylesJul 5, 2024
  2. Eric SunshineJul 5, 2024
  3. Sean AllredJul 5, 2024
  4. Eric SunshineJul 5, 2024
  5. Johannes SixtJul 6, 2024
  6. Junio C HamanoJul 6, 2024
  7. Johannes SixtJul 7, 2024
  8. Brian LylesJul 8, 2024
  9. Johannes SixtJul 8, 2024
  10. Oswald BuddenhagenAug 7, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.