Skip to content

Keep "#" lines in a commit message where the host strips comments [patch] - #203

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/140-commit-cleanup-whitespace
Oct 9, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/140-commit-cleanup-whitespace

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #140

What was wrong

GitCommitBuilder passed the message through --message but never pinned --cleanup. With commit.cleanup=strip (or scissors) in the host's git config, git treated every #-leading line as a comment:

  • #123 fixed the crash was dropped from the stored body, and the read-back GitCommit reported the truncated body, so the caller couldn't tell.
  • A #42: fix login subject made git abort with "empty commit message".

Change

  • Commit() always emits --cleanup=whitespace. That is git's own default for a message that never opens an editor, so an unconfigured host stores the same message as before.
  • CLAUDE.md gets note 16 alongside the other host-config pins (status.showUntrackedFiles, log.showSignature).

Tests

  • GitCommitBuilderTests.BuildsTheDefaultCommitVector now expects the flag. The new PinsTheMessageCleanupModeAheadOfTheMessage test checks it appears exactly once, before the message.
  • New integration test CommitKeepsHashLinesEvenWhereTheHostStripsCommentsAsync sets commit.cleanup=strip in the throwaway repository's config, then checks that a #-leading body line and a #-leading subject both survive.
  • With the fix temporarily reverted, all three tests fail: the body comes back without its # line. With the fix in place, the full suite passes: 776/776 on net10.0 (Linux).

🤖 Generated with Claude Code

https://claude.ai/code/session_01NwJrDAUtukhDgLo9pAfR3t


Generated by Claude Code

…tch]

Commit() never pinned --cleanup, so commit.cleanup=strip (or scissors) in
the host's git config made git drop every "#"-leading line of the message:
"#123 fixed the crash" vanished from the body without a word, and a
"#42: fix login" subject aborted the commit as empty. Always pass
--cleanup=whitespace, which is git's own default for a message that never
opens an editor, so unconfigured hosts store the same message as before.

Fixes #140

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NwJrDAUtukhDgLo9pAfR3t

Copy link
Copy Markdown
Contributor Author

ci / .NET / Test on macos-latest was cancelled after its Test step ran for 54 minutes with no result. I don't think this PR caused it:

  • On this same commit, the same suite passed on macOS in about 3 minutes in the other workflow (Test on macos-latest, run 37879269767). Linux and Windows also passed in this run.
  • The same job hung the same way on PR Recognise "no changes added to commit" as nothing to commit [patch] #199 (run 37864685802), which doesn't touch commit cleanup. Its Test step ran 55 minutes, was cancelled, and Linux and Windows passed.

So something in the suite occasionally hangs on the shared pipeline's macOS runner, regardless of the change. I'm re-running the failed jobs once. If it hangs again, the next step is to find the stuck test, which the job log should name now that it's available.


Generated by Claude Code

@sonarqubecloud

sonarqubecloud Bot commented Oct 9, 2026

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit d3c4f6f into main Oct 9, 2026
23 of 24 checks passed
@matt-edmondson
matt-edmondson deleted the fix/140-commit-cleanup-whitespace branch October 9, 2026 08:13
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.

With commit.cleanup=strip in the user's config, Commit() silently drops body lines starting with "#" (e.g. "#123 fixed the crash")

2 participants