{"thread":{"id":"34848","subject":"Transfer notes when rebasing","startedAt":"2013-09-04T07:51:26Z","lastAt":"2013-09-04T08:49:45Z","messageCount":7,"participants":["Francis Moreau","Jeff King","John Keeping"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"226706","messageId":"CAC9WiBiSLMO+JM3aEHZ8xdwKE=jh+mDuo4REQ7rnQ-rTDNb9qA@mail.gmail.com","threadId":"34848","inReplyTo":null,"subject":"Transfer notes when rebasing","fromName":"Francis Moreau","fromEmail":"francis.moro@gmail.com","sentAt":"2013-09-04T07:51:26Z","receivedAt":"2013-09-04T07:51:26Z","isPatch":false,"sender":{"key":"francis.moro@gmail.com","avatar":null},"body":"Hello,\n\nWhen rebasing a branch which contains commits with notes onto another\nbranch it happens that some commits are already presents in the target\nbranch.\n\nIn that case git-rebase correctly drops those (already present)\ncommits but it also drops the notes associated with them.\n\nCan the notes be transfered somehow in the target branch on the\nalready present commits ?\n\nThanks\n-- \nFrancis\n"},{"id":"226707","messageId":"20130904075310.GB9637@sigill.intra.peff.net","threadId":"34848","inReplyTo":"CAC9WiBiSLMO+JM3aEHZ8xdwKE=jh+mDuo4REQ7rnQ-rTDNb9qA@mail.gmail.com","subject":"Re: Transfer notes when rebasing","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2013-09-04T07:53:10Z","receivedAt":"2013-09-04T07:53:10Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Sep 04, 2013 at 09:51:26AM +0200, Francis Moreau wrote:\n\n> When rebasing a branch which contains commits with notes onto another\n> branch it happens that some commits are already presents in the target\n> branch.\n> \n> In that case git-rebase correctly drops those (already present)\n> commits but it also drops the notes associated with them.\n> \n> Can the notes be transfered somehow in the target branch on the\n> already present commits ?\n\nYes, see the notes.rewriteRef config option to enable this.\n\n-Peff\n"},{"id":"226708","messageId":"20130904075941.GA2582@serenity.lan","threadId":"34848","inReplyTo":"20130904075310.GB9637@sigill.intra.peff.net","subject":"Re: Transfer notes when rebasing","fromName":"John Keeping","fromEmail":"john@keeping.me.uk","sentAt":"2013-09-04T07:59:41Z","receivedAt":"2013-09-04T07:59:41Z","isPatch":false,"sender":{"key":"john@keeping.me.uk","avatar":"https://avatars.githubusercontent.com/u/1702081?v=4"},"body":"On Wed, Sep 04, 2013 at 03:53:10AM -0400, Jeff King wrote:\n> On Wed, Sep 04, 2013 at 09:51:26AM +0200, Francis Moreau wrote:\n> \n> > When rebasing a branch which contains commits with notes onto another\n> > branch it happens that some commits are already presents in the target\n> > branch.\n> > \n> > In that case git-rebase correctly drops those (already present)\n> > commits but it also drops the notes associated with them.\n> > \n> > Can the notes be transfered somehow in the target branch on the\n> > already present commits ?\n> \n> Yes, see the notes.rewriteRef config option to enable this.\n\nDoes that actually work for this case?  It sounds like Francis has the\nnotes copying correctly when commits are rewritten but the notes are not\ncopied anywhere if the commit becomes empty.\n\nI suspect it is difficult to do that in general as there is no clear way\nto know which commit those notes should be copied to.\n"},{"id":"226709","messageId":"CAC9WiBiXsPM7f4ji6TxJMQ3V6w8tG7Hu5inp=cwp1=ZbzWb2gA@mail.gmail.com","threadId":"34848","inReplyTo":"20130904075941.GA2582@serenity.lan","subject":"Re: Transfer notes when rebasing","fromName":"Francis Moreau","fromEmail":"francis.moro@gmail.com","sentAt":"2013-09-04T08:03:09Z","receivedAt":"2013-09-04T08:03:09Z","isPatch":false,"sender":{"key":"francis.moro@gmail.com","avatar":null},"body":"On Wed, Sep 4, 2013 at 9:59 AM, John Keeping <john@keeping.me.uk> wrote:\n> On Wed, Sep 04, 2013 at 03:53:10AM -0400, Jeff King wrote:\n>> On Wed, Sep 04, 2013 at 09:51:26AM +0200, Francis Moreau wrote:\n>>\n>> > When rebasing a branch which contains commits with notes onto another\n>> > branch it happens that some commits are already presents in the target\n>> > branch.\n>> >\n>> > In that case git-rebase correctly drops those (already present)\n>> > commits but it also drops the notes associated with them.\n>> >\n>> > Can the notes be transfered somehow in the target branch on the\n>> > already present commits ?\n>>\n>> Yes, see the notes.rewriteRef config option to enable this.\n>\n> Does that actually work for this case?  It sounds like Francis has the\n> notes copying correctly when commits are rewritten but the notes are not\n> copied anywhere if the commit becomes empty.\n\nI don't think so:\n\n$ git config -l\n...\nnotes.rewriteref=refs/notes/*\n\n$ git notes show\nnote 1\n\n$ git checkout -b target master~1\nSwitched to a new branch 'target'\n\n$ git cherry-pick -x master\n[target 93740ff] commit 6 (cherry picked from commit\n5dc90209d7c0195dd9d671c234c49c903b9e1b10)\n 1 file changed, 1 insertion(+)\n\n$ git rebase target master\nFirst, rewinding head to replay your work on top of it...\n\n$ git notes show\nerror: No note found for object 93740ff96b37b2ed7aa0a78861c8beb87fdad474.\n\nThanks\n-- \nFrancis\n"},{"id":"226714","messageId":"20130904082803.GA17308@sigill.intra.peff.net","threadId":"34848","inReplyTo":"20130904075941.GA2582@serenity.lan","subject":"Re: Transfer notes when rebasing","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2013-09-04T08:28:03Z","receivedAt":"2013-09-04T08:28:03Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Sep 04, 2013 at 08:59:41AM +0100, John Keeping wrote:\n\n> On Wed, Sep 04, 2013 at 03:53:10AM -0400, Jeff King wrote:\n> > On Wed, Sep 04, 2013 at 09:51:26AM +0200, Francis Moreau wrote:\n> > \n> > > When rebasing a branch which contains commits with notes onto another\n> > > branch it happens that some commits are already presents in the target\n> > > branch.\n> > > \n> > > In that case git-rebase correctly drops those (already present)\n> > > commits but it also drops the notes associated with them.\n> > > \n> > > Can the notes be transfered somehow in the target branch on the\n> > > already present commits ?\n> > \n> > Yes, see the notes.rewriteRef config option to enable this.\n> \n> Does that actually work for this case?  It sounds like Francis has the\n> notes copying correctly when commits are rewritten but the notes are not\n> copied anywhere if the commit becomes empty.\n\nAh, I misunderstood. If we are dropping commits from the rebase because\ntheir counterpart is already applied upstream, then no, there isn't an\nautomatic way to do this.\n\nIf the commits are dropped because a commit with the same patch-id\nalready exists upstream, you could match them up by patch-id and copy\nthe notes. Annoyingly, while we have things like \"log --cherry-mark\" to\nshow which commits are already present on each side, I do not think\nthere is a way to correlate them commit for commit. So I think you are\nstuck doing something in the shell like:\n\n  patch_ids() {\n    git rev-list \"$1\" |\n    git diff-tree --stdin -p |\n    git patch-id |\n    sort\n  }\n\n  patch_ids $upstream..HEAD >us\n  patch_ids HEAD..$upstream >them\n\n  join us them |\n  cut -d' ' -f2-3 |\n  git notes copy --stdin\n\nHowever, if the commit is dropped because we find while applying that it\nbecomes empty, there is not much we can do. It may have been obsoleted\nby its counterpart patch that had a different patch-id, or it may even\nhave been obsoleted by unrelated patches. In the latter case, there is\nnothing to copy to. In the former, you would have to trying to match up\nthe commit messages or similar to guess that the two commits correspond.\n\n-Peff\n"},{"id":"226715","messageId":"CAC9WiBg+0PkEeBst6sw5uuCb4-21=zj+XCcjwKWSfAYi-ciqDA@mail.gmail.com","threadId":"34848","inReplyTo":"20130904082803.GA17308@sigill.intra.peff.net","subject":"Re: Transfer notes when rebasing","fromName":"Francis Moreau","fromEmail":"francis.moro@gmail.com","sentAt":"2013-09-04T08:47:22Z","receivedAt":"2013-09-04T08:47:22Z","isPatch":false,"sender":{"key":"francis.moro@gmail.com","avatar":null},"body":"On Wed, Sep 4, 2013 at 10:28 AM, Jeff King <peff@peff.net> wrote:\n> On Wed, Sep 04, 2013 at 08:59:41AM +0100, John Keeping wrote:\n>\n>> On Wed, Sep 04, 2013 at 03:53:10AM -0400, Jeff King wrote:\n>> > On Wed, Sep 04, 2013 at 09:51:26AM +0200, Francis Moreau wrote:\n>> >\n>> > > When rebasing a branch which contains commits with notes onto another\n>> > > branch it happens that some commits are already presents in the target\n>> > > branch.\n>> > >\n>> > > In that case git-rebase correctly drops those (already present)\n>> > > commits but it also drops the notes associated with them.\n>> > >\n>> > > Can the notes be transfered somehow in the target branch on the\n>> > > already present commits ?\n>> >\n>> > Yes, see the notes.rewriteRef config option to enable this.\n>>\n>> Does that actually work for this case?  It sounds like Francis has the\n>> notes copying correctly when commits are rewritten but the notes are not\n>> copied anywhere if the commit becomes empty.\n>\n> Ah, I misunderstood. If we are dropping commits from the rebase because\n> their counterpart is already applied upstream, then no, there isn't an\n> automatic way to do this.\n>\n> If the commits are dropped because a commit with the same patch-id\n> already exists upstream, you could match them up by patch-id and copy\n> the notes. Annoyingly, while we have things like \"log --cherry-mark\" to\n> show which commits are already present on each side, I do not think\n> there is a way to correlate them commit for commit. So I think you are\n> stuck doing something in the shell like:\n>\n>   patch_ids() {\n>     git rev-list \"$1\" |\n>     git diff-tree --stdin -p |\n>     git patch-id |\n>     sort\n>   }\n>\n>   patch_ids $upstream..HEAD >us\n>   patch_ids HEAD..$upstream >them\n>\n>   join us them |\n>   cut -d' ' -f2-3 |\n>   git notes copy --stdin\n>\n> However, if the commit is dropped because we find while applying that it\n> becomes empty, there is not much we can do. It may have been obsoleted\n> by its counterpart patch that had a different patch-id, or it may even\n> have been obsoleted by unrelated patches. In the latter case, there is\n> nothing to copy to. In the former, you would have to trying to match up\n> the commit messages or similar to guess that the two commits correspond.\n\nCan't git-rebase at least handle the case where a patch and its\ncounterpart have the same patch-id ?\n\nAlso maybe git-rebase should warn when dropping a commit having a note\nto tell the user that the note is dropped too.\n\n-- \nFrancis\n"},{"id":"226716","messageId":"20130904084945.GA22470@sigill.intra.peff.net","threadId":"34848","inReplyTo":"CAC9WiBg+0PkEeBst6sw5uuCb4-21=zj+XCcjwKWSfAYi-ciqDA@mail.gmail.com","subject":"Re: Transfer notes when rebasing","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2013-09-04T08:49:45Z","receivedAt":"2013-09-04T08:49:45Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Sep 04, 2013 at 10:47:22AM +0200, Francis Moreau wrote:\n\n> > However, if the commit is dropped because we find while applying that it\n> > becomes empty, there is not much we can do. It may have been obsoleted\n> > by its counterpart patch that had a different patch-id, or it may even\n> > have been obsoleted by unrelated patches. In the latter case, there is\n> > nothing to copy to. In the former, you would have to trying to match up\n> > the commit messages or similar to guess that the two commits correspond.\n> \n> Can't git-rebase at least handle the case where a patch and its\n> counterpart have the same patch-id ?\n\nCertainly it could. My point was only that it doesn't currently (and it\ndoes not even know what the counterpart is, only that there is one).\n\n> Also maybe git-rebase should warn when dropping a commit having a note\n> to tell the user that the note is dropped too.\n\nThat might end up annoying, depending on what you use notes for. But\nI think if it were restricted to notes that would be rewritten via\nnotes.rewriteRef, it probably makes sense.\n\nPatches welcome.\n\n-Peff\n"}]}