git/list[1] front-page[2] threads[3] people[4] search[5] about
 

notes handling broken on rebase

From
Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Date
May 30, 2023, 09:21 UTC
Message-ID
<20230530092155.3zbb5uxa7eisdzxb@pengutronix.de>
Hello,
I found a bug in git rebase and how notes are retained using
	uwe@taurus:~/tmp/gittest$ git version
	git version 2.41.0.rc2.161.g9c6817b8e7dd
, it also happens with 2.39.2.
Here comes a reproducer:
 - Create some initial git history, just three commits A, B and C:
	uwe@taurus:~/tmp/gittest$ git init
	Initialized empty Git repository in /home/uwe/tmp/gittest/.git/
	uwe@taurus:~/tmp/gittest$ for i in A B C; do echo content $i >> file ; git add file ; git commit -m "$i" ; git notes add -m "notes for $i" ; git tag $i ; done
	[main (root-commit) db2548de5a3c] A
	 1 file changed, 1 insertion(+)
	 create mode 100644 file
	[main 2b8fa82afb3c] B
	 1 file changed, 1 insertion(+)
	[main 3dd5e4a2037e] C
	 1 file changed, 1 insertion(+)
 - Pick C on top of A:
	uwe@taurus:~/tmp/gittest$ git checkout A
	HEAD is now at db2548de5a3c A
	uwe@taurus:~/tmp/gittest$ git cherry-pick C
	Auto-merging file
	CONFLICT (content): Merge conflict in file
	error: could not apply 3dd5e4a2037e... C
	hint: After resolving the conflicts, mark them with
	hint: "git add/rm <pathspec>", then run
	hint: "git cherry-pick --continue".
	hint: You can instead skip this commit with "git cherry-pick --skip".
	hint: To abort and get back to the state before "git cherry-pick",
	hint: run "git cherry-pick --abort".
	Recorded preimage for 'file'
	uwe@taurus:~/tmp/gittest$ { echo content A; echo content C; } > file
	uwe@taurus:~/tmp/gittest$ git add file
	uwe@taurus:~/tmp/gittest$ git cherry-pick --continue
	Recorded resolution for 'file'.
	[detached HEAD 6cfc9b7bd437] C
	 Date: Tue May 30 11:02:13 2023 +0200
	 1 file changed, 1 insertion(+)
 - Rebase {B, C} on top of A + C' (which results in skipping C):
	uwe@taurus:~/tmp/gittest$ git rebase HEAD C
	Auto-merging file
	CONFLICT (content): Merge conflict in file
	error: could not apply 2b8fa82afb3c... B
	hint: Resolve all conflicts manually, mark them as resolved with
	hint: "git add/rm <conflicted_files>", then run "git rebase --continue".
	hint: You can instead skip this commit: run "git rebase --skip".
	hint: To abort and get back to the state before "git rebase", run "git rebase --abort".
	Recorded preimage for 'file'
	Could not apply 2b8fa82afb3c... B
	uwe@taurus:~/tmp/gittest$ { echo content A; echo content B; echo content C; } > file
	uwe@taurus:~/tmp/gittest$ git add file
	uwe@taurus:~/tmp/gittest$ git rebase --continue
	Recorded resolution for 'file'.
	[detached HEAD e5b3e28216f2] B
	 1 file changed, 1 insertion(+)
	dropping 3dd5e4a2037ecd31f5470561638cb065434eabbc C -- patch contents already upstream
	Successfully rebased and updated detached HEAD.
Now I have:
	uwe@taurus:~/tmp/gittest$ git log --pretty=oneline --abbrev-commit --notes
	e5b3e28216f2 (HEAD) B
	Notes:
	    notes for B
	    
	    notes for C
	6cfc9b7bd437 C
	db2548de5a3c (tag: A) A
	Notes:
	    notes for A

The surprising part here is that (the new) B also has C's note. I would have expected that it only has its own one. I quickly looked into the source code, but didn't find an easy fix because the code that notices that C should be dropped (in do_pick_commit()) isn't where the note is copied (which I didn't find).

Best regards Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |
Next: Phillip Wood
Message 1 of 2 in “notes handling broken on rebase”
  1. Uwe Kleine-KönigMay 30, 2023
  2. Phillip WoodMay 31, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.