{"thread":{"id":"9597","subject":"bug in rebase--interactive with squash and conflicts","startedAt":"2007-08-21T15:10:04Z","lastAt":"2007-08-24T07:18:45Z","messageCount":3,"participants":["Johannes Sixt","Johannes Schindelin"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"51171","messageId":"46CB004C.AC39D562@eudaptics.com","threadId":"9597","inReplyTo":null,"subject":"bug in rebase--interactive with squash and conflicts","fromName":"Johannes Sixt","fromEmail":"j.sixt@eudaptics.com","sentAt":"2007-08-21T15:10:04Z","receivedAt":"2007-08-21T15:10:04Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Hi,\n\nThere's a problem with rebase--interactive where I want to squash two\ncommits and the one to squash is the first in the original series. In\nparticular, I change the commit list from\n\n\tpick 1\n\tpick 2\n\tpick 3\nto\n\tpick 3\n\tsquash 1\n\tpick 2\n\nIn this case, the edits of commit 3 are lost. There are conflicts when\ncommits 3 and 1 are cherry-picked.\n\nYou can simulate the problematic case by applying this patch:\n\nindex 40d6799..861ece1 100755\n--- a/t/t3404-rebase-interactive.sh\n+++ b/t/t3404-rebase-interactive.sh\n@@ -252,3 +252,4 @@ 'interrupted squash works as expected' '\n \t\techo $n >> conflict &&\n-\t\tgit add conflict &&\n+\t\techo $n > $n\n+\t\tgit add conflict $n &&\n \t\tgit commit -m $n\n@@ -256,3 +257,3 @@ 'interrupted squash works as expected' '\n \tone=$(git rev-parse HEAD~3) &&\n-\t! FAKE_LINES=\"1 squash 3 2\" git rebase -i HEAD~3 &&\n+\t! FAKE_LINES=\"3 squash 1 2\" git rebase -i HEAD~3 &&\n \t(echo one; echo two; echo four) > conflict &&\n\n\nThe test fails now, because git rebase --continue did not fail although\nit should have. Run\n\n   gitk HEAD to-be-rebased@{1}\n\nNote that the rebase was completed, i.e. there are now 2 commits instead\nof the original 3. But the file 'four' is missing and the final contents\nof the file 'conflict' is\n\none\ntwo\nthree\n\ni.e. as if commit 3 had never taken place.\n\n-- Hannes\n"},{"id":"51347","messageId":"Pine.LNX.4.64.0708222334510.20400@racer.site","threadId":"9597","inReplyTo":"46CB004C.AC39D562@eudaptics.com","subject":"[PATCH] rebase -i: fix squashing corner case","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-08-23T08:55:41Z","receivedAt":"2007-08-23T08:55:41Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nWhen squashing, rebase -i did not prevent fast forwards.  This could\nhappen when picking some other commit than the first one, and then\nsquashing the first commit.  So do not allow fast forwards when\nsquashing.\n\nNoticed by Johannes Sixt.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n\n\tOn Tue, 21 Aug 2007, Johannes Sixt wrote:\n\n\t> There's a problem with rebase--interactive where I want to \n\t> squash two commits and the one to squash is the first in the \n\t> original series.\n\n\tThanks.\n\n git-rebase--interactive.sh    |    5 +++--\n t/t3404-rebase-interactive.sh |   21 +++++++++++++++++++++\n 2 files changed, 24 insertions(+), 2 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex bdec462..ec798a1 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -96,13 +96,14 @@ die_abort () {\n }\n \n pick_one () {\n-\tcase \"$1\" in -n) sha1=$2 ;; *) sha1=$1 ;; esac\n+\tno_ff=\n+\tcase \"$1\" in -n) sha1=$2; no_ff=t ;; *) sha1=$1 ;; esac\n \toutput git rev-parse --verify $sha1 || die \"Invalid commit name: $sha1\"\n \ttest -d \"$REWRITTEN\" &&\n \t\tpick_one_preserving_merges \"$@\" && return\n \tparent_sha1=$(git rev-parse --verify $sha1^ 2>/dev/null)\n \tcurrent_sha1=$(git rev-parse --verify HEAD)\n-\tif test $current_sha1 = $parent_sha1; then\n+\tif test $no_ff$current_sha1 = $parent_sha1; then\n \t\toutput git reset --hard $sha1\n \t\ttest \"a$1\" = a-n && output git reset --soft $current_sha1\n \t\tsha1=$(git rev-parse --short $sha1)\ndiff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh\nindex 40d6799..718c9c1 100755\n--- a/t/t3404-rebase-interactive.sh\n+++ b/t/t3404-rebase-interactive.sh\n@@ -264,6 +264,27 @@ test_expect_success 'interrupted squash works as expected' '\n \ttest $one = $(git rev-parse HEAD~2)\n '\n \n+test_expect_success 'interrupted squash works as expected (case 2)' '\n+\tfor n in one two three four\n+\tdo\n+\t\techo $n >> conflict &&\n+\t\tgit add conflict &&\n+\t\tgit commit -m $n\n+\tdone &&\n+\tone=$(git rev-parse HEAD~3) &&\n+\t! FAKE_LINES=\"3 squash 1 2\" git rebase -i HEAD~3 &&\n+\t(echo one; echo four) > conflict &&\n+\tgit add conflict &&\n+\t! git rebase --continue &&\n+\t(echo one; echo two; echo four) > conflict &&\n+\tgit add conflict &&\n+\t! git rebase --continue &&\n+\techo resolved > conflict &&\n+\tgit add conflict &&\n+\tgit rebase --continue &&\n+\ttest $one = $(git rev-parse HEAD~2)\n+'\n+\n test_expect_success 'ignore patch if in upstream' '\n \tHEAD=$(git rev-parse HEAD) &&\n \tgit checkout -b has-cherry-picked HEAD^ &&\n-- \n1.5.3.rc6.3.gaf460\n"},{"id":"51426","messageId":"46CE8655.1DD79C48@eudaptics.com","threadId":"9597","inReplyTo":"Pine.LNX.4.64.0708222334510.20400@racer.site","subject":"Re: [PATCH] rebase -i: fix squashing corner case","fromName":"Johannes Sixt","fromEmail":"j.sixt@eudaptics.com","sentAt":"2007-08-24T07:18:45Z","receivedAt":"2007-08-24T07:18:45Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Johannes Schindelin wrote:\n> \n> When squashing, rebase -i did not prevent fast forwards.  This could\n> happen when picking some other commit than the first one, and then\n> squashing the first commit.  So do not allow fast forwards when\n> squashing.\n\nThis indeed fixes the problem. Hence:\n\nAcked-by: Johannes Sixt <johannes.sixt@telecom.at>\n\nJunio, please apply.\n\n-- Hannes\n"}]}