git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [BUG REPORT] git-gui invokes prepare-commit-msg hook incorrectly
@ 2024-07-05 19:23 brianmlyles
  2024-07-05 19:57 ` Eric Sunshine
  0 siblings, 1 reply; 10+ messages in thread
From: brianmlyles @ 2024-07-05 19:23 UTC (permalink / raw)
  To: git

I noticed that commits from certain users were ending up in our
repository with comment-like lines in the commit message. I traced the
cause back to the combination of:

- Those users are using git-gui to make their commits
- A `prepare-commit-msg` hook is adding a dynamic commit message
  template using comment lines starting with `#`
- git-gui creates the commit in a way that circumvents the message
  washing similar to if one used `git commit -F`, but invokes the
  `prepare-commit-msg` hook without any additional arguments like
  "message" [1] that would tell the hook that `-F` is being used

[1]: https://git-scm.com/docs/githooks#_prepare_commit_msg

The result here is that even though the `prepare-commit-msg` hook is
already correctly short-circuiting when given the "message" parameter,
it is providing these comment lines when called by git-gui, and thus the
commits have these comment lines in them.

This seems like a bug in git-gui. I see two fixes, but I'm not sure
which is more correct:

- Have git-gui pass "message" as an argument to the
  `prepare-commit-msg` hook so that the hook knows that `-F`-like
  behavior is being used
- Have git-gui create the commit in a way that causes the message to be
  washed

The latter seems like it would be more consistent with other workflows
where the user is seeing the message in an editor, so my instinct is
that it would be the better fix.

-- 
Thank you,
Brian Lyles

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-08-07 18:19 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-05 19:23 [BUG REPORT] git-gui invokes prepare-commit-msg hook incorrectly brianmlyles
2024-07-05 19:57 ` Eric Sunshine
2024-07-05 20:56   ` Sean Allred
2024-07-05 21:47     ` Eric Sunshine
2024-07-06 14:03       ` Johannes Sixt
2024-07-06 18:15         ` Junio C Hamano
2024-07-07 13:25           ` Johannes Sixt
2024-07-08 19:29             ` Brian Lyles
2024-07-08 20:40               ` Johannes Sixt
2024-08-07 18:19                 ` Oswald Buddenhagen

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).