Skip to content

ciq-cherry-pick.py: Fix two commit message defects - #83

Merged
PlaidCat merged 2 commits into
mainlinefrom
ciq-cherry-pick-msg-fixes
Aug 14, 2026
Merged

ciq-cherry-pick.py: Fix two commit message defects#83
PlaidCat merged 2 commits into
mainlinefrom
ciq-cherry-pick-msg-fixes

Conversation

@kerneltoast

@kerneltoast kerneltoast commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Both fixes target the standardized commit message that ciq-cherry-pick.py writes to MERGE_MSG. I noticed the first defect while reviewing the gve backport series on ctrliq/kernel-src-tree PRs 1496, 1498, and 1523: every backport in the series has its trailing Signed-off-by tab-indented (e.g., d5596b7488851, b862126f2c9ce, 2d48036cc4997) when it should sit at column 0.

The trailer-indent loop never stops at the cherry-pick marker. The loop in CIQ_cherry_pick_commit_standardization() is meant to quit indenting once it reaches the marker line, but it tests for a line starting with cherry picked from commit while git writes (cherry picked from commit <sha>). The leading parenthesis means the break never fires, so the loop runs past the marker and indents the backporter's own Signed-off-by, which cherry-pick -s appends below the marker. Fixed by matching the line git actually writes.

git's conflict comment block leaks into the final message. On a conflicted pick, git appends # Conflicts: plus #<TAB><path> comment lines to MERGE_MSG. manage_commit_message() reads MERGE_MSG, inserts the CIQ header, and writes the whole thing back, conflict comments included. The script then exits telling the user to resolve and commit, and committing with git commit -F .git/MERGE_MSG keeps those lines, since -F's default cleanup mode only strips whitespace, not comments. I reproduced this on a live conflicted pick: the # Conflicts: block landed in the final commit message verbatim. Fixed by dropping the tail of the message starting at the line that is exactly # Conflicts:. The fix deliberately doesn't filter every # line, since legitimate upstream commit bodies can contain them.

The first fix comes with tests in tests/kt/ktlib/test_ciq_helpers.py, following the existing pytest layout. manage_commit_message() isn't importable from a test (the module builds git.Repo(os.getcwd()) and imports jira at load time), so I verified it by exec'ing the function in isolation against a synthetic conflicted MERGE_MSG, alongside a negative control showing the old marker check misbehaving:

PASS: both tests in tests/kt/ktlib/test_ciq_helpers.py
PASS: negative control, mainline tab-indents the backporter Signed-off-by (defect A reproduced)
--- standardized MERGE_MSG (conflicted pick) ---
gve: fix a bug in the driver

jira VULN-123
cve CVE-2026-1234
commit-author Upstream Author <author@example.com>
commit 1234567890abcdef1234567890abcdef12345678
upstream-diff |

Some body text describing the fix.
# earlier body line starting with hash must survive

<TAB>Signed-off-by: Upstream Author <author@example.com>
(cherry picked from commit 1234567890abcdef1234567890abcdef12345678)
Signed-off-by: Backporter <backporter@example.com>

--- end ---
PASS: conflict block dropped; earlier '#' body line survives; marker and backporter Signed-off-by untouched

Generated with Claude Code

Coverage Report

Name Stmts Miss Branch BrPart Cover Missing
check_fips_changes.py 42 42 12 0 0% 8-67
check_kernel_commits.py 179 179 76 0 0% 3-371
ciq-cherry-pick.py 194 194 54 0 0% 1-434
ciq-tag.py 146 146 16 0 0% 3-378
ciq_tag.py 232 232 54 0 0% 1-464
jira_pr_check.py 180 180 80 0 0% 3-381
kt/ktlib/ciq_helpers.py 325 269 152 4 14% 31-51, 74-106, 124, 126->129, 129->136, 136->151, 162-172, 179-183, 187, 191-199, 208-209, 213, 217, 225-229, 240-255, 263-266, 277-314, 327-333, 346-347, 351-353, 359, 363-369, 380-382, 390-395, 404-406, 415-420, 431-444, 455-479, 489-503, 513-518, 527, 557-623, 632-642, 646-655, 665-680, 692-709
kt/ktlib/command_runner.py 33 20 6 0 33% 16, 20-33, 37-61, 65-66
kt/ktlib/config.py 54 0 12 0 100%
kt/ktlib/kernel_workspace.py 111 77 18 0 26% 22-35, 49-66, 73-76, 80-91, 94-100, 113-124, 135-145, 162-165, 169-202, 210-213, 216-220
kt/ktlib/kernels.py 85 13 14 1 84% 57-65, 119, 135-142
kt/ktlib/local.py 5 1 0 0 80% 12
kt/ktlib/repo.py 29 15 2 0 45% 30-31, 34-35, 43-55
kt/ktlib/ssh.py 12 5 2 0 50% 9-12, 16
kt/ktlib/util.py 17 0 0 0 100%
kt/ktlib/virt.py 80 39 10 0 46% 26, 34-37, 51-78, 82-88, 92-93, 97, 101, 105, 109, 119-127, 133-138, 142-147
kt/ktlib/vm.py 302 152 52 4 47% 127-144, 177-186, 194-205, 234-238, 253->264, 281->287, 292-302, 305-306, 319-323, 326, 329-345, 350-367, 370-377, 386-392, 400-405, 426-437, 440-441, 444, 448-453, 465-478, 491-498, 507, 516-528, 531-538, 541-550, 553
release_config.py 2 2 0 0 0% 7-27
rolling-release-update.py 264 264 106 0 0% 1-412
run_interdiff.py 165 165 56 0 0% 3-244
update_lt_spec.py 219 219 46 0 0% 9-411
TOTAL 2676 2214 768 9 15%

kerneltoast and others added 2 commits August 10, 2026 18:00
The trailer-indent loop in CIQ_cherry_pick_commit_standardization() is
meant to stop indenting once it hits the marker line that git
cherry-pick -x writes, but it tests for a line starting with "cherry
picked from commit" while git actually writes "(cherry picked from
commit <sha>)". The leading parenthesis means the break never fires, so
the loop runs past the marker and tab-indents the backporter's own
Signed-off-by that cherry-pick -s appends below it. As a result, every
backport made through this helper ends up with its trailing
Signed-off-by indented.

Fix it by matching the line git actually writes. Trailers above the
marker still get their tab, while the marker and everything below it are
now left untouched. Add a test covering both sides of the marker.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
When a cherry-pick hits a conflict, git appends a comment block to
MERGE_MSG ("# Conflicts:" followed by the conflicted paths).
manage_commit_message() reads MERGE_MSG, inserts the CIQ header block,
and writes the whole thing back, conflict comments included. The script
then exits telling the user to resolve the conflict and commit, and
committing with -F keeps those lines, since -F's default cleanup mode
only strips whitespace, not comments. The conflict block winds up in the
final commit message verbatim.

Fix it by dropping the tail of the message starting at the
"# Conflicts:" line before standardizing. Only the trailing
git-generated block goes; legitimate body lines starting with "#"
earlier in the message survive.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings August 11, 2026 01:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes two defects in the standardized commit message handling used by ciq-cherry-pick.py, ensuring backport trailers are formatted correctly and that git’s conflict-comment block does not leak into the final commit message.

Changes:

  • Fix trailer indentation logic to stop indenting once the actual git cherry-pick marker line ((cherry picked from commit …)) is reached.
  • Strip the # Conflicts: comment block from MERGE_MSG during commit message management to prevent it from being committed via git commit -F.
  • Add pytest coverage validating that upstream trailers are indented while the marker and backporter’s Signed-off-by remain unindented.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
kt/ktlib/ciq_helpers.py Corrects the marker detection so the indentation loop stops at git’s real cherry-pick marker format.
ciq-cherry-pick.py Drops the # Conflicts: tail block from MERGE_MSG to avoid committing conflict comments when using -F.
tests/kt/ktlib/test_ciq_helpers.py Adds tests asserting upstream trailer indentation and that indenting stops at the cherry-pick marker.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@PlaidCat PlaidCat left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@bmastbergen bmastbergen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥌

@PlaidCat
PlaidCat merged commit d32f26f into mainline Aug 14, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants