Git Mailing List Archive mirror
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: git@vger.kernel.org
Cc: entwicklung@pengutronix.de
Subject: notes handling broken on rebase
Date: Tue, 30 May 2023 11:21:55 +0200	[thread overview]
Message-ID: <20230530092155.3zbb5uxa7eisdzxb@pengutronix.de> (raw)

[-- Attachment #1: Type: text/plain, Size: 3433 bytes --]

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/ |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

             reply	other threads:[~2023-05-30  9:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-30  9:21 Uwe Kleine-König [this message]
2023-05-31 13:29 ` notes handling broken on rebase Phillip Wood

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230530092155.3zbb5uxa7eisdzxb@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=entwicklung@pengutronix.de \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).