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

Re: [PATCH] sequencer: Skip copying notes for commits that disappear during rebase

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Jun 19, 2026, 10:13 UTC
Message-ID
<67dbfb5c-5f07-49b8-aa32-a4635c585028@gmail.com>
In-Reply-To
<ajKimV1TDCgE-GzK@monoceros>
Hi Uwe and Junio
On 17/06/2026 14:58, Uwe Kleine-König wrote:
Show 19 quoted lines
> 
>> It is not yet clear to me if we want to _always_ discard a note from
>> a commit that would become "empty" during a rebase session (in other
>> words, a commit that becomes empty during a rebase is _always_ a
>> sign that the change it brings in is _already_ in the new base of
>> the rebase
> 
> Yeah, or in a patch that was picked before.
> 
>> and the necessary information the note wanted to carry to
>> the target branch is there without need to _duplicate_ it by copying
>> the note).  But assuming that we want the behaviour, the code change
>> to sequencer.c looks very reasonable to me, except for one thing that
>> I am not clear about.
> 
> I think given the commit goes away, it's natural that the note goes
> away, too. And to come back to your question above: I think it doesn't
> need documentation, that if a commit disappears its notes go away, too.
> But that might be subjective?!

I tend to agree with this - if we're throwing away the commit message without asking the user I think it makes sense to do the same for the notes. We have "--empty=ask" if the user does not want commits that become empty to be automatically discarded.

Show 19 quoted lines
>>> diff --git a/sequencer.c b/sequencer.c
>>> index 57855b0066ac..da2185a37c5d 100644
>>> --- a/sequencer.c
>>> +++ b/sequencer.c
>>> ...
>>> @@ -4965,7 +4965,7 @@ static int pick_one_commit(struct repository *r,
>>>   		return error_with_patch(r, commit,
>>>   					arg, item->arg_len, opts, res, !res);
>>>   	}
>>> -	if (is_rebase_i(opts) && !res)
>>> +	if (is_rebase_i(opts) && !res && !dropped_commit)
>>>   		record_in_rewritten(&item->commit->object.oid,
>>>   				    peek_command(todo_list, 1));
>>
>> If we have a sequence of commits where a commit that was *not*
>> dropped is followed by a fixup commit that *is* dropped (e.g.,
>> because it became empty/redundant), wouldn't it prevent the
>> previously pending commit from being flushed to skip
>> `record_in_rewritten` entirely for the dropped fixup commit?

That's a good point - we should call flush_rewritten_pending() in that case. Looking at the code there are some other bugs related to dropping commits either because they become empty or the user runs "git rebase --skip"

  - If we drop the final fixup we don't cleanup the commit message
  - If we drop an "edit" command then "git rebase --continue" records it
    as being rewritten HEAD so we'll copy the notes to the wrong commit
  - Running "git rebase --skip" causes the commit that had conflicts
    to also be recorded as as being rewritten to HEAD leading to the
    same issue.
Show 5 quoted lines
> Huh, sounds possible. I wonder if that makes the change so complicated
> that my time isn't well spend working on that given that I'm not used to
> git's source code and it's better addressed by someone with deeper
> knowledge. Sounds as if we need a state signaling "Current commit is
> done".

I'm happy to take this forward and try and fix at least some of the other bugs I've listed above. Uwe - if I don't cc you on some patches within the next couple of weeks please feel free to send a reminder.

Thanks
Phillip
Show 61 quoted lines
>> Wouldn't it map the note for `X` to rewritten `C`?
>>
>>> diff --git a/t/t3322-notes-rebase.sh b/t/t3322-notes-rebase.sh
>>> new file mode 100755
>>> index 000000000000..0eddde7f9961
>>> --- /dev/null
>>> +++ b/t/t3322-notes-rebase.sh
>>> @@ -0,0 +1,37 @@
>>> +#!/bin/sh
>>> +
>>> +test_description='Test notes on rebase'
>>> +
>>> +. ./test-lib.sh
>>> +
>>> +test_expect_success setup '
>>> +	git init &&
>>> +	git config notes.rewriteRef refs/notes/commits &&
>>> +	git version > version &&
>>> +	echo A > A &&
>>
>> Style.  In our codebase, redirection operator sticks to the
>> redirection target without SP in between, i.e.
>>
>> 	git version >version &&
>> 	echo A >A &&
>>
>>> +	git notes add -m "This is B" @ &&
>>
>> '@' is hard to read; when you refer to HEAD, please write HEAD.
>>
>>
>>> +test_expect_success 'rebase B + C on top of BD' '
>>> +	git rebase @ master
>>> +'
>>> +
>>> +test_expect_success 'assert there is no note on BD' '
>>> +	if git notes list branch >/tmp/lalaa; then return 1; fi
>>> +'
>>
>> Do not step outside of $TRASH_DIRECTORY without a good reason.
> 
> Oh, that is a debug thing that shouldn't have made it into the patch.
>   
>> Style.  In our codebase, shell scripts do not use ';' and written
>> more like
>>
>> 	if git notes list branch >notes-list
>> 	then
>> 		return 1
>> 	fi
>>
>> But more importantly, if you want to make sure the command makes a
>> controlled exit (not crash), use
>>
>> 	test_must_fail git notes list branch
> 
> Ah, I really wondered if I'm missing something because it should be
> easier to say "this command should fail".
> 
> Best regards
> Uwe
Previous: Uwe Kleine-KönigNext: Uwe Kleine-König
Message 4 of 67 in “sequencer: Skip copying notes for commits that disappear during rebase”
  1. sequencer: Skip copying notes for commits that disappear during rebaseUwe Kleine-König, Jun 16, 2026
  2. Junio C HamanoJun 17, 2026
  3. Uwe Kleine-KönigJun 17, 2026
  4. Phillip WoodJun 19, 2026
  5. Uwe Kleine-KönigJun 19, 2026
  6. 00/11 sequencer: do not record dropped commits as rewrittenPhillip Wood, Jun 30, 2026
  7. 01/11 t3400: restore coverage for note copying with apply backendPhillip Wood, Jun 30, 2026
  8. 02/11 sequencer: move definition of is_final_fixup()Phillip Wood, Jun 30, 2026
  9. 03/11 sequencer: be more careful with external mergePhillip Wood, Jun 30, 2026
  10. 04/11 sequencer: never reschedule on failed commitPhillip Wood, Jun 30, 2026
  11. 05/11 sequencer: remove unnecessary "or" in pick_one_commit()Phillip Wood, Jun 30, 2026
  12. 06/11 sequencer: simplify handing of fixup with conflictsPhillip Wood, Jun 30, 2026
  13. 07/11 sequencer: remove unnecessary condition in pick_one_commit()Phillip Wood, Jun 30, 2026
  14. 08/11 sequencer: simplify pick_one_commit()Phillip Wood, Jun 30, 2026
  15. Oswald BuddenhagenJul 6, 2026
  16. Phillip WoodJul 6, 2026
  17. 09/11 sequencer: return early from pick_one_commit() on successPhillip Wood, Jun 30, 2026
  18. Oswald BuddenhagenJul 6, 2026
  19. 11/11 sequencer: do not record dropped commits as rewrittenPhillip Wood, Jun 30, 2026
  20. 10/11 sequencer: use an enum to represent result of picking a commitPhillip Wood, Jun 30, 2026
  21. Oswald BuddenhagenJul 6, 2026
  22. Phillip WoodJul 6, 2026
  23. Junio C HamanoJun 30, 2026
  24. Uwe Kleine-KönigJul 1, 2026
  25. Phillip WoodJul 1, 2026
  26. Phillip WoodJul 1, 2026
  27. Junio C HamanoJul 13, 2026
  28. Uwe Kleine-KönigJul 1, 2026
  29. Phillip WoodJul 1, 2026
  30. Uwe Kleine-KönigJul 18, 2026
  31. Phillip WoodJul 18, 2026
  32. 00/10 sequencer: do not record dropped commits as rewrittenPhillip Wood, Jul 13, 2026
  33. 01/10 t3400: restore coverage for note copying with apply backendPhillip Wood, Jul 13, 2026
  34. Oswald BuddenhagenJul 13, 2026
  35. 02/10 sequencer: move definition of is_final_fixup()Phillip Wood, Jul 13, 2026
  36. Andrei RybakJul 14, 2026
  37. Phillip WoodJul 15, 2026
  38. 03/10 sequencer: be more careful with external mergePhillip Wood, Jul 13, 2026
  39. Oswald BuddenhagenJul 13, 2026
  40. Phillip WoodJul 15, 2026
  41. Phillip WoodJul 15, 2026
  42. Junio C HamanoJul 15, 2026
  43. 04/10 sequencer: never reschedule on failed commitPhillip Wood, Jul 13, 2026
  44. 05/10 sequencer: remove unnecessary "or" in pick_one_commit()Phillip Wood, Jul 13, 2026
  45. 06/10 sequencer: simplify handing of fixup with conflictsPhillip Wood, Jul 13, 2026
  46. Oswald BuddenhagenJul 13, 2026
  47. Phillip WoodJul 15, 2026
  48. 07/10 sequencer: remove unnecessary condition in pick_one_commit()Phillip Wood, Jul 13, 2026
  49. 08/10 sequencer: simplify pick_one_commit()Phillip Wood, Jul 13, 2026
  50. 09/10 sequencer: use an enum to represent result of picking a commitPhillip Wood, Jul 13, 2026
  51. 10/10 sequencer: do not record dropped commits as rewrittenPhillip Wood, Jul 13, 2026
  52. Junio C HamanoJul 13, 2026
  53. 0/9 sequencer: do not record dropped commits as rewrittenPhillip Wood, Jul 15, 2026
  54. 1/9 t3400: restore coverage for note copying with apply backendPhillip Wood, Jul 15, 2026
  55. 3/9 sequencer: never reschedule on failed commitPhillip Wood, Jul 15, 2026
  56. 2/9 sequencer: be more careful with external mergePhillip Wood, Jul 15, 2026
  57. 4/9 sequencer: remove unnecessary "or" in pick_one_commit()Phillip Wood, Jul 15, 2026
  58. 5/9 sequencer: simplify handling of fixup with conflictsPhillip Wood, Jul 15, 2026
  59. 6/9 sequencer: remove unnecessary condition in pick_one_commit()Phillip Wood, Jul 15, 2026
  60. 7/9 sequencer: simplify pick_one_commit()Phillip Wood, Jul 15, 2026
  61. 8/9 sequencer: use an enum to represent result of picking a commitPhillip Wood, Jul 15, 2026
  62. 9/9 sequencer: do not record dropped commits as rewrittenPhillip Wood, Jul 15, 2026
  63. Junio C HamanoJul 19, 2026
  64. Oswald BuddenhagenJul 20, 2026
  65. Junio C HamanoJul 20, 2026
  66. gerrit code review once more (was: Re: [PATCH v3 0/9] sequencer: do not record dropped commits as) rewrittenOswald Buddenhagen, Jul 20, 2026
  67. Phillip WoodJul 22, 2026

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.