Two lists that disagree#
In the fixture, main has "fix b" and "fix c". The release branch received "fix b" by cherry-pick.
$ git log --oneline rel..main
a1092a2 fix c
6eaa3da fix b
$ git cherry -v rel main
- 6eaa3da... fix b
+ a1092a2... fix c
The log lists both as missing. git cherry compares patches and marks an equivalent one with -. Its manual says the test is based on the diff, after removing whitespace and line numbers.
Where the patch comparison fails#
The second fixture picks a fix onto a release branch whose neighboring line differs. The pick conflicts, and the resolution keeps the fix. Its patch now has different context:
$ git cherry -v rel main
+ 12d2232... fix l2
The fix is on the branch, and the command says it is not. The -x line still connects the two, since the picked commit's message ends with:
(cherry picked from commit 12d2232b57c782043a5eeee38fb41b4fe22ab050)
So the two sources have opposite weaknesses. Both were run with Git 2.43.
| Says picked | Says missing | |
|---|---|---|
git cherry | An equivalent patch is there | Missing, or adapted during a conflict |
-x line | Someone picked that commit, perhaps adapting it | Missing, or picked without -x, or the line was edited out |
Neither one tells you whether the fix works on the release branch. A commit can be picked and later reverted, and both lists still count it.
Build the list to hand over#
git cherry -v rel main | grep '^+' > open.txt
git log rel --not main --format='%h %s%n%b' | grep -E '^[0-9a-f]{7,} |cherry picked from'
For each line in open.txt, look for its ID in the second output. Then sort what is left:
| State | Next decision |
|---|---|
| Equivalent patch | None, unless it was reverted later |
Marked +, with an -x line | Read the adapted pick and run its test on the release branch |
Marked +, with no -x line | Decide whether to backport, and say why not if you skip it |
Search for reverts with git log rel --grep='^Revert' --oneline.
Worked example#
This example is fictional. Ana hands Ben the 4.2 branch before her leave. Her note says "all security fixes are in". Ben runs git cherry and finds six + lines. Four have -x lines in adapted commits, whose tests pass on the branch. One is a documentation change. The sixth has neither, and its advisory covers 4.2. Ben's decision is one backport, and the note he adds to the branch lists all six with the reason for each.
If the fix has to travel without a shared remote, send it as a patch with its base. Return to handing over evidence.