[PATCH] Add a test about broken notes handling on rebase
- From
- Uwe Kleine-König <u.kleine-koenig@baylibre.com>
- Date
- Jun 12, 2026, 14:39 UTC
- Message-ID
- <20260612143952.3281115-2-u.kleine-koenig@baylibre.com>
When a commit disappears during rebase because the patch content is already there (but not by the same patch in which case the commit would be skipped) the notes of that disappearing commit still survives and is added to the (rebased) parent of the disappearing commit.
So with the commit graph
A -- B -- C ` `-BD
where BD includes the changes done in B, when rebasing C on top of BD, the note for B should disappear and not be added to BD.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com> --- Hello,
this is a behaviour of git that really bothers me when working on big patch series. I use notes to track the Message-Id of the patches when I send them out. Then when rebasing to a newer upstream version, the tracking gets confused because the Message-Id notes end up on commits that were not sent out yet (or I got two Message-Ids in them).
I reported that already back in 2023[1], but obviously not in a way that resulted in a fix. So I'm trying again with a patch that adds a failing test.
Best regards Uwe
[1] https://lore.kernel.org/git/20230530092155.3zbb5uxa7eisdzxb@pengutronix.de/
t/meson.build | 1 + t/t3322-notes-rebase.sh | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 t/t3322-notes-rebase.sh
diff --git a/t/meson.build b/t/meson.build index c5832fee0535..6927bd9c794f 100644 --- a/t/meson.build +++ b/t/meson.build @@ -358,6 +358,7 @@ integration_tests = [ 't3311-notes-merge-fanout.sh', 't3320-notes-merge-worktrees.sh', 't3321-notes-stripspace.sh', + 't3322-notes-rebase.sh', 't3400-rebase.sh', 't3401-rebase-and-am-rename.sh', 't3402-rebase-merge.sh', diff --git a/t/t3322-notes-rebase.sh b/t/t3322-notes-rebase.sh new file mode 100644 index 000000000000..64c40a523b50 --- /dev/null +++ b/t/t3322-notes-rebase.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +test_description='Test notes on rebase' + +. ./test-lib.sh + +test_expect_success setup ' + git init && + echo A > A && + git add A && + git commit -m A && + git branch branch && + echo B > B && + git add B && + git commit -m B && + git notes add -m "This is B" @ && + echo C > C && + git add C && + git commit -m C && + git checkout branch && + echo B > B && + echo D > D && + git add B D && + git commit -m BD +' + +test_expect_success 'rebase B + C on top of BD' ' + git rebase @ master +' + +test_expect_failure 'assert there is no note on BD' ' + git notes show branch +' + +test_done base-commit: 3e65291872de10c3f0bf05ea8c24187e7a71ebf0
-- 2.47.3