{"thread":{"id":"12805","subject":"[PATCH] New tests to check rebase with preserve merges","startedAt":"2008-03-22T01:19:42Z","lastAt":"2008-03-22T15:37:55Z","messageCount":19,"participants":["Jörg Sommer","Johannes Schindelin","Björn Steinbrink"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"72641","messageId":"1206148785-29466-1-git-send-email-joerg@alea.gnuu.de","threadId":"12805","inReplyTo":null,"subject":"[PATCH] rebase with preserve merges should not show merged commits","fromName":"Jörg Sommer","fromEmail":"joerg@alea.gnuu.de","sentAt":"2008-03-22T01:19:42Z","receivedAt":"2008-03-22T01:19:42Z","isPatch":true,"sender":{"key":"joerg@alea.gnuu.de","avatar":null},"body":"The current version of git-rebase--interactive shows the user the commits\ncoming from a merge.\n\nM---A---B\n \\       \\\n  o---o---+---o branch\n\nRebasing branch on M with preserve merges gives the commits A and B. But\nif you mark them for editing or remove them the rebase fails. You must\nkeep them as they are. It's useless to bother the user with these commits\nand might lead to mistakes.\n\nSigned-off-by: Jörg Sommer <joerg@alea.gnuu.de>\n---\n git-rebase--interactive.sh |    4 +++-\n 1 files changed, 3 insertions(+), 1 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 8aa7371..3879841 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -162,6 +162,8 @@ pick_one_preserving_merges () {\n \t\t\t\tnew_parents=\"$new_parents $new_p\"\n \t\t\t\t;;\n \t\t\tesac\n+\t\telse\n+\t\t\tnew_parents=\"$new_parents $p\"\n \t\tfi\n \tdone\n \tcase $fast_forward in\n@@ -523,7 +525,7 @@ do\n \t\tSHORTONTO=$(git rev-parse --short $ONTO)\n \t\tgit rev-list $MERGES_OPTION --pretty=oneline --abbrev-commit \\\n \t\t\t--abbrev=7 --reverse --left-right --cherry-pick \\\n-\t\t\t$UPSTREAM...$HEAD | \\\n+\t\t\t--first-parent $UPSTREAM...$HEAD | \\\n \t\t\tsed -n \"s/^>/pick /p\" > \"$TODO\"\n \t\tcat >> \"$TODO\" << EOF\n \n-- \n1.5.4.4\n"},{"id":"72639","messageId":"1206148785-29466-2-git-send-email-joerg@alea.gnuu.de","threadId":"12805","inReplyTo":"1206148785-29466-1-git-send-email-joerg@alea.gnuu.de","subject":"[PATCH] Check for non‐foreign commits in rebase-interactive test","fromName":"Jörg Sommer","fromEmail":"joerg@alea.gnuu.de","sentAt":"2008-03-22T01:19:43Z","receivedAt":"2008-03-22T01:19:43Z","isPatch":true,"sender":{"key":"joerg@alea.gnuu.de","avatar":null},"body":"\nSigned-off-by: Jörg Sommer <joerg@alea.gnuu.de>\n---\n t/t3404-rebase-interactive.sh |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh\nindex 9cf873f..7d1e469 100755\n--- a/t/t3404-rebase-interactive.sh\n+++ b/t/t3404-rebase-interactive.sh\n@@ -185,7 +185,7 @@ test_expect_success 'retain authorship when squashing' '\n \n test_expect_success '-p handles \"no changes\" gracefully' '\n \tHEAD=$(git rev-parse HEAD) &&\n-\tgit rebase -i -p HEAD^ &&\n+\tEXPECT_COUNT=1 git rebase -i -p HEAD^ &&\n \ttest $HEAD = $(git rev-parse HEAD)\n '\n \n@@ -205,7 +205,7 @@ test_expect_success 'preserve merges with -p' '\n \ttest_tick &&\n \tgit commit -m K file1 &&\n \ttest_tick &&\n-\tgit rebase -i -p --onto branch1 master &&\n+\tEXPECT_COUNT=3 git rebase -i -p --onto branch1 master &&\n \ttest $(git rev-parse HEAD^^2) = $(git rev-parse to-be-preserved) &&\n \ttest $(git rev-parse HEAD~3) = $(git rev-parse branch1) &&\n \ttest $(git show HEAD:file1) = C &&\n-- \n1.5.4.4\n"},{"id":"72640","messageId":"1206148785-29466-3-git-send-email-joerg@alea.gnuu.de","threadId":"12805","inReplyTo":"1206148785-29466-2-git-send-email-joerg@alea.gnuu.de","subject":"[PATCH] Handle fast forward correctly in rebase with preserve merges","fromName":"Jörg Sommer","fromEmail":"joerg@alea.gnuu.de","sentAt":"2008-03-22T01:19:44Z","receivedAt":"2008-03-22T01:19:44Z","isPatch":true,"sender":{"key":"joerg@alea.gnuu.de","avatar":null},"body":"Rebase-interactive with preserve merges does fast forward commits while\nthe parent of the old commit is not the parent of the new commit. If the\nparent of the changed commit is not touched, e.g. has no entry in the\nREWRITTEN database, a fast forward happens. With these commits\n“A---B---C” and rebase “A---C---B” would do a fast forward for C which\nleads to an incorrect result.\n\nThe fast forward is also not realised, i.e. the HEAD is not updated.\n\nAfter all is done, it was assumed that the new head is the rewritten old\nhead. But if the old head was applied before current head—as in the\nexample above—the commits after the rewritten old head are lost.\n\nSigned-off-by: Jörg Sommer <joerg@alea.gnuu.de>\n---\n git-rebase--interactive.sh |   35 ++++++++++++++++++-----------------\n 1 files changed, 18 insertions(+), 17 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 3879841..04fe3bf 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -144,6 +144,7 @@ pick_one_preserving_merges () {\n \t\tdie \"Cannot write current commit's replacement sha1\"\n \tfi\n \n+\tcurrent_sha1=$(git rev-parse --verify HEAD)\n \t# rewrite parents; if none were rewritten, we can fast-forward.\n \tfast_forward=t\n \tpreserve=t\n@@ -166,18 +167,31 @@ pick_one_preserving_merges () {\n \t\t\tnew_parents=\"$new_parents $p\"\n \t\tfi\n \tdone\n+\n+\t# Don't do a fast forward, if current commit is not the parent of\n+\t# the new commit\n+\tcase \"$new_parents\" in\n+\t\"\"|\" $current_sha1\"*)\n+\t\t;;\n+\t*)\n+\t\tfast_forward=f\n+\t\t;;\n+\tesac\n+\n \tcase $fast_forward in\n \tt)\n \t\toutput warn \"Fast forward to $sha1\"\n \t\ttest $preserve = f || echo $sha1 > \"$REWRITTEN\"/$sha1\n+\t\toutput git reset --hard $sha1\n+\t\tif test \"a$1\" = a-n\n+\t\tthen\n+\t\t\toutput git reset --soft $current_sha1\n+\t\tfi\n \t\t;;\n \tf)\n \t\ttest \"a$1\" = a-n && die \"Refusing to squash a merge: $sha1\"\n \n \t\tfirst_parent=$(expr \"$new_parents\" : ' \\([^ ]*\\)')\n-\t\t# detach HEAD to current parent\n-\t\toutput git checkout $first_parent 2> /dev/null ||\n-\t\t\tdie \"Cannot move HEAD to $first_parent\"\n \n \t\techo $sha1 > \"$DOTEST\"/current-commit\n \t\tcase \"$new_parents\" in\n@@ -330,20 +344,7 @@ do_next () {\n \tHEADNAME=$(cat \"$DOTEST\"/head-name) &&\n \tOLDHEAD=$(cat \"$DOTEST\"/head) &&\n \tSHORTONTO=$(git rev-parse --short $(cat \"$DOTEST\"/onto)) &&\n-\tif test -d \"$REWRITTEN\"\n-\tthen\n-\t\ttest -f \"$DOTEST\"/current-commit &&\n-\t\t\tcurrent_commit=$(cat \"$DOTEST\"/current-commit) &&\n-\t\t\tgit rev-parse HEAD > \"$REWRITTEN\"/$current_commit\n-\t\tif test -f \"$REWRITTEN\"/$OLDHEAD\n-\t\tthen\n-\t\t\tNEWHEAD=$(cat \"$REWRITTEN\"/$OLDHEAD)\n-\t\telse\n-\t\t\tNEWHEAD=$OLDHEAD\n-\t\tfi\n-\telse\n-\t\tNEWHEAD=$(git rev-parse HEAD)\n-\tfi &&\n+\tNEWHEAD=$(git rev-parse HEAD) &&\n \tcase $HEADNAME in\n \trefs/*)\n \t\tmessage=\"$GIT_REFLOG_ACTION: $HEADNAME onto $SHORTONTO)\" &&\n-- \n1.5.4.4\n"},{"id":"72638","messageId":"1206148785-29466-4-git-send-email-joerg@alea.gnuu.de","threadId":"12805","inReplyTo":"1206148785-29466-3-git-send-email-joerg@alea.gnuu.de","subject":"[PATCH] New tests to check rebase with preserve merges","fromName":"Jörg Sommer","fromEmail":"joerg@alea.gnuu.de","sentAt":"2008-03-22T01:19:45Z","receivedAt":"2008-03-22T01:19:45Z","isPatch":true,"sender":{"key":"joerg@alea.gnuu.de","avatar":null},"body":"\nSigned-off-by: Jörg Sommer <joerg@alea.gnuu.de>\n---\n t/t3404-rebase-interactive.sh |   27 +++++++++++++++++++++++++++\n 1 files changed, 27 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh\nindex 7d1e469..50974f0 100755\n--- a/t/t3404-rebase-interactive.sh\n+++ b/t/t3404-rebase-interactive.sh\n@@ -212,6 +212,33 @@ test_expect_success 'preserve merges with -p' '\n \ttest $(git show HEAD~2:file1) = B\n '\n \n+test_expect_success 'preserve merges with -p (case 2)' '\n+\ttest_tick &&\n+\tEXPECT_COUNT=3 FAKE_LINES=\"1 3 2\" git rebase -v -i -p branch1 &&\n+\ttest $(git rev-parse HEAD^2) = $(git rev-parse to-be-preserved) &&\n+\ttest $(git rev-parse HEAD~3) = $(git rev-parse branch1) &&\n+\ttest $(git show HEAD~2:file1) = B &&\n+\ttest $(git show HEAD~1:file1) = C\n+'\n+\n+test_expect_success 'preserve merges with -p (case 3)' '\n+\ttest_tick &&\n+\tEXPECT_COUNT=3 FAKE_LINES=\"3 1 2\" git rebase -i -p branch1 &&\n+\ttest $(git rev-parse HEAD~2^2) = $(git rev-parse to-be-preserved) &&\n+\ttest $(git rev-parse HEAD~3) = $(git rev-parse branch1) &&\n+\ttest $(git show HEAD~1:file1) = B &&\n+\ttest $(git show HEAD:file1) = C\n+'\n+\n+test_expect_success 'preserve merges really uses fast forward' '\n+\thead=$(git rev-parse HEAD) &&\n+\ttest_tick &&\n+\tEXPECT_COUNT=3 git rebase -v -i -p branch1 2>pm-ff-err &&\n+\tcat pm-ff-err &&\n+\ttest $(grep \"^Fast forward\" pm-ff-err | wc -l) -eq 3 &&\n+\ttest $(git rev-parse HEAD) = $head\n+'\n+\n test_expect_success '--continue tries to commit' '\n \ttest_tick &&\n \t! git rebase -i --onto new-branch1 HEAD^ &&\n-- \n1.5.4.4\n"},{"id":"72643","messageId":"alpine.LSU.1.00.0803220231020.4124@racer.site","threadId":"12805","inReplyTo":"1206148785-29466-1-git-send-email-joerg@alea.gnuu.de","subject":"Re: [PATCH] rebase with preserve merges should not show merged commits","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-03-22T01:33:29Z","receivedAt":"2008-03-22T01:33:29Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sat, 22 Mar 2008, Jörg Sommer wrote:\n\n> The current version of git-rebase--interactive shows the user the \n> commits coming from a merge.\n> \n> M---A---B\n>  \\       \\\n>   o---o---+---o branch\n> \n> Rebasing branch on M with preserve merges gives the commits A and B. But \n> if you mark them for editing or remove them the rebase fails. You must \n> keep them as they are. It's useless to bother the user with these \n> commits and might lead to mistakes.\n\nI don't understand.  Rebasing with \"rebase --onto <something else> M\" \n_should_ show A and B.\n\nBesides, I think that this would break exactly that case:\n\n> @@ -523,7 +525,7 @@ do\n>  \t\tSHORTONTO=$(git rev-parse --short $ONTO)\n>  \t\tgit rev-list $MERGES_OPTION --pretty=oneline --abbrev-commit \\\n>  \t\t\t--abbrev=7 --reverse --left-right --cherry-pick \\\n> -\t\t\t$UPSTREAM...$HEAD | \\\n> +\t\t\t--first-parent $UPSTREAM...$HEAD | \\\n\nIf I am not mistaken, you now mark A and B to be _not_ in the list of \ncommits all of a sudden, even if A and B _are_ reachable from \"branch\", \nbut not from \"M\".\n\nSo I think this is exactly one of the cases which made me unsure if your \nexpectation was always right.\n\nIOW I think this is _very_ easy to get wrong, and needs careful thought.\n\nCiao,\nDscho\n"},{"id":"72644","messageId":"20080322015252.GA7570@atjola.homenet","threadId":"12805","inReplyTo":"1206148785-29466-1-git-send-email-joerg@alea.gnuu.de","subject":"Re: [PATCH] rebase with preserve merges should not show merged commits","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2008-03-22T01:52:52Z","receivedAt":"2008-03-22T01:52:52Z","isPatch":true,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"On 2008.03.22 02:19:42 +0100, Jörg Sommer wrote:\n> The current version of git-rebase--interactive shows the user the commits\n> coming from a merge.\n> \n> M---A---B\n>  \\       \\\n>   o---o---+---o branch\n> \n> Rebasing branch on M with preserve merges gives the commits A and B. But\n> if you mark them for editing or remove them the rebase fails. You must\n> keep them as they are. It's useless to bother the user with these commits\n> and might lead to mistakes.\n\nUhm, why do you completely remove the possibility to edit A instead of\nfixing the code so that the editing actually works?\n\nBjörn\n"},{"id":"72650","messageId":"20080322094051.GA30074@alea.gnuu.de","threadId":"12805","inReplyTo":"20080322015252.GA7570@atjola.homenet","subject":"Re: [PATCH] rebase with preserve merges should not show merged commits","fromName":"Jörg Sommer","fromEmail":"joerg@alea.gnuu.de","sentAt":"2008-03-22T09:40:51Z","receivedAt":"2008-03-22T09:40:51Z","isPatch":true,"sender":{"key":"joerg@alea.gnuu.de","avatar":null},"body":"Hallo Björn,\n\nBjörn Steinbrink schrieb am Sat 22. Mar, 02:52 (+0100):\n> On 2008.03.22 02:19:42 +0100, Jörg Sommer wrote:\n> > The current version of git-rebase--interactive shows the user the commits\n> > coming from a merge.\n> > \n> > M---A---B\n> >  \\       \\\n> >   o---o---+---o branch\n> > \n> > Rebasing branch on M with preserve merges gives the commits A and B. But\n> > if you mark them for editing or remove them the rebase fails. You must\n> > keep them as they are. It's useless to bother the user with these commits\n> > and might lead to mistakes.\n> \n> Uhm, why do you completely remove the possibility to edit A instead of\n> fixing the code so that the editing actually works?\n\nBecause I didn't see why it's useful to edit A and create A' and merge in\nA again, later.\n\nM---A---B\n \\       \\\n  C---D---+---o branch\n\nM---A--------------B\n \\                  \\\n  C---B'---D'---A'---+---o branch\n\nBye, Jörg.\n-- \nViele Leute glauben, dass sie denken, wenn sie lediglich\nihre Vorurteile neu ordnen.\n"},{"id":"72649","messageId":"20080322094331.GB30074@alea.gnuu.de","threadId":"12805","inReplyTo":"alpine.LSU.1.00.0803220231020.4124@racer.site","subject":"Re: [PATCH] rebase with preserve merges should not show merged commits","fromName":"Jörg Sommer","fromEmail":"joerg@alea.gnuu.de","sentAt":"2008-03-22T09:43:31Z","receivedAt":"2008-03-22T09:43:31Z","isPatch":true,"sender":{"key":"joerg@alea.gnuu.de","avatar":null},"body":"Hallo,\n\nJohannes Schindelin schrieb am Sat 22. Mar, 02:33 (+0100):\n> On Sat, 22 Mar 2008, Jörg Sommer wrote:\n> \n> > The current version of git-rebase--interactive shows the user the \n> > commits coming from a merge.\n> > \n> > M---A---B\n> >  \\       \\\n> >   o---o---+---o branch\n> > \n> > Rebasing branch on M with preserve merges gives the commits A and B. But \n> > if you mark them for editing or remove them the rebase fails. You must \n> > keep them as they are. It's useless to bother the user with these \n> > commits and might lead to mistakes.\n> \n> I don't understand.  Rebasing with \"rebase --onto <something else> M\" \n> _should_ show A and B.\n\nBut IMO not “rebase --onto <something else> --preserve-merges -i M”.\n\nSchöne Grüße, Jörg.\n-- \nGeld allein macht nicht glücklich, aber es ist besser in einem Taxi zu\nweinen, als in der Straßenbahn.\n\t       \t   \t       \t\t\t(Marcel Reich‐Ranicki)\n"},{"id":"72651","messageId":"alpine.LSU.1.00.0803221222210.4124@racer.site","threadId":"12805","inReplyTo":"20080322094331.GB30074@alea.gnuu.de","subject":"Re: [PATCH] rebase with preserve merges should not show merged commits","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-03-22T11:22:57Z","receivedAt":"2008-03-22T11:22:57Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sat, 22 Mar 2008, Jörg Sommer wrote:\n\n> Johannes Schindelin schrieb am Sat 22. Mar, 02:33 (+0100):\n> > On Sat, 22 Mar 2008, Jörg Sommer wrote:\n> > \n> > > The current version of git-rebase--interactive shows the user the \n> > > commits coming from a merge.\n> > > \n> > > M---A---B\n> > >  \\       \\\n> > >   o---o---+---o branch\n> > > \n> > > Rebasing branch on M with preserve merges gives the commits A and B. But \n> > > if you mark them for editing or remove them the rebase fails. You must \n> > > keep them as they are. It's useless to bother the user with these \n> > > commits and might lead to mistakes.\n> > \n> > I don't understand.  Rebasing with \"rebase --onto <something else> M\" \n> > _should_ show A and B.\n> \n> But IMO not “rebase --onto <something else> --preserve-merges -i M”.\n\nUmm, yes it should.\n\nYou are asking to transplant everything up to and including M onto \nsomething else.\n\nCiao,\nDscho\n"},{"id":"72654","messageId":"20080322123734.GA10467@atjola.homenet","threadId":"12805","inReplyTo":"20080322094051.GA30074@alea.gnuu.de","subject":"Re: [PATCH] rebase with preserve merges should not show merged commits","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2008-03-22T12:37:34Z","receivedAt":"2008-03-22T12:37:34Z","isPatch":true,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"On 2008.03.22 10:40:51 +0100, Jörg Sommer wrote:\n> Hallo Björn,\n> \n> Björn Steinbrink schrieb am Sat 22. Mar, 02:52 (+0100):\n> > On 2008.03.22 02:19:42 +0100, Jörg Sommer wrote:\n> > > The current version of git-rebase--interactive shows the user the commits\n> > > coming from a merge.\n> > > \n> > > M---A---B\n> > >  \\       \\\n> > >   o---o---+---o branch\n> > > \n> > > Rebasing branch on M with preserve merges gives the commits A and B. But\n> > > if you mark them for editing or remove them the rebase fails. You must\n> > > keep them as they are. It's useless to bother the user with these commits\n> > > and might lead to mistakes.\n> > \n> > Uhm, why do you completely remove the possibility to edit A instead of\n> > fixing the code so that the editing actually works?\n> \n> Because I didn't see why it's useful to edit A and create A' and merge in\n> A again, later.\n> \n> M---A---B\n>  \\       \\\n>   C---D---+---o branch\n> \n> M---A--------------B\n>  \\                  \\\n>   C---B'---D'---A'---+---o branch\n\nHm? Why do you have A' and B' on the other side of the merge? Using -p\nmeans that you deliberately _disable_ the linearization. The structure\nof the history is not supposed to change at all. You're just editing A\nand the merge should pull A(edited) and B in.\n\nBjörn\n"},{"id":"72661","messageId":"20080322140648.GA3189@alea.gnuu.de","threadId":"12805","inReplyTo":"20080322015252.GA7570@atjola.homenet","subject":"Re: [PATCH] rebase with preserve merges should not show merged commits","fromName":"Jörg Sommer","fromEmail":"joerg@alea.gnuu.de","sentAt":"2008-03-22T14:06:48Z","receivedAt":"2008-03-22T14:06:48Z","isPatch":true,"sender":{"key":"joerg@alea.gnuu.de","avatar":null},"body":"Hallo Björn,\n\nBjörn Steinbrink schrieb am Sat 22. Mar, 02:52 (+0100):\n> On 2008.03.22 02:19:42 +0100, Jörg Sommer wrote:\n> > The current version of git-rebase--interactive shows the user the commits\n> > coming from a merge.\n> > \n> > M---A---B\n> >  \\       \\\n> >   o---o---+---o branch\n> > \n> > Rebasing branch on M with preserve merges gives the commits A and B. But\n> > if you mark them for editing or remove them the rebase fails. You must\n> > keep them as they are. It's useless to bother the user with these commits\n> > and might lead to mistakes.\n> \n> Uhm, why do you completely remove the possibility to edit A\n\nAhh, now I see what you've tried to say. I did add the option\n--first-parent for rebase interactive *without* preserve merges, too.\nI'll update my patch.\n\nBye, Jörg.\n-- \n“Science is the game we play with God to find out what his rules are.”\n"},{"id":"72662","messageId":"1206194907-3340-1-git-send-email-joerg@alea.gnuu.de","threadId":"12805","inReplyTo":"1206148785-29466-1-git-send-email-joerg@alea.gnuu.de","subject":"[PATCH v2 1/5] rebase with preserve merges should not show merged commits","fromName":"Jörg Sommer","fromEmail":"joerg@alea.gnuu.de","sentAt":"2008-03-22T14:08:23Z","receivedAt":"2008-03-22T14:08:23Z","isPatch":true,"sender":{"key":"joerg@alea.gnuu.de","avatar":null},"body":"The current version of git-rebase--interactive shows the user the commits\ncoming from a merge.\n\nM---A---B\n \\       \\\n  o---o---+---o branch\n\nRebasing branch on M with preserve merges gives the commits A and B. But\nif you mark them for editing or remove them the rebase fails. You must\nkeep them as they are. It's useless to bother the user with these commits\nand might lead to mistakes.\n\nSigned-off-by: Jörg Sommer <joerg@alea.gnuu.de>\n---\n git-rebase--interactive.sh |    4 +++-\n 1 files changed, 3 insertions(+), 1 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 8aa7371..e1ce44e 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -162,6 +162,8 @@ pick_one_preserving_merges () {\n \t\t\t\tnew_parents=\"$new_parents $new_p\"\n \t\t\t\t;;\n \t\t\tesac\n+\t\telse\n+\t\t\tnew_parents=\"$new_parents $p\"\n \t\tfi\n \tdone\n \tcase $fast_forward in\n@@ -513,7 +515,7 @@ do\n \t\t\t\techo $ONTO > \"$REWRITTEN\"/$c ||\n \t\t\t\t\tdie \"Could not init rewritten commits\"\n \t\t\tdone\n-\t\t\tMERGES_OPTION=\n+\t\t\tMERGES_OPTION=--first-parent\n \t\telse\n \t\t\tMERGES_OPTION=--no-merges\n \t\tfi\n-- \n1.5.4.4\n"},{"id":"72663","messageId":"1206194907-3340-2-git-send-email-joerg@alea.gnuu.de","threadId":"12805","inReplyTo":"1206194907-3340-1-git-send-email-joerg@alea.gnuu.de","subject":"[PATCH v2 2/5] New test: no merges without preserve merges","fromName":"Jörg Sommer","fromEmail":"joerg@alea.gnuu.de","sentAt":"2008-03-22T14:08:24Z","receivedAt":"2008-03-22T14:08:24Z","isPatch":true,"sender":{"key":"joerg@alea.gnuu.de","avatar":null},"body":"This test checks that no merges are included, if --preserve-merges is not\ngiven.\n\nTo see a difference between with and without merges add a second commit\nto the branch to-be-preserved. Otherwise you exchange one merge with one\ncommit, which isn't cognizable with EXPECT_COUNT.\n\nThe for loop in the test looks somewhat strange, but I didn't saw a\ndifferent way (than || exit 1) to make the test fail if an inner test\nfails. Recall: The exit code of a for loop is the exit code of the last\ncommand in the last pass, i.e. “for a in 1 2; do test $a != 1; do”\nreturns success.\n\nSigned-off-by: Jörg Sommer <joerg@alea.gnuu.de>\n---\n t/t3404-rebase-interactive.sh |   15 +++++++++++++++\n 1 files changed, 15 insertions(+), 0 deletions(-)\n\nThis patch must be applied after the first patch that fixes rebase,\nbecause it triggers a bug.\n\ndiff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh\nindex 9cf873f..8de1f21 100755\n--- a/t/t3404-rebase-interactive.sh\n+++ b/t/t3404-rebase-interactive.sh\n@@ -195,6 +195,9 @@ test_expect_success 'preserve merges with -p' '\n \tgit add unrelated-file &&\n \ttest_tick &&\n \tgit commit -m \"unrelated\" &&\n+\techo 2 > unrelated-file &&\n+\ttest_tick &&\n+\tgit commit -m \"second unrelated commit\" unrelated-file &&\n \tgit checkout -b to-be-rebased master &&\n \techo B > file1 &&\n \ttest_tick &&\n@@ -212,6 +215,18 @@ test_expect_success 'preserve merges with -p' '\n \ttest $(git show HEAD~2:file1) = B\n '\n \n+test_expect_success 'no merges without preserve merges' '\n+\thead=$(git rev-parse HEAD) &&\n+\ttest_tick &&\n+\tEXPECT_COUNT=4 git rebase -i branch1 &&\n+\ttest $(git rev-parse HEAD) != $head &&\n+        for i in 0 1 2 3\n+\tdo\n+\t\ttest $? -eq 0 &&\n+\t\ttest \"$(git rev-list --parents -1 HEAD~$i | tr -dc \" \")\" = \" \"\n+\tdone\n+'\n+\n test_expect_success '--continue tries to commit' '\n \ttest_tick &&\n \t! git rebase -i --onto new-branch1 HEAD^ &&\n-- \n1.5.4.4\n"},{"id":"72665","messageId":"1206194907-3340-3-git-send-email-joerg@alea.gnuu.de","threadId":"12805","inReplyTo":"1206194907-3340-2-git-send-email-joerg@alea.gnuu.de","subject":"[PATCH v2 3/5] Check for non‐foreign commits in rebase-interactive test","fromName":"Jörg Sommer","fromEmail":"joerg@alea.gnuu.de","sentAt":"2008-03-22T14:08:25Z","receivedAt":"2008-03-22T14:08:25Z","isPatch":true,"sender":{"key":"joerg@alea.gnuu.de","avatar":null},"body":"\nSigned-off-by: Jörg Sommer <joerg@alea.gnuu.de>\n---\n t/t3404-rebase-interactive.sh |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh\nindex 8de1f21..8a801a0 100755\n--- a/t/t3404-rebase-interactive.sh\n+++ b/t/t3404-rebase-interactive.sh\n@@ -185,7 +185,7 @@ test_expect_success 'retain authorship when squashing' '\n \n test_expect_success '-p handles \"no changes\" gracefully' '\n \tHEAD=$(git rev-parse HEAD) &&\n-\tgit rebase -i -p HEAD^ &&\n+\tEXPECT_COUNT=1 git rebase -i -p HEAD^ &&\n \ttest $HEAD = $(git rev-parse HEAD)\n '\n \n@@ -208,7 +208,7 @@ test_expect_success 'preserve merges with -p' '\n \ttest_tick &&\n \tgit commit -m K file1 &&\n \ttest_tick &&\n-\tgit rebase -i -p --onto branch1 master &&\n+\tEXPECT_COUNT=3 git rebase -i -p --onto branch1 master &&\n \ttest $(git rev-parse HEAD^^2) = $(git rev-parse to-be-preserved) &&\n \ttest $(git rev-parse HEAD~3) = $(git rev-parse branch1) &&\n \ttest $(git show HEAD:file1) = C &&\n-- \n1.5.4.4\n"},{"id":"72666","messageId":"1206194907-3340-4-git-send-email-joerg@alea.gnuu.de","threadId":"12805","inReplyTo":"1206194907-3340-3-git-send-email-joerg@alea.gnuu.de","subject":"[PATCH v2 4/5] Handle fast forward correctly in rebase with preserve merges","fromName":"Jörg Sommer","fromEmail":"joerg@alea.gnuu.de","sentAt":"2008-03-22T14:08:26Z","receivedAt":"2008-03-22T14:08:26Z","isPatch":true,"sender":{"key":"joerg@alea.gnuu.de","avatar":null},"body":"Rebase-interactive with preserve merges does fast forward commits while\nthe parent of the old commit is not the parent of the new commit. If the\nparent of the changed commit is not touched, e.g. has no entry in the\nREWRITTEN database, a fast forward happens. With these commits\n“A---B---C” and rebase “A---C---B” would do a fast forward for C which\nleads to an incorrect result.\n\nThe fast forward is also not realised, i.e. the HEAD is not updated.\n\nAfter all is done, it was assumed that the new head is the rewritten old\nhead. But if the old head was applied before current head—as in the\nexample above—the commits after the rewritten old head are lost.\n\nSigned-off-by: Jörg Sommer <joerg@alea.gnuu.de>\n---\n git-rebase--interactive.sh |   35 ++++++++++++++++++-----------------\n 1 files changed, 18 insertions(+), 17 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex e1ce44e..8626ef6 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -144,6 +144,7 @@ pick_one_preserving_merges () {\n \t\tdie \"Cannot write current commit's replacement sha1\"\n \tfi\n \n+\tcurrent_sha1=$(git rev-parse --verify HEAD)\n \t# rewrite parents; if none were rewritten, we can fast-forward.\n \tfast_forward=t\n \tpreserve=t\n@@ -166,18 +167,31 @@ pick_one_preserving_merges () {\n \t\t\tnew_parents=\"$new_parents $p\"\n \t\tfi\n \tdone\n+\n+\t# Don't do a fast forward, if current commit is not the parent of\n+\t# the new commit\n+\tcase \"$new_parents\" in\n+\t\"\"|\" $current_sha1\"*)\n+\t\t;;\n+\t*)\n+\t\tfast_forward=f\n+\t\t;;\n+\tesac\n+\n \tcase $fast_forward in\n \tt)\n \t\toutput warn \"Fast forward to $sha1\"\n \t\ttest $preserve = f || echo $sha1 > \"$REWRITTEN\"/$sha1\n+\t\toutput git reset --hard $sha1\n+\t\tif test \"a$1\" = a-n\n+\t\tthen\n+\t\t\toutput git reset --soft $current_sha1\n+\t\tfi\n \t\t;;\n \tf)\n \t\ttest \"a$1\" = a-n && die \"Refusing to squash a merge: $sha1\"\n \n \t\tfirst_parent=$(expr \"$new_parents\" : ' \\([^ ]*\\)')\n-\t\t# detach HEAD to current parent\n-\t\toutput git checkout $first_parent 2> /dev/null ||\n-\t\t\tdie \"Cannot move HEAD to $first_parent\"\n \n \t\techo $sha1 > \"$DOTEST\"/current-commit\n \t\tcase \"$new_parents\" in\n@@ -330,20 +344,7 @@ do_next () {\n \tHEADNAME=$(cat \"$DOTEST\"/head-name) &&\n \tOLDHEAD=$(cat \"$DOTEST\"/head) &&\n \tSHORTONTO=$(git rev-parse --short $(cat \"$DOTEST\"/onto)) &&\n-\tif test -d \"$REWRITTEN\"\n-\tthen\n-\t\ttest -f \"$DOTEST\"/current-commit &&\n-\t\t\tcurrent_commit=$(cat \"$DOTEST\"/current-commit) &&\n-\t\t\tgit rev-parse HEAD > \"$REWRITTEN\"/$current_commit\n-\t\tif test -f \"$REWRITTEN\"/$OLDHEAD\n-\t\tthen\n-\t\t\tNEWHEAD=$(cat \"$REWRITTEN\"/$OLDHEAD)\n-\t\telse\n-\t\t\tNEWHEAD=$OLDHEAD\n-\t\tfi\n-\telse\n-\t\tNEWHEAD=$(git rev-parse HEAD)\n-\tfi &&\n+\tNEWHEAD=$(git rev-parse HEAD) &&\n \tcase $HEADNAME in\n \trefs/*)\n \t\tmessage=\"$GIT_REFLOG_ACTION: $HEADNAME onto $SHORTONTO)\" &&\n-- \n1.5.4.4\n"},{"id":"72664","messageId":"1206194907-3340-5-git-send-email-joerg@alea.gnuu.de","threadId":"12805","inReplyTo":"1206194907-3340-4-git-send-email-joerg@alea.gnuu.de","subject":"[PATCH v2 5/5] New tests to check rebase with preserve merges","fromName":"Jörg Sommer","fromEmail":"joerg@alea.gnuu.de","sentAt":"2008-03-22T14:08:27Z","receivedAt":"2008-03-22T14:08:27Z","isPatch":true,"sender":{"key":"joerg@alea.gnuu.de","avatar":null},"body":"\nSigned-off-by: Jörg Sommer <joerg@alea.gnuu.de>\n---\n t/t3404-rebase-interactive.sh |   27 +++++++++++++++++++++++++++\n 1 files changed, 27 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh\nindex 8a801a0..2172065 100755\n--- a/t/t3404-rebase-interactive.sh\n+++ b/t/t3404-rebase-interactive.sh\n@@ -215,6 +215,33 @@ test_expect_success 'preserve merges with -p' '\n \ttest $(git show HEAD~2:file1) = B\n '\n \n+test_expect_success 'preserve merges with -p (case 2)' '\n+\ttest_tick &&\n+\tEXPECT_COUNT=3 FAKE_LINES=\"1 3 2\" git rebase -v -i -p branch1 &&\n+\ttest $(git rev-parse HEAD^2) = $(git rev-parse to-be-preserved) &&\n+\ttest $(git rev-parse HEAD~3) = $(git rev-parse branch1) &&\n+\ttest $(git show HEAD~2:file1) = B &&\n+\ttest $(git show HEAD~1:file1) = C\n+'\n+\n+test_expect_success 'preserve merges with -p (case 3)' '\n+\ttest_tick &&\n+\tEXPECT_COUNT=3 FAKE_LINES=\"3 1 2\" git rebase -i -p branch1 &&\n+\ttest $(git rev-parse HEAD~2^2) = $(git rev-parse to-be-preserved) &&\n+\ttest $(git rev-parse HEAD~3) = $(git rev-parse branch1) &&\n+\ttest $(git show HEAD~1:file1) = B &&\n+\ttest $(git show HEAD:file1) = C\n+'\n+\n+test_expect_success 'preserve merges really uses fast forward' '\n+\thead=$(git rev-parse HEAD) &&\n+\ttest_tick &&\n+\tEXPECT_COUNT=3 git rebase -v -i -p branch1 2>pm-ff-err &&\n+\tcat pm-ff-err &&\n+\ttest $(grep \"^Fast forward\" pm-ff-err | wc -l) -eq 3 &&\n+\ttest $(git rev-parse HEAD) = $head\n+'\n+\n test_expect_success 'no merges without preserve merges' '\n \thead=$(git rev-parse HEAD) &&\n \ttest_tick &&\n-- \n1.5.4.4\n"},{"id":"72668","messageId":"alpine.LSU.1.00.0803221545100.4124@racer.site","threadId":"12805","inReplyTo":"1206194907-3340-1-git-send-email-joerg@alea.gnuu.de","subject":"Re: [PATCH v2 1/5] rebase with preserve merges should not show merged commits","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-03-22T14:46:28Z","receivedAt":"2008-03-22T14:46:28Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sat, 22 Mar 2008, Jörg Sommer wrote:\n\n> The current version of git-rebase--interactive shows the user the \n> commits coming from a merge.\n> \n> M---A---B\n>  \\       \\\n>   o---o---+---o branch\n> \n> Rebasing branch on M with preserve merges gives the commits A and B. But \n> if you mark them for editing or remove them the rebase fails. You must \n> keep them as they are. It's useless to bother the user with these \n> commits and might lead to mistakes.\n\nIt is not useless.  It's just that you seemed to have found buggy \nbehaviour.  I am _totally_ opposed to your patch without even reading more \nthan the commit message.\n\nCiao,\nDscho"},{"id":"72670","messageId":"20080322151234.GA19558@atjola.homenet","threadId":"12805","inReplyTo":"20080322140648.GA3189@alea.gnuu.de","subject":"Re: [PATCH] rebase with preserve merges should not show merged commits","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2008-03-22T15:12:34Z","receivedAt":"2008-03-22T15:12:34Z","isPatch":true,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"On 2008.03.22 15:06:48 +0100, Jörg Sommer wrote:\n> Björn Steinbrink schrieb am Sat 22. Mar, 02:52 (+0100):\n> > On 2008.03.22 02:19:42 +0100, Jörg Sommer wrote:\n> > > The current version of git-rebase--interactive shows the user the commits\n> > > coming from a merge.\n> > > \n> > > M---A---B\n> > >  \\       \\\n> > >   o---o---+---o branch\n> > > \n> > > Rebasing branch on M with preserve merges gives the commits A and B. But\n> > > if you mark them for editing or remove them the rebase fails. You must\n> > > keep them as they are. It's useless to bother the user with these commits\n> > > and might lead to mistakes.\n> > \n> > Uhm, why do you completely remove the possibility to edit A\n> \n> Ahh, now I see what you've tried to say. I did add the option\n> --first-parent for rebase interactive *without* preserve merges, too.\n> I'll update my patch.\n\nI didn't even look at it closely enough to notice that.\n--preserve-merges preserves the structure of the history. You seem to\ninterpret it as to preserve the merges against the original parents,\nexcept for the first one, and that's simply not what it's meant to do. I\ncan see how that might be useful, but you'd have to add that as an\nadditional mode of operation, and not break the normal one.\n\nBjörn\n"},{"id":"72672","messageId":"20080322153755.GA3498@alea.gnuu.de","threadId":"12805","inReplyTo":"20080322151234.GA19558@atjola.homenet","subject":"Re: [PATCH] rebase with preserve merges should not show merged commits","fromName":"Jörg Sommer","fromEmail":"joerg@alea.gnuu.de","sentAt":"2008-03-22T15:37:55Z","receivedAt":"2008-03-22T15:37:55Z","isPatch":true,"sender":{"key":"joerg@alea.gnuu.de","avatar":null},"body":"Hallo Björn,\n\nBjörn Steinbrink schrieb am Sat 22. Mar, 16:12 (+0100):\n> On 2008.03.22 15:06:48 +0100, Jörg Sommer wrote:\n> > Björn Steinbrink schrieb am Sat 22. Mar, 02:52 (+0100):\n> > > On 2008.03.22 02:19:42 +0100, Jörg Sommer wrote:\n> > > > The current version of git-rebase--interactive shows the user the commits\n> > > > coming from a merge.\n> > > > \n> > > > M---A---B\n> > > >  \\       \\\n> > > >   o---o---+---o branch\n> > > > \n> > > > Rebasing branch on M with preserve merges gives the commits A and B. But\n> > > > if you mark them for editing or remove them the rebase fails. You must\n> > > > keep them as they are. It's useless to bother the user with these commits\n> > > > and might lead to mistakes.\n> > > \n> > > Uhm, why do you completely remove the possibility to edit A\n> > \n> > Ahh, now I see what you've tried to say. I did add the option\n> > --first-parent for rebase interactive *without* preserve merges, too.\n> > I'll update my patch.\n> \n> I didn't even look at it closely enough to notice that.\n> --preserve-merges preserves the structure of the history. You seem to\n> interpret it as to preserve the merges against the original parents,\n> except for the first one,\n\nYes, exactly this is my intent.\n\n> and that's simply not what it's meant to do.\n\nThat's a pity. So it's meant to be for such cases:\n\nM---A---B\n \\       \\\n  o---C---+---o branch\n\nM---A---B\n|    \\\n|     `-B'\n \\       \\\n  o---C'--+---o branch\n\n> I can see how that might be useful, but you'd have to add that as an\n> additional mode of operation, and not break the normal one.\n\nWhat's the intention of the patch that adds --first-parent somewhere that\nyou've mentioned in the IRC?\n\nI would like to send some tests for bugs I've seen. How do I correctly\ncleanup after rebase failed? It's necessary to not break following tests.\n\ntest_expect_failure '…' '\n\t…\n\tgit rebase -i …\n'\n\nShould I do something like this:\n\ntest_expect_failure '…' '\n\t…\n\tif !git rebase -i …;\n\tthen\n\t\tgit rebase --abort;\n\t\tfalse\n\tfi\n'\n\nBye, Jörg.\n-- \nManchmal denke ich, das sicherste Indiz dafür, daß anderswo im Universum\nintelligentes Leben existiert, ist, daß niemand versucht hat, mit uns\nKontakt aufzunehmen.                           (Calvin und Hobbes)\n"}]}