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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux