+
Skip to content

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

orgads
Copy link
Contributor

@orgads orgads commented Jul 13, 2025

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.

@j6t
Copy link
Owner

j6t commented Jul 14, 2025

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.

@orgads
Copy link
Contributor Author

orgads commented Jul 14, 2025

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.

Copy link
Contributor

@ossilator ossilator left a 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>
@orgads orgads force-pushed the strip-post-hooks branch from f79b953 to bfacf83 Compare July 14, 2025 13:11
@orgads
Copy link
Contributor Author

orgads commented Jul 14, 2025

Removed the initial validation and signed the commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载