{"thread":{"id":"16685","subject":"[PATCH] Show a failure of rebase -p if the merge had a conflict","startedAt":"2008-12-11T16:21:01Z","lastAt":"2008-12-22T21:16:51Z","messageCount":6,"participants":["Johannes Sixt","Junio C Hamano","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"97601","messageId":"1229012461-31377-1-git-send-email-j6t@kdbg.org","threadId":"16685","inReplyTo":null,"subject":"[PATCH] Show a failure of rebase -p if the merge had a conflict","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2008-12-11T16:21:01Z","receivedAt":"2008-12-11T16:21:01Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"This extends t3409-rebase-preserve-merges by a case where the merge that\nis rebased has a conflict. Therefore, the rebase stops and expects that\nthe user resolves the conflict. However, currently rebase --continue\nfails because .git/rebase-merge/author-script is missing.\n\nThe test script had allocated two identical clones, but only one of them\n(clone2) was used. Now we use both as indicated in the comment. Also, an\ninstance of && was missing in the setup part.\n\nSigned-off-by: Johannes Sixt <j6t@kdbg.org>\n---\n  BTW, I'm not 100% sure whether the additional tests of what to expect\n  from the test if it did not fail are correct.\n\n  I am unable to fix the failure.\n\n  -- Hannes\n\n  [Sorry, Junio, for the resend. git send-email & PEBCAK. :-/ ]\n\n t/t3409-rebase-preserve-merges.sh |   43 ++++++++++++++++++++++++++++++++----\n 1 files changed, 38 insertions(+), 5 deletions(-)\n\ndiff --git a/t/t3409-rebase-preserve-merges.sh b/t/t3409-rebase-preserve-merges.sh\nindex 8cde40f..02a6401 100755\n--- a/t/t3409-rebase-preserve-merges.sh\n+++ b/t/t3409-rebase-preserve-merges.sh\n@@ -11,7 +11,7 @@ Run \"git rebase -p\" and check that merges are properly carried along\n GIT_AUTHOR_EMAIL=bogus_email_address\n export GIT_AUTHOR_EMAIL\n \n-#echo 'Setting up:\n+#Clone 1 (trivial merge):\n #\n #A1--A2  <-- origin/master\n # \\   \\\n@@ -19,7 +19,15 @@ export GIT_AUTHOR_EMAIL\n #   \\\n #    B2  <-- origin/topic\n #\n-#'\n+#Clone 2 (conflicting merge):\n+#\n+#A1--A2--B3   <-- origin/master\n+# \\       \\\n+#  B1------M  <-- topic\n+#   \\\n+#    B2       <-- origin/topic\n+#\n+# In both cases, 'topic' is rebased onto 'origin/topic'.\n \n test_expect_success 'setup for merge-preserving rebase' \\\n \t'echo First > A &&\n@@ -37,12 +45,19 @@ test_expect_success 'setup for merge-preserving rebase' \\\n \tcd clone1 &&\n \tgit checkout -b topic origin/topic &&\n \tgit merge origin/master &&\n-\tcd ..\n+\tcd .. &&\n+\n+\techo Fifth > B &&\n+\tgit add B &&\n+\tgit commit -m \"Add different B\" &&\n \n \tgit clone ./. clone2\n \tcd clone2 &&\n \tgit checkout -b topic origin/topic &&\n-\tgit merge origin/master &&\n+\ttest_must_fail git merge origin/master &&\n+\techo Resolved > B &&\n+\tgit add B &&\n+\tgit commit -m \"Merge origin/master into topic\" &&\n \tcd .. &&\n \n \tgit checkout topic &&\n@@ -51,11 +66,29 @@ test_expect_success 'setup for merge-preserving rebase' \\\n '\n \n test_expect_success 'rebase -p fakes interactive rebase' '\n-\tcd clone2 &&\n+\t(\n+\tcd clone1 &&\n \tgit fetch &&\n \tgit rebase -p origin/topic &&\n \ttest 1 = $(git rev-list --all --pretty=oneline | grep \"Modify A\" | wc -l) &&\n \ttest 1 = $(git rev-list --all --pretty=oneline | grep \"Merge commit\" | wc -l)\n+\t)\n+'\n+\n+test_expect_failure '--continue works after a conflict' '\n+\t(\n+\tcd clone2 &&\n+\tgit fetch &&\n+\ttest_must_fail git rebase -p origin/topic &&\n+\ttest 2 = $(git ls-files B | wc -l) &&\n+\techo Resolved again > B &&\n+\ttest_must_fail git rebase --continue &&\n+\tgit add B &&\n+\tgit rebase --continue &&\n+\ttest 1 = $(git rev-list --all --pretty=oneline | grep \"Modify A\" | wc -l) &&\n+\ttest 1 = $(git rev-list --all --pretty=oneline | grep \"Add different\" | wc -l) &&\n+\ttest 1 = $(git rev-list --all --pretty=oneline | grep \"Merge origin\" | wc -l)\n+\t)\n '\n \n test_done\n-- \n1.6.1.rc2.22.gf3bf84\n"},{"id":"97943","messageId":"1229335531-32707-1-git-send-email-j6t@kdbg.org","threadId":"16685","inReplyTo":"1229012461-31377-1-git-send-email-j6t@kdbg.org","subject":"[PATCH 1/2 updated] Show a failure of rebase -p if the merge had a conflict","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2008-12-15T10:05:30Z","receivedAt":"2008-12-15T10:05:30Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"This extends t3409-rebase-preserve-merges by a case where the merge that\nis rebased has a conflict. Therefore, the rebase stops and expects that\nthe user resolves the conflict. However, currently rebase --continue\nfails because .git/rebase-merge/author-script is missing.\n\nThe test script had allocated two identical clones, but only one of them\n(clone2) was used. Now we use both as indicated in the comment. Also,\ntwo instances of && was missing in the setup part.\n\nSigned-off-by: Johannes Sixt <j6t@kdbg.org>\n---\n This is a resend of the earlier patch with a minor update: I missed one\n instance of && in the setup part, so there were actually two missing.\n\n -- Hannes\n\n t/t3409-rebase-preserve-merges.sh |   55 +++++++++++++++++++++++++++++-------\n 1 files changed, 44 insertions(+), 11 deletions(-)\n\ndiff --git a/t/t3409-rebase-preserve-merges.sh b/t/t3409-rebase-preserve-merges.sh\nindex 8cde40f..5ddd1d1 100755\n--- a/t/t3409-rebase-preserve-merges.sh\n+++ b/t/t3409-rebase-preserve-merges.sh\n@@ -11,15 +11,23 @@ Run \"git rebase -p\" and check that merges are properly carried along\n GIT_AUTHOR_EMAIL=bogus_email_address\n export GIT_AUTHOR_EMAIL\n \n-#echo 'Setting up:\n+# Clone 1 (trivial merge):\n #\n-#A1--A2  <-- origin/master\n-# \\   \\\n-#  B1--M  <-- topic\n-#   \\\n-#    B2  <-- origin/topic\n+# A1--A2  <-- origin/master\n+#  \\   \\\n+#   B1--M  <-- topic\n+#    \\\n+#     B2  <-- origin/topic\n #\n-#'\n+# Clone 2 (conflicting merge):\n+#\n+# A1--A2--B3   <-- origin/master\n+#  \\       \\\n+#   B1------M  <-- topic\n+#    \\\n+#     B2       <-- origin/topic\n+#\n+# In both cases, 'topic' is rebased onto 'origin/topic'.\n \n test_expect_success 'setup for merge-preserving rebase' \\\n \t'echo First > A &&\n@@ -37,12 +45,19 @@ test_expect_success 'setup for merge-preserving rebase' \\\n \tcd clone1 &&\n \tgit checkout -b topic origin/topic &&\n \tgit merge origin/master &&\n-\tcd ..\n+\tcd .. &&\n+\n+\techo Fifth > B &&\n+\tgit add B &&\n+\tgit commit -m \"Add different B\" &&\n \n-\tgit clone ./. clone2\n+\tgit clone ./. clone2 &&\n \tcd clone2 &&\n \tgit checkout -b topic origin/topic &&\n-\tgit merge origin/master &&\n+\ttest_must_fail git merge origin/master &&\n+\techo Resolved > B &&\n+\tgit add B &&\n+\tgit commit -m \"Merge origin/master into topic\" &&\n \tcd .. &&\n \n \tgit checkout topic &&\n@@ -51,11 +66,29 @@ test_expect_success 'setup for merge-preserving rebase' \\\n '\n \n test_expect_success 'rebase -p fakes interactive rebase' '\n-\tcd clone2 &&\n+\t(\n+\tcd clone1 &&\n \tgit fetch &&\n \tgit rebase -p origin/topic &&\n \ttest 1 = $(git rev-list --all --pretty=oneline | grep \"Modify A\" | wc -l) &&\n \ttest 1 = $(git rev-list --all --pretty=oneline | grep \"Merge commit\" | wc -l)\n+\t)\n+'\n+\n+test_expect_failure '--continue works after a conflict' '\n+\t(\n+\tcd clone2 &&\n+\tgit fetch &&\n+\ttest_must_fail git rebase -p origin/topic &&\n+\ttest 2 = $(git ls-files B | wc -l) &&\n+\techo Resolved again > B &&\n+\ttest_must_fail git rebase --continue &&\n+\tgit add B &&\n+\tgit rebase --continue &&\n+\ttest 1 = $(git rev-list --all --pretty=oneline | grep \"Modify A\" | wc -l) &&\n+\ttest 1 = $(git rev-list --all --pretty=oneline | grep \"Add different\" | wc -l) &&\n+\ttest 1 = $(git rev-list --all --pretty=oneline | grep \"Merge origin\" | wc -l)\n+\t)\n '\n \n test_done\n-- \n1.6.1.rc2.22.gf3bf84\n"},{"id":"97942","messageId":"1229335531-32707-2-git-send-email-j6t@kdbg.org","threadId":"16685","inReplyTo":"1229335531-32707-1-git-send-email-j6t@kdbg.org","subject":"[PATCH 2/2] rebase -i -p: Fix --continue after a merge could not be redone","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2008-12-15T10:05:31Z","receivedAt":"2008-12-15T10:05:31Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"When a merge that has a conflict was rebased, then rebase stopped to let\nthe user resolve the conflicts. However, thereafter --continue failed\nbecause the author-script was not saved. (This is rebase -i's way to\npreserve a commit's authorship.) This fixes it by doing taking the same\nfailure route after a merge that is also taken after a normal cherry-pick.\n\nSigned-off-by: Johannes Sixt <j6t@kdbg.org>\n---\n This is an attempt at fixing the failure.  I don't know whether it is\n problematic to leave a \"patch\" behind if there was actually a merge.\n Nevertheless, all rebase tests pass.\n\n -- Hannes\n \n git-rebase--interactive.sh        |    3 +--\n t/t3409-rebase-preserve-merges.sh |    2 +-\n 2 files changed, 2 insertions(+), 3 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 1172e47..89c39eb 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -253,15 +253,14 @@ pick_one_preserving_merges () {\n \t\t\tif ! GIT_AUTHOR_NAME=\"$GIT_AUTHOR_NAME\" \\\n \t\t\t\tGIT_AUTHOR_EMAIL=\"$GIT_AUTHOR_EMAIL\" \\\n \t\t\t\tGIT_AUTHOR_DATE=\"$GIT_AUTHOR_DATE\" \\\n \t\t\t\toutput git merge $STRATEGY -m \"$msg\" \\\n \t\t\t\t\t$new_parents\n \t\t\tthen\n-\t\t\t\tgit rerere\n \t\t\t\tprintf \"%s\\n\" \"$msg\" > \"$GIT_DIR\"/MERGE_MSG\n-\t\t\t\tdie Error redoing merge $sha1\n+\t\t\t\tdie_with_patch $sha1 \"Error redoing merge $sha1\"\n \t\t\tfi\n \t\t\t;;\n \t\t*)\n \t\t\toutput git cherry-pick \"$@\" ||\n \t\t\t\tdie_with_patch $sha1 \"Could not pick $sha1\"\n \t\t\t;;\ndiff --git a/t/t3409-rebase-preserve-merges.sh b/t/t3409-rebase-preserve-merges.sh\nindex 5ddd1d1..820e010 100755\n--- a/t/t3409-rebase-preserve-merges.sh\n+++ b/t/t3409-rebase-preserve-merges.sh\n@@ -72,13 +72,13 @@ test_expect_success 'rebase -p fakes interactive rebase' '\n \tgit rebase -p origin/topic &&\n \ttest 1 = $(git rev-list --all --pretty=oneline | grep \"Modify A\" | wc -l) &&\n \ttest 1 = $(git rev-list --all --pretty=oneline | grep \"Merge commit\" | wc -l)\n \t)\n '\n \n-test_expect_failure '--continue works after a conflict' '\n+test_expect_success '--continue works after a conflict' '\n \t(\n \tcd clone2 &&\n \tgit fetch &&\n \ttest_must_fail git rebase -p origin/topic &&\n \ttest 2 = $(git ls-files B | wc -l) &&\n \techo Resolved again > B &&\n-- \n1.6.1.rc2.22.gf3bf84\n"},{"id":"97944","messageId":"7v3agpyc9m.fsf@gitster.siamese.dyndns.org","threadId":"16685","inReplyTo":"1229335531-32707-2-git-send-email-j6t@kdbg.org","subject":"Re: [PATCH 2/2] rebase -i -p: Fix --continue after a merge could not be redone","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-12-15T10:16:05Z","receivedAt":"2008-12-15T10:16:05Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Sixt <j6t@kdbg.org> writes:\n\n> When a merge that has a conflict was rebased, then rebase stopped to let\n> the user resolve the conflicts. However, thereafter --continue failed\n> because the author-script was not saved. (This is rebase -i's way to\n> preserve a commit's authorship.) This fixes it by doing taking the same\n> failure route after a merge that is also taken after a normal cherry-pick.\n>\n> Signed-off-by: Johannes Sixt <j6t@kdbg.org>\n> ---\n>  This is an attempt at fixing the failure.  I don't know whether it is\n>  problematic to leave a \"patch\" behind if there was actually a merge.\n>  Nevertheless, all rebase tests pass.\n\nInteresting approach.  Dscho?\n"},{"id":"98559","messageId":"alpine.DEB.1.00.0812222139340.30769@pacific.mpi-cbg.de","threadId":"16685","inReplyTo":"1229335531-32707-2-git-send-email-j6t@kdbg.org","subject":"Re: [PATCH 2/2] rebase -i -p: Fix --continue after a merge could not be redone","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-12-22T21:06:06Z","receivedAt":"2008-12-22T21:06:06Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 15 Dec 2008, Johannes Sixt wrote:\n\n> When a merge that has a conflict was rebased, then rebase stopped to let\n> the user resolve the conflicts. However, thereafter --continue failed\n> because the author-script was not saved. (This is rebase -i's way to\n> preserve a commit's authorship.) This fixes it by doing taking the same\n> failure route after a merge that is also taken after a normal cherry-pick.\n> \n> Signed-off-by: Johannes Sixt <j6t@kdbg.org>\n> ---\n>  This is an attempt at fixing the failure.  I don't know whether it is\n>  problematic to leave a \"patch\" behind if there was actually a merge.\n\nI'd suggest leaving behind a --cc patch, so that nobody is tempted to \n\"fix\" the patch until it applies.\n\n> diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\n> index 1172e47..89c39eb 100755\n> --- a/git-rebase--interactive.sh\n> +++ b/git-rebase--interactive.sh\n> @@ -253,15 +253,14 @@ pick_one_preserving_merges () {\n>  \t\t\tif ! GIT_AUTHOR_NAME=\"$GIT_AUTHOR_NAME\" \\\n>  \t\t\t\tGIT_AUTHOR_EMAIL=\"$GIT_AUTHOR_EMAIL\" \\\n>  \t\t\t\tGIT_AUTHOR_DATE=\"$GIT_AUTHOR_DATE\" \\\n>  \t\t\t\toutput git merge $STRATEGY -m \"$msg\" \\\n>  \t\t\t\t\t$new_parents\n>  \t\t\tthen\n> -\t\t\t\tgit rerere\n\nWhy?  I found rerere pretty helpful when rebasing merges.\n\nAh, it is done by die_with_patch() already.  You might want to prevent \nheadscratching and hunting around for a few minutes, by simply mentioning \nthat fact in the commit message.\n\nI'll leave the commit message fixing to you, but the --cc patch probably \nlooks something like this -- feel free to squash in:\n\n---\n\n git-rebase--interactive.sh |   18 +++++++++++++++---\n 1 files changed, 15 insertions(+), 3 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 89c39eb..b20c101 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -115,9 +115,21 @@ mark_action_done () {\n }\n \n make_patch () {\n-\tparent_sha1=$(git rev-parse --verify \"$1\"^) ||\n-\t\tdie \"Cannot get patch for $1^\"\n-\tgit diff-tree -p \"$parent_sha1\"..\"$1\" > \"$DOTEST\"/patch\n+\tsha1_and_parents=\"$(git rev-list --parents -1 $1)\"\n+\tcase \"$sha1_and_parents\" in\n+\t*' '*' '*' '*)\n+\t\techo \"Octopus merge\"\n+\t;;\n+\t*' '*' '*)\n+\t\tgit diff --cc $sha1_and_parents\n+\t;;\n+\t*' '*)\n+\t\tgit diff-tree -R -p $sha1_and_parents\n+\t;;\n+\t*)\n+\t\techo \"Root commit\"\n+\t;;\n+\tesac > \"$DOTEST\"/patch\n \ttest -f \"$DOTEST\"/message ||\n \t\tgit cat-file commit \"$1\" | sed \"1,/^$/d\" > \"$DOTEST\"/message\n \ttest -f \"$DOTEST\"/author-script ||\n"},{"id":"98560","messageId":"alpine.DEB.1.00.0812222215170.30769@pacific.mpi-cbg.de","threadId":"16685","inReplyTo":"alpine.DEB.1.00.0812222139340.30769@pacific.mpi-cbg.de","subject":"Re: [PATCH 2/2] rebase -i -p: Fix --continue after a merge could not be redone","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-12-22T21:16:51Z","receivedAt":"2008-12-22T21:16:51Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 22 Dec 2008, Johannes Schindelin wrote:\n\n> I'll leave the commit message fixing to you, but the --cc patch probably \n> looks something like this -- feel free to squash in:\n> \n> ---\n> [... a patch ...]\n\nOoops.  Scratch that.  I tested without running the test suite, and sure \nenough, it failed.  Take that instead.\n\n--\n\n git-rebase--interactive.sh |   18 +++++++++++++++---\n 1 files changed, 15 insertions(+), 3 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 89c39eb..f08409c 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -115,9 +115,21 @@ mark_action_done () {\n }\n \n make_patch () {\n-\tparent_sha1=$(git rev-parse --verify \"$1\"^) ||\n-\t\tdie \"Cannot get patch for $1^\"\n-\tgit diff-tree -p \"$parent_sha1\"..\"$1\" > \"$DOTEST\"/patch\n+\tsha1_and_parents=\"$(git rev-list --parents -1 $1)\"\n+\tcase \"$sha1_and_parents\" in\n+\t*' '*' '*' '*)\n+\t\techo \"Octopus merge\"\n+\t;;\n+\t*' '*' '*)\n+\t\tgit diff --cc $sha1_and_parents\n+\t;;\n+\t*' '*)\n+\t\tgit diff-tree -p $1^!\n+\t;;\n+\t*)\n+\t\techo \"Root commit\"\n+\t;;\n+\tesac > \"$DOTEST\"/patch\n \ttest -f \"$DOTEST\"/message ||\n \t\tgit cat-file commit \"$1\" | sed \"1,/^$/d\" > \"$DOTEST\"/message\n \ttest -f \"$DOTEST\"/author-script ||\n"}]}