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

bug: interactive rebase's 'edit' insn copies notes to newly inserted commit

From
SZEDER Gábor <szeder.dev@gmail.com>
Date
Aug 23, 2019, 13:38 UTC
Message-ID
<20190823133850.GK20404@szeder.dev>

I noticed that somehow two commits on the same branch ended up with the same note attached. I believe that this is the result of me using interactive rebase's 'edit' instruction to insert new commits, and then it copied the note from the edited commit to the commit from from where I 'git rebase --continue'-ed.

Here's a simple illustration:
  $ git log --oneline --notes
  70be36f (HEAD -> master) third
  02b5ef9 second
  Notes:
      A note on the second commit
  
  f93427a first
  $ git config --get notes.rewriteref 
  refs/notes/commits
  $ git rebase -i HEAD^^
  ## Change the instruction sheet to 'edit' the "second" commit ##
  Stopped at 02b5ef9...  second
  You can amend the commit now, with
  
    git commit --amend 
  
  Once you are satisfied with your changes, run
  
    git rebase --continue
  $ git commit --allow-empty -m "Insert new commit #1"
  [detached HEAD 2d05076] Insert new commit #1
  $ git commit --allow-empty -m "Insert new commit #2"
  [detached HEAD 0ed24dc] Insert new commit #2
  $ git rebase --continue 
  Successfully rebased and updated refs/heads/master.
  $ git log --oneline --notes
  b02a593 (HEAD -> master) third
  0ed24dc Insert new commit #2
  Notes:
      A note on the second commit
  
  2d05076 Insert new commit #1
  02b5ef9 second
  Notes:
      A note on the second commit
  
  f93427a first

Notice how the note now appears twice, because it has been copied from the (unmodified) "second" commit to the last commit that has been inserted on top before continuing.

I certainly didn't expect this, and can't readily see a use case where it's desirable, but maybe I just lack imagination :) However, once rebase stops for the 'edit' instruction the user can do just about anything, so I'm not sure how rebase could figure out when to copy the note and when not.

This is not a regression of following the rewrite in C, the scripted version had the same behavior (I think v1.8.0 was the oldest I tried).

This doesn't happen when inserting a 'break' instruction between picking the "second" and "third" commits, and then adding new commits. Alas, the 'break' instruction is not even a year old, and I have been using 'edit' for this purpose for over a decade now... so re-training my fingers will be hard :)

Next: Junio C Hamano
Message 1 of 2 in “bug: interactive rebase's 'edit' insn copies notes to newly inserted commit”
  1. SZEDER GáborAug 23, 2019
  2. Junio C HamanoAug 23, 2019

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.