{"thread":{"id":"14913","subject":"[PATCH] Make cherry-pick use rerere for conflict resolution.","startedAt":"2008-08-10T11:48:55Z","lastAt":"2008-08-12T07:02:05Z","messageCount":12,"participants":["Abhijit Menon-Sen","Johannes Schindelin","Petr Baudis","Johannes Sixt","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"86663","messageId":"1218368935-31124-1-git-send-email-ams@toroid.org","threadId":"14913","inReplyTo":null,"subject":"[PATCH] Make cherry-pick use rerere for conflict resolution.","fromName":"Abhijit Menon-Sen","fromEmail":"ams@toroid.org","sentAt":"2008-08-10T11:48:55Z","receivedAt":"2008-08-10T11:48:55Z","isPatch":true,"sender":{"key":"ams@toroid.org","avatar":null},"body":"Trivial change plus test, as requested by Johannes Schindelin.\n\nSigned-off-by: Abhijit Menon-Sen <ams@toroid.org>\n---\n builtin-revert.c              |    2 +\n t/t3504-cherry-pick-rerere.sh |   45 +++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 47 insertions(+), 0 deletions(-)\n create mode 100755 t/t3504-cherry-pick-rerere.sh\n\ndiff --git a/builtin-revert.c b/builtin-revert.c\nindex 27881e9..3667705 100644\n--- a/builtin-revert.c\n+++ b/builtin-revert.c\n@@ -11,6 +11,7 @@\n #include \"cache-tree.h\"\n #include \"diff.h\"\n #include \"revision.h\"\n+#include \"rerere.h\"\n \n /*\n  * This implements the builtins revert and cherry-pick.\n@@ -395,6 +396,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)\n \t\t\tdie (\"Error wrapping up %s\", defmsg);\n \t\tfprintf(stderr, \"Automatic %s failed.%s\\n\",\n \t\t\tme, help_msg(commit->object.sha1));\n+\t\trerere();\n \t\texit(1);\n \t}\n \tif (commit_lock_file(&msg_file) < 0)\ndiff --git a/t/t3504-cherry-pick-rerere.sh b/t/t3504-cherry-pick-rerere.sh\nnew file mode 100755\nindex 0000000..957b298\n--- /dev/null\n+++ b/t/t3504-cherry-pick-rerere.sh\n@@ -0,0 +1,45 @@\n+#!/bin/sh\n+\n+test_description='cherry-pick should rerere for conflicts'\n+\n+. ./test-lib.sh\n+\n+echo foo > foo\n+git add foo && git commit -q -m 1\n+\n+echo foo-master > foo\n+git add foo && git commit -q -m 2\n+\n+git checkout -b dev HEAD^\n+\n+echo foo-dev > foo\n+git add foo && git commit -q -m 3\n+\n+git config rerere.enabled true\n+\n+test_expect_success 'conflicting merge' '\n+\ttest_must_fail git merge master\n+'\n+\n+echo foo-dev > foo\n+git add foo && git commit -q -m 4\n+\n+git reset --hard HEAD^\n+\n+echo foo-dev > expect\n+\n+test_expect_success 'cherry-pick conflict' '\n+\ttest_must_fail git cherry-pick master &&\n+\ttest_cmp expect foo\n+'\n+\n+git config rerere.enabled false\n+\n+git reset --hard\n+\n+test_expect_success 'cherry-pick conflict without rerere' '\n+\ttest_must_fail git cherry-pick master &&\n+\ttest_must_fail test_cmp expect foo\n+'\n+\n+test_done\n-- \n1.6.0.rc2\n"},{"id":"86731","messageId":"alpine.DEB.1.00.0808110111430.24820@pacific.mpi-cbg.de.mpi-cbg.de","threadId":"14913","inReplyTo":"1218368935-31124-1-git-send-email-ams@toroid.org","subject":"Re: [PATCH] Make cherry-pick use rerere for conflict resolution.","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-08-10T23:12:13Z","receivedAt":"2008-08-10T23:12:13Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sun, 10 Aug 2008, Abhijit Menon-Sen wrote:\n\n> Trivial change plus test, as requested by Johannes Schindelin.\n\nI would have preferred some convincing rationale for the change instead.\n\nCiao,\nDscho\n"},{"id":"86741","messageId":"20080811023053.GA9144@toroid.org","threadId":"14913","inReplyTo":"alpine.DEB.1.00.0808110111430.24820@pacific.mpi-cbg.de.mpi-cbg.de","subject":"[PATCH v2] Make cherry-pick use rerere for conflict resolution.","fromName":"Abhijit Menon-Sen","fromEmail":"ams@toroid.org","sentAt":"2008-08-11T02:30:53Z","receivedAt":"2008-08-11T02:30:53Z","isPatch":true,"sender":{"key":"ams@toroid.org","avatar":null},"body":"It was a dark and stormy night. Sam struggled to keep his eyelids open\nas he integrated yet another gigantic patch series. Ever the optimist,\nhe'd pulled in the changes, only to discover several merge conflicts.\nBut the night was young then, and he'd fixed them all by hand.\n\nIt was only later that he noticed many lousy, one-line commit messages.\nUndaunted, he reset his branch and began to cherry-pick patches, giving\nthem a once-over, writing a comment here, squashing the odd grotesque\nhack there, and writing sensible commit messages more often than not.\n\nBut even that was hours ago, and each new but oh-so-familiar conflict\nate into his determination like maggots through decaying meat; and Sam\nwas beginning to question the wisdom of staying in this fruit business.\nHis whiskey was running low, and time was running out.\n\n\"If only\", thought Sam, \"If only cherry-pick would...\"\n\nSigned-off-by: Abhijit Menon-Sen <ams@toroid.org>\n---\n builtin-revert.c              |    2 +\n t/t3504-cherry-pick-rerere.sh |   45 +++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 47 insertions(+), 0 deletions(-)\n create mode 100755 t/t3504-cherry-pick-rerere.sh\n\ndiff --git a/builtin-revert.c b/builtin-revert.c\nindex 27881e9..3667705 100644\n--- a/builtin-revert.c\n+++ b/builtin-revert.c\n@@ -11,6 +11,7 @@\n #include \"cache-tree.h\"\n #include \"diff.h\"\n #include \"revision.h\"\n+#include \"rerere.h\"\n \n /*\n  * This implements the builtins revert and cherry-pick.\n@@ -395,6 +396,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)\n \t\t\tdie (\"Error wrapping up %s\", defmsg);\n \t\tfprintf(stderr, \"Automatic %s failed.%s\\n\",\n \t\t\tme, help_msg(commit->object.sha1));\n+\t\trerere();\n \t\texit(1);\n \t}\n \tif (commit_lock_file(&msg_file) < 0)\ndiff --git a/t/t3504-cherry-pick-rerere.sh b/t/t3504-cherry-pick-rerere.sh\nnew file mode 100755\nindex 0000000..957b298\n--- /dev/null\n+++ b/t/t3504-cherry-pick-rerere.sh\n@@ -0,0 +1,45 @@\n+#!/bin/sh\n+\n+test_description='cherry-pick should rerere for conflicts'\n+\n+. ./test-lib.sh\n+\n+echo foo > foo\n+git add foo && git commit -q -m 1\n+\n+echo foo-master > foo\n+git add foo && git commit -q -m 2\n+\n+git checkout -b dev HEAD^\n+\n+echo foo-dev > foo\n+git add foo && git commit -q -m 3\n+\n+git config rerere.enabled true\n+\n+test_expect_success 'conflicting merge' '\n+\ttest_must_fail git merge master\n+'\n+\n+echo foo-dev > foo\n+git add foo && git commit -q -m 4\n+\n+git reset --hard HEAD^\n+\n+echo foo-dev > expect\n+\n+test_expect_success 'cherry-pick conflict' '\n+\ttest_must_fail git cherry-pick master &&\n+\ttest_cmp expect foo\n+'\n+\n+git config rerere.enabled false\n+\n+git reset --hard\n+\n+test_expect_success 'cherry-pick conflict without rerere' '\n+\ttest_must_fail git cherry-pick master &&\n+\ttest_must_fail test_cmp expect foo\n+'\n+\n+test_done\n-- \n1.6.0.rc2\n"},{"id":"86758","messageId":"alpine.DEB.1.00.0808111218160.24820@pacific.mpi-cbg.de.mpi-cbg.de","threadId":"14913","inReplyTo":"20080811023053.GA9144@toroid.org","subject":"Re: [PATCH v2] Make cherry-pick use rerere for conflict resolution.","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-08-11T10:19:50Z","receivedAt":"2008-08-11T10:19:50Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 11 Aug 2008, Abhijit Menon-Sen wrote:\n\n> It was a dark and stormy night. Sam struggled to keep his eyelids open\n> as he integrated yet another gigantic patch series. Ever the optimist,\n> he'd pulled in the changes, only to discover several merge conflicts.\n> But the night was young then, and he'd fixed them all by hand.\n> \n> It was only later that he noticed many lousy, one-line commit messages.\n> Undaunted, he reset his branch and began to cherry-pick patches, giving\n> them a once-over, writing a comment here, squashing the odd grotesque\n> hack there, and writing sensible commit messages more often than not.\n> \n> But even that was hours ago, and each new but oh-so-familiar conflict\n> ate into his determination like maggots through decaying meat; and Sam\n> was beginning to question the wisdom of staying in this fruit business.\n> His whiskey was running low, and time was running out.\n> \n> \"If only\", thought Sam, \"If only cherry-pick would...\"\n\nNice try.\n\nI have tried the whole dark and lonely night to find where in the git.git \nhistory we have some equally enlightening commit message.\n\nSo in essence, it is nice what you wrote, but not a commit message.  \nPlease imitate the style of existing commit messages, especially if you \nwant to have your patch applied.\n\nCiao,\nDscho\n"},{"id":"86761","messageId":"20080811104006.GH32184@machine.or.cz","threadId":"14913","inReplyTo":"alpine.DEB.1.00.0808111218160.24820@pacific.mpi-cbg.de.mpi-cbg.de","subject":"Re: [PATCH v2] Make cherry-pick use rerere for conflict resolution.","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2008-08-11T10:40:06Z","receivedAt":"2008-08-11T10:40:06Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"  Hi,\n\n  this makes revert use rerere too, right? Maybe use\n\n\tMake cherry-pick and revert call rerere for conflicts\n\ninstead?\n\n  For janitors looking for a cleanup job, it would be nice to share this\ncode with suggest_conflicts() in the future.\n\nOn Mon, Aug 11, 2008 at 12:19:50PM +0200, Johannes Schindelin wrote:\n> On Mon, 11 Aug 2008, Abhijit Menon-Sen wrote:\n> \n> > It was a dark and stormy night. Sam struggled to keep his eyelids open\n> > as he integrated yet another gigantic patch series. Ever the optimist,\n> > he'd pulled in the changes, only to discover several merge conflicts.\n> > But the night was young then, and he'd fixed them all by hand.\n> > \n> > It was only later that he noticed many lousy, one-line commit messages.\n> > Undaunted, he reset his branch and began to cherry-pick patches, giving\n> > them a once-over, writing a comment here, squashing the odd grotesque\n> > hack there, and writing sensible commit messages more often than not.\n> > \n> > But even that was hours ago, and each new but oh-so-familiar conflict\n> > ate into his determination like maggots through decaying meat; and Sam\n> > was beginning to question the wisdom of staying in this fruit business.\n> > His whiskey was running low, and time was running out.\n> > \n> > \"If only\", thought Sam, \"If only cherry-pick would...\"\n> \n> Nice try.\n> \n> I have tried the whole dark and lonely night to find where in the git.git \n> history we have some equally enlightening commit message.\n> \n> So in essence, it is nice what you wrote, but not a commit message.  \n> Please imitate the style of existing commit messages, especially if you \n> want to have your patch applied.\n\n  come on. :-)  I think it's harmless and amusing. If there was some\nuseful information lost because of this, that would be troublesome, but\nwhat kind of \"rationale\" do you want here? The point seems obvious.\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nThe next generation of interesting software will be done\non the Macintosh, not the IBM PC.  -- Bill Gates\n"},{"id":"86765","messageId":"alpine.DEB.1.00.0808111328590.24820@pacific.mpi-cbg.de.mpi-cbg.de","threadId":"14913","inReplyTo":"20080811104006.GH32184@machine.or.cz","subject":"Re: [PATCH v2] Make cherry-pick use rerere for conflict resolution.","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-08-11T11:32:57Z","receivedAt":"2008-08-11T11:32:57Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 11 Aug 2008, Petr Baudis wrote:\n\n>   this makes revert use rerere too, right?\n\nThat would actually be a problem, no?  I am not sure that resolutions for \nreverts make sense for cherry-picks, so I am not sure if resolutions \nshould be recorded for reverts.\n\nThanks for bringing up that point,\nDscho\n"},{"id":"86766","messageId":"48A0274D.8090504@viscovery.net","threadId":"14913","inReplyTo":"alpine.DEB.1.00.0808111328590.24820@pacific.mpi-cbg.de.mpi-cbg.de","subject":"Re: [PATCH v2] Make cherry-pick use rerere for conflict resolution.","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2008-08-11T11:49:33Z","receivedAt":"2008-08-11T11:49:33Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Johannes Schindelin schrieb:\n> That would actually be a problem, no?  I am not sure that resolutions for \n> reverts make sense for cherry-picks, so I am not sure if resolutions \n> should be recorded for reverts.\n\nOf course they should. If the reversal is part of a topic branch that you\nrebase at least once, then you want to have the resolutions recorded,\ndon't you?\n\n-- Hannes\n"},{"id":"86781","messageId":"alpine.DEB.1.00.0808111748220.24820@pacific.mpi-cbg.de.mpi-cbg.de","threadId":"14913","inReplyTo":"48A0274D.8090504@viscovery.net","subject":"Re: [PATCH v2] Make cherry-pick use rerere for conflict resolution.","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-08-11T15:54:03Z","receivedAt":"2008-08-11T15:54:03Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 11 Aug 2008, Johannes Sixt wrote:\n\n> Johannes Schindelin schrieb:\n> > That would actually be a problem, no?  I am not sure that resolutions \n> > for reverts make sense for cherry-picks, so I am not sure if \n> > resolutions should be recorded for reverts.\n> \n> Of course they should.\n\nAre you sure?\n\n> If the reversal is part of a topic branch that you rebase at least once, \n> then you want to have the resolutions recorded, don't you?\n\nThat is not the revert we are talking about.  The revert we are talking \nabout is a literal \"git revert <commit>\".  Not a replay of a commit (that \nmight have been a revert originally).\n\nI am a little worried that these reverts (being negative changes) could \ninterfer with the common operation: positive changes.  Although I haven't \nbeen able to come up with a scenario where the recorded revert would \nactively be wrong in a subsequent rebase/cherry-pick.\n\nYes, I see your point that a revert on a topic branch which is then \nrebased would be nice to have its resolution recorded; that will happen \nwith the first rebase, though.\n\nHowever, if my suspicion is true, recording the resolution only with the \nfirst rebase could make things safer overall, because an occasional \ntemporary revert would not affect later cherry-picks in an unintuitive \nway.\n\nThinking about a good example, or a counterexample,\nDscho\n"},{"id":"86803","messageId":"7vmyjjxuca.fsf@gitster.siamese.dyndns.org","threadId":"14913","inReplyTo":"20080811023053.GA9144@toroid.org","subject":"Re: [PATCH v2] Make cherry-pick use rerere for conflict resolution.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-08-11T18:47:01Z","receivedAt":"2008-08-11T18:47:01Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Abhijit Menon-Sen <ams@toroid.org> writes:\n\n> It was a dark and stormy night. Sam struggled to keep his eyelids open\n> as he integrated yet another gigantic patch series. Ever the optimist,\n> he'd pulled in the changes, only to discover several merge conflicts.\n> But the night was young then, and he'd fixed them all by hand.\n>\n> It was only later that he noticed many lousy, one-line commit messages.\n> Undaunted, he reset his branch and began to cherry-pick patches, giving\n> them a once-over, writing a comment here, squashing the odd grotesque\n> hack there, and writing sensible commit messages more often than not.\n>\n> But even that was hours ago, and each new but oh-so-familiar conflict\n> ate into his determination like maggots through decaying meat; and Sam\n> was beginning to question the wisdom of staying in this fruit business.\n> His whiskey was running low, and time was running out.\n>\n> \"If only\", thought Sam, \"If only cherry-pick would...\"\n\nThat's cute, but I do not think that story is a good example.\n\nBy \"pulled in the changes\" do you mean \"he merged somebody else's work\"?\nIf so, the cherry-pick would be doing rebase of the series manually, and\nas you already may know, you are not supposed to be rebasing other\npeople's work.  And if you are indeed rebasing, that would not be a good\nexample of cherry-pick, either.\n\nDo you mean instead \"he applied many patches, but there were conflicts and\nhe wiggled them in?\"  If so, at the resolution time rerere() wouldn't have\nrecorded them in the first place, and more importantly, what you would be\ncherry-picking won't have conflicts.  What the second paragraph describes\nis what he would do with \"git rebase -i\" on top of the same base, so there\nwon't be merge conflicts, and even if there were, the use case is again\nabout rebase and not cherry-pick.\n\nA better example would be if you have two (or more) maintenance tracks\nfrom similarly old vintage and a far more advanced development track, and\ncherry-picking from that development track to backport a fix down to one\nof the maintenance track would have conflicts you need to fix.  Then you\nwould face the same conflict while propagating the same fix to another\nmaintenance track.  But even then, you would most likely cherry-pick the\ncherry-picked fix from the maintenance track, which would be conflict\nfree, instead of cherry-picking it from the development track.\n"},{"id":"86894","messageId":"20080812023411.GA14831@toroid.org","threadId":"14913","inReplyTo":"7vmyjjxuca.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH v2] Make cherry-pick use rerere for conflict resolution.","fromName":"Abhijit Menon-Sen","fromEmail":"ams@toroid.org","sentAt":"2008-08-12T02:34:11Z","receivedAt":"2008-08-12T02:34:11Z","isPatch":true,"sender":{"key":"ams@toroid.org","avatar":null},"body":"At 2008-08-11 11:47:01 -0700, gitster@pobox.com wrote:\n>\n> I do not think that story is a good example.\n\nI agree, it's a stretch.\n\nI can't think of any better rationale for the change than \"It might\nconceivably be convenient to someone at some point\", which falls a\nfair bit short of being convincing.\n\nTo be honest, it took so little time to implement this suggestion that\nI didn't realise until later that there was no realistic use-case and\nnothing to say about the patch.\n\nSorry for the noise.\n\n-- ams\n"},{"id":"86904","messageId":"7vy732ra5t.fsf@gitster.siamese.dyndns.org","threadId":"14913","inReplyTo":"20080812023411.GA14831@toroid.org","subject":"Re: [PATCH v2] Make cherry-pick use rerere for conflict resolution.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-08-12T06:59:26Z","receivedAt":"2008-08-12T06:59:26Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Abhijit Menon-Sen <ams@toroid.org> writes:\n\n> At 2008-08-11 11:47:01 -0700, gitster@pobox.com wrote:\n>>\n>> I do not think that story is a good example.\n>\n> I agree, it's a stretch.\n>\n> I can't think of any better rationale for the change than \"It might\n> conceivably be convenient to someone at some point\", which falls a\n> fair bit short of being convincing.\n>\n> To be honest, it took so little time to implement this suggestion that\n> I didn't realise until later that there was no realistic use-case and\n> nothing to say about the patch.\n\nOh, that's Ok.  I think my \"cherry-picking from devel to maint1 and then\ncherry-picking the same change to maint2\" example already shows the\npotential usefulness of the patch.  Yes, cherry-picking the change from\nmaint1 would avoid conflicts, but we do not _have to_ force the user to\nthink about it.  If the user somehow chose to cherry-pick from devel to\nmaint2, it is certainly better if we allowed the earlier resolution\napplied.\n\nIn any case, thanks for the patch --- queued in 'pu' for now.\n"},{"id":"86906","messageId":"48A1356D.6020200@viscovery.net","threadId":"14913","inReplyTo":"alpine.DEB.1.00.0808111748220.24820@pacific.mpi-cbg.de.mpi-cbg.de","subject":"Re: [PATCH v2] Make cherry-pick use rerere for conflict resolution.","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2008-08-12T07:02:05Z","receivedAt":"2008-08-12T07:02:05Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Johannes Schindelin schrieb:\n> On Mon, 11 Aug 2008, Johannes Sixt wrote:\n>> If the reversal is part of a topic branch that you rebase at least once, \n>> then you want to have the resolutions recorded, don't you?\n> \n> That is not the revert we are talking about.  The revert we are talking \n> about is a literal \"git revert <commit>\".  Not a replay of a commit (that \n> might have been a revert originally).\n\nYou are right. My example misses the point.\n\nAnother example is when you have to repeat the revert, say, you find out\nyou did it on the wrong branch. When you repeat the 'git revert' on the\ncorrect branch, you want to have the resolutions replayed.\n\n> I am a little worried that these reverts (being negative changes) could \n> interfer with the common operation: positive changes.  Although I haven't \n> been able to come up with a scenario where the recorded revert would \n> actively be wrong in a subsequent rebase/cherry-pick.\n\nI think that your worries are not justified.  A 'git revert' is not a\n\"negative\" change; it a change like any other. 'git revert' is just a\nshort hand for a more sequence of diff+apply+commit.\n\n-- Hannes\n"}]}