From: Phillip Wood <phillip.wood123@gmail.com>
To: "D. Ben Knoble" <ben.knoble@gmail.com>, Git <git@vger.kernel.org>
Subject: Re: BUG? git rebase -x "git commit --amend …" loses notes
Date: Wed, 5 Aug 2026 17:31:07 +0100 [thread overview]
Message-ID: <de96a0de-a0a3-4e3e-b44e-8991f8ae87d3@gmail.com> (raw)
In-Reply-To: <307abaeb-b033-4c55-8edf-1ea765199dce@gmail.com>
On 05/08/2026 14:42, Phillip Wood wrote:
> On 05/08/2026 14:13, D. Ben Knoble wrote:
>> Sigh… I haven't minimized a reproduction case here yet, but maybe
>> someone can tell me how I'm holding it wrong.
>>
>> I have a local branch with notes in refs/notes/benknoble/commits (in
>> particular, the tip commit has a note). I forgot to adjust my author
>> email before creating some of these commits, and I wanted to adjust it
>> to match the mailmap patch I just sent out, so I ran
>>
>> git rebase -x "git commit --no-verify --no-edit --amend
>> --author='$(git config get user.name) <$(git config get user.email)>'"
>>
>> Upon checking (much) later, I discovered the note was missing! It had
>> not been rewritten. And yet:
>
> I suspect the note was rewritten to the un-amended commit (i.e. the
> commit created by rebase before it ran the exec command). The way the
> note writing works is that as rebase picks commits it remembers the new
> object id of each commit and after all the commits have been rebased
> passes a list of "old-oid new-oid" pairs to "git notes copy". If a
> commit gets amended by an exec command then we don't record the new
> object id correctly. I have some old, half finished, patches that try to
> fix that by making "git commit --amend" update the file where rebase
> stores the list of rewritten commits. I think it worked for exec
> commands that run "git commit amend", but the effort got bogged down
> trying to improve the way we handle commits that are edited. I've just
> pushed them to [1] if anyone is interested (though the commit messages
> are dreadful so I don't know how much help the patches will be).
Another approach would be to copy the notes before we stop for an "exec"
or "edit" command (the latter is complicated by the fact it might have
conflicts) so that "git commit --amend" could just copy them to the
amended commit. If we did that we'd want to copy the notes in-process
rather than forking "git notes copy" before each "exec" command.
Thanks
Phillip
> Thanks
>
> Phillip
>
> [1] https://github.com/phillipwood/git/commits/wip/rebase-update-rewritten
>
>> git config get --all --regexp --show-names --show-scope notes |
>> column -t
>> global format.notes true
>> global notes.rewriteref refs/notes/commits
>> local core.notesref refs/notes/benknoble/commits
>> local notes.rewriteref refs/notes/benknoble/commits
>> local notes.displayref refs/notes/origin/amlog
>>
>> So I would have expected the notes to get rewritten?
>>
>> - Running "git commit … --amend …" (author change and all) rewrites
>> the notes
>> - Running "git rebase -x echo" rewrites the notes (well, it has
>> nothing to do right now, so it doesn't modify anything; however, I'm
>> 99.9% convinced that when I did a plain rebase earlier today the notes
>> were preserved, just like they are all the time)
>>
>> It's just the combination that loses them :/
>>
>
next prev parent reply other threads:[~2026-08-05 16:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-05 13:13 BUG? git rebase -x "git commit --amend …" loses notes D. Ben Knoble
2026-08-05 13:42 ` Phillip Wood
2026-08-05 16:31 ` Phillip Wood [this message]
2026-08-06 12:01 ` D. Ben Knoble
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=de96a0de-a0a3-4e3e-b44e-8991f8ae87d3@gmail.com \
--to=phillip.wood123@gmail.com \
--cc=ben.knoble@gmail.com \
--cc=git@vger.kernel.org \
--cc=phillip.wood@dunelm.org.uk \
/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