{"thread":{"id":"51715","subject":"bug: interactive rebase's 'edit' insn copies notes to newly inserted commit","startedAt":"2019-08-23T13:38:58Z","lastAt":"2019-08-23T16:41:37Z","messageCount":2,"participants":["SZEDER Gábor","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"381011","messageId":"20190823133850.GK20404@szeder.dev","threadId":"51715","inReplyTo":null,"subject":"bug: interactive rebase's 'edit' insn copies notes to newly inserted commit","fromName":"SZEDER Gábor","fromEmail":"szeder.dev@gmail.com","sentAt":"2019-08-23T13:38:50Z","receivedAt":"2019-08-23T13:38:58Z","isPatch":false,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"I noticed that somehow two commits on the same branch ended up with\nthe same note attached.  I believe that this is the result of me using\ninteractive rebase's 'edit' instruction to insert new commits, and\nthen it copied the note from the edited commit to the commit from from\nwhere I 'git rebase --continue'-ed.\n\nHere's a simple illustration:\n\n  $ git log --oneline --notes\n  70be36f (HEAD -> master) third\n  02b5ef9 second\n  Notes:\n      A note on the second commit\n  \n  f93427a first\n  $ git config --get notes.rewriteref \n  refs/notes/commits\n  $ git rebase -i HEAD^^\n  ## Change the instruction sheet to 'edit' the \"second\" commit ##\n  Stopped at 02b5ef9...  second\n  You can amend the commit now, with\n  \n    git commit --amend \n  \n  Once you are satisfied with your changes, run\n  \n    git rebase --continue\n\n  $ git commit --allow-empty -m \"Insert new commit #1\"\n  [detached HEAD 2d05076] Insert new commit #1\n  $ git commit --allow-empty -m \"Insert new commit #2\"\n  [detached HEAD 0ed24dc] Insert new commit #2\n  $ git rebase --continue \n  Successfully rebased and updated refs/heads/master.\n  $ git log --oneline --notes\n  b02a593 (HEAD -> master) third\n  0ed24dc Insert new commit #2\n  Notes:\n      A note on the second commit\n  \n  2d05076 Insert new commit #1\n  02b5ef9 second\n  Notes:\n      A note on the second commit\n  \n  f93427a first\n\nNotice how the note now appears twice, because it has been copied from\nthe (unmodified) \"second\" commit to the last commit that has been\ninserted on top before continuing.\n\nI certainly didn't expect this, and can't readily see a use case where\nit's desirable, but maybe I just lack imagination :)  However, once\nrebase stops for the 'edit' instruction the user can do just about\nanything, so I'm not sure how rebase could figure out when to copy the\nnote and when not.\n\nThis is not a regression of following the rewrite in C, the scripted\nversion had the same behavior (I think v1.8.0 was the oldest I tried).\n\nThis doesn't happen when inserting a 'break' instruction between\npicking the \"second\" and \"third\" commits, and then adding new commits.\nAlas, the 'break' instruction is not even a year old, and I have been\nusing 'edit' for this purpose for over a decade now...  so\nre-training my fingers will be hard :)\n\n"},{"id":"381015","messageId":"xmqqef1bn8av.fsf@gitster-ct.c.googlers.com","threadId":"51715","inReplyTo":"20190823133850.GK20404@szeder.dev","subject":"Re: bug: interactive rebase's 'edit' insn copies notes to newly inserted commit","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-08-23T16:41:28Z","receivedAt":"2019-08-23T16:41:37Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"SZEDER Gábor <szeder.dev@gmail.com> writes:\n\n> ...  However, once\n> rebase stops for the 'edit' instruction the user can do just about\n> anything, so I'm not sure how rebase could figure out when to copy the\n> note and when not.\n\nTrue.\n\n> This doesn't happen when inserting a 'break' instruction between\n> picking the \"second\" and \"third\" commits, and then adding new commits.\n\nMeaning the original note for the second one is carried to the\nrewritten second, and the one for the third is carried to the\nrewritten third?  That would be a reasonable outcome.\n\n> Alas, the 'break' instruction is not even a year old, and I have been\n> using 'edit' for this purpose for over a decade now...  so\n> re-training my fingers will be hard :)\n\nProbably a section in the tutorial and/or the example section of the\n\"git rebase -i\" documentation should encourage use of \"break\" when\ninserting a brand-new commit in the middle.\n\nThanks.\n"}]}