-
Notifications
You must be signed in to change notification settings - Fork 19
git-gui: strip the commit message after running commit-msg hook #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Which problem does this change solve? Why is it a problem that the message is stripped before it is processed by the commit-msg? Wouldn't it be more appropriate to adjust the hook since it has to cope with messages that have no excessive whitespace anyway? Please sign off the commit. @ossilator Your feedback would be appreciated. |
My hook was generating output with CRLF line endings. I only recently realized that this was causing some commits to include trailing spaces - but it took me weeks to trace the issue back to git-gui. When using Git directly, everything worked as expected. I've since updated the hook to produce LF line endings, but I’d like to help others avoid going through the same confusion. Regarding the hook's input, I don't see any reason why git-gui should provide different input than Git does. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any reason why git-gui should provide different input than Git does.
i see that as sufficient justification to approve of the change in general.
in fact, i have been pondering actually calling git commit, but that would require a lot of reshuffling and probably some enabler additions to git itself, so i didn't bother.
When commit-msg writes the file using CRLF, the lines in the final message include trailing spaces. Postpone stripping until after hooks execute. This aligns with Git's behavior, which passes the original message to commit-msg, then strips comments and whitespace. Signed-off-by: Orgad Shaneh <orgads@gmail.com>
Removed the initial validation and signed the commit. |
Thanks, queued. Since this patch touches an essential part of Git GUI, I'll let it cook for a while and use it in production before I send it upstream. |
Sure, thank you. |
When commit-msg writes the file using CRLF, the lines in the final message include trailing spaces.
Postpone stripping until after hooks execute.
Perform an initial strip for validation before hook execution.
This aligns with Git's behavior, which passes the original message to commit-msg, then strips comments and whitespace.