{"thread":{"id":"12767","subject":"[PATCH] New test for preserve merges and squash","startedAt":"2008-03-20T00:03:52Z","lastAt":"2008-03-21T13:14:33Z","messageCount":8,"participants":["Jörg Sommer","Junio C Hamano","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"72446","messageId":"1205971432-12641-1-git-send-email-joerg@alea.gnuu.de","threadId":"12767","inReplyTo":null,"subject":"[PATCH] New test for preserve merges and squash","fromName":"Jörg Sommer","fromEmail":"joerg@alea.gnuu.de","sentAt":"2008-03-20T00:03:52Z","receivedAt":"2008-03-20T00:03:52Z","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 |   20 ++++++++++++++++++++\n 1 files changed, 20 insertions(+), 0 deletions(-)\n\nThe current version of git fails this test. I think it's a bug, because\nthe patch is what I expect to happen. Or am I wrong?\n\ndiff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh\nindex 62e65d7..05f3828 100755\n--- a/t/t3404-rebase-interactive.sh\n+++ b/t/t3404-rebase-interactive.sh\n@@ -213,6 +213,26 @@ test_expect_success 'preserve merges with -p' '\n \ttest $(git show HEAD~2:file1) = B\n '\n \n+# This test uses to-be-preserved from the test 'preserve merges with -p'\n+test_expect_success 'squash and preserve merges' '\n+\ttest_tick &&\n+\tgit checkout -b squash-and-preserve-merges master &&\n+\techo A > file1 &&\n+\tgit commit -m SaPM-1 file1 &&\n+\techo B > file1 &&\n+\tgit commit -m SaPM-2 file1 &&\n+\tgit merge to-be-preserved &&\n+\techo C > file1 &&\n+\tgit commit -m SaPM-3 file1 &&\n+\n+        EXPECT_COUNT=4 FAKE_LINES=\"1 2 squash 4 3\" \\\n+          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+\ttest $(git show HEAD~2:file1) = A\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":"72450","messageId":"7v1w661bnx.fsf@gitster.siamese.dyndns.org","threadId":"12767","inReplyTo":"1205971432-12641-1-git-send-email-joerg@alea.gnuu.de","subject":"Re: [PATCH] New test for preserve merges and squash","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-03-20T00:28:34Z","receivedAt":"2008-03-20T00:28:34Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jörg Sommer <joerg@alea.gnuu.de> writes:\n\n> Signed-off-by: Jörg Sommer <joerg@alea.gnuu.de>\n> ---\n>  t/t3404-rebase-interactive.sh |   20 ++++++++++++++++++++\n>  1 files changed, 20 insertions(+), 0 deletions(-)\n>\n> The current version of git fails this test. I think it's a bug, because\n> the patch is what I expect to happen. Or am I wrong?\n\nPlease mark such tests with test_expect_fail.\n\nAnd also Cc: the guilty parties.\n\n\t$ git-blame master -- git-rebase--interactive.sh\n        $ git shortlog -n -s master -- git-rebase--interactive.sh\n\nwould tell you who they are ;-).\n\n> +test_expect_success 'squash and preserve merges' '\n> +\ttest_tick &&\n> +\tgit checkout -b squash-and-preserve-merges master &&\n> +\techo A > file1 &&\n> +\tgit commit -m SaPM-1 file1 &&\n> +\techo B > file1 &&\n> +\tgit commit -m SaPM-2 file1 &&\n> +\tgit merge to-be-preserved &&\n> +\techo C > file1 &&\n> +\tgit commit -m SaPM-3 file1 &&\n> +\n> +        EXPECT_COUNT=4 FAKE_LINES=\"1 2 squash 4 3\" \\\n> +          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> +\ttest $(git show HEAD~2:file1) = A\n> +'\n\nPlease split such a test into two parts, a part that sets things up (which\nwould succeed), and the part that runs the command it tries to test\n(\"rebase -i\" followed by the validation of the result, which you are\nexpecting to fail).  That way, somebody who is trying to fix the breakage\ncan stop the test script by inserting \"exit\" between the two, run the\nrebase command by hand to see what is going on, etc. to diagnose the\nissue.\n"},{"id":"72503","messageId":"20080320101809.GA23108@alea.gnuu.de","threadId":"12767","inReplyTo":"7v1w661bnx.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] New test for preserve merges and squash","fromName":"Jörg Sommer","fromEmail":"joerg@alea.gnuu.de","sentAt":"2008-03-20T10:18:09Z","receivedAt":"2008-03-20T10:18:09Z","isPatch":true,"sender":{"key":"joerg@alea.gnuu.de","avatar":null},"body":"Hi,\n\nJunio C Hamano schrieb am Wed 19. Mar, 17:28 (-0700):\n> Jörg Sommer <joerg@alea.gnuu.de> writes:\n> \n> > Signed-off-by: Jörg Sommer <joerg@alea.gnuu.de>\n> > ---\n> >  t/t3404-rebase-interactive.sh |   20 ++++++++++++++++++++\n> >  1 files changed, 20 insertions(+), 0 deletions(-)\n> >\n> > The current version of git fails this test. I think it's a bug, because\n> > the patch is what I expect to happen. Or am I wrong?\n> \n> Please mark such tests with test_expect_fail.\n\nNo, I expect the test succeeds. Currently, it fails. This might be,\nbecause my expectations are wrong or there's a bug.\n\n> And also Cc: the guilty parties.\n\nOkay, I've added Johannes the author of f09c9b8c5ff to the Cc: list.\n\nJohannes, can you explain why this test fails?\n\nBye, Jörg.\n-- \n> Definiere ‚Demokratie‘ …\n… eine Mehrheit beweist einer Minderheit, dass Widerstand zwecklos ist.\n"},{"id":"72505","messageId":"alpine.LSU.1.00.0803201208080.3983@racer.site","threadId":"12767","inReplyTo":"20080320101809.GA23108@alea.gnuu.de","subject":"Re: [PATCH] New test for preserve merges and squash","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-03-20T11:09:34Z","receivedAt":"2008-03-20T11:09:34Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 20 Mar 2008, Jörg Sommer wrote:\n\n> Junio C Hamano schrieb am Wed 19. Mar, 17:28 (-0700):\n> > Jörg Sommer <joerg@alea.gnuu.de> writes:\n> > \n> > > Signed-off-by: Jörg Sommer <joerg@alea.gnuu.de>\n> > > ---\n> > >  t/t3404-rebase-interactive.sh |   20 ++++++++++++++++++++\n> > >  1 files changed, 20 insertions(+), 0 deletions(-)\n> > >\n> > > The current version of git fails this test. I think it's a bug, \n> > > because the patch is what I expect to happen. Or am I wrong?\n> > \n> > Please mark such tests with test_expect_fail.\n> \n> No, I expect the test succeeds. Currently, it fails. This might be, \n> because my expectations are wrong or there's a bug.\n\nThe definition of \"test_expect_fail\" is: this should succeed, but needs \nfixin'.\n\n> > And also Cc: the guilty parties.\n> \n> Okay, I've added Johannes the author of f09c9b8c5ff to the Cc: list.\n> \n> Johannes, can you explain why this test fails?\n\nAt the moment, I can't, because I indeed missed your original mail.  Maybe \nI'll find time this afternoon to dive into gmane to find your original \nmail.\n\nCiao,\nDscho\n"},{"id":"72510","messageId":"1206018070-3402-1-git-send-email-joerg@alea.gnuu.de","threadId":"12767","inReplyTo":"alpine.LSU.1.00.0803201208080.3983@racer.site","subject":"[PATCH] New test for rebase with preserve merges and squash","fromName":"Jörg Sommer","fromEmail":"joerg@alea.gnuu.de","sentAt":"2008-03-20T13:01:10Z","receivedAt":"2008-03-20T13:01:10Z","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 |   52 +++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 52 insertions(+), 0 deletions(-)\n\n> > > \n> > > Please mark such tests with test_expect_fail.\n> > \n> > No, I expect the test succeeds. Currently, it fails. This might be, \n> > because my expectations are wrong or there's a bug.\n> \n> The definition of \"test_expect_fail\" is: this should succeed, but needs \n> fixin'.\n\nAhh, I didn't know this. Here's a new one:\n\ndiff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh\nindex 62e65d7..c849415 100755\n--- a/t/t3404-rebase-interactive.sh\n+++ b/t/t3404-rebase-interactive.sh\n@@ -362,4 +362,56 @@ test_expect_success 'rebase with a file named HEAD in worktree' '\n \n '\n \n+test_expect_success 'squash and preserve merges' '\n+\ttest_tick &&\n+\tgit checkout -b squash-and-preserve-merges master &&\n+\techo A > file1 &&\n+\tgit commit -m SaPM-1 file1 &&\n+\techo B > file1 &&\n+\tgit commit -m SaPM-2 file1 &&\n+\tgit merge to-be-preserved &&\n+\techo C > file1 &&\n+\tgit commit -m SaPM-3 file1\n+'\n+\n+# This test should fail, because the prompt includes the commit from the\n+# merge not only the merge:\n+# -> pick 9604163 unrelated\n+#    pick 5ef0364 SaPM-1\n+#    pick 22aadcf SaPM-2\n+#    pick 828f7d8 Merge branch 'to-be-preserved' into squash-and-preserve-merges\n+#    pick 2a15a54 SaPM-3\n+test_expect_failure 'expect preserve merges shown not commits from merge' '\n+        EXPECT_COUNT=4 FAKE_LINES=\"1 2 squash 4 3\" \\\n+          git rebase -i -p --onto branch1 master ||\n+        { git rebase --abort;\n+          EXPECT_COUNT=5 FAKE_LINES=\"1 2 3 squash 5 4\" \\\n+          git rebase -i -p --onto branch1 master;\n+          false; }\n+'\n+\n+# The rebase changes nothing: SaPM-3 is still the last commit while it\n+# should have been merged with SaMP-2 and the branch is not rebased on\n+# branch1\n+#\n+# % git forest squash-and-preserve-merges\n+# ╓─[squash-and-preserve-merges]──SaPM-3\n+# ╟ Merge branch 'to-be-preserved' into squash-and-preserve-merges\n+# ╠═╗ \n+# ╟ ║ SaPM-2\n+# ╟ ║ SaPM-1\n+# ║ ╟─[to-be-preserved]──unrelated\n+# ╟─║─[master]──E\n+# ╠═╝ \n+# ╟ D\n+# ╟ C\n+# ╟ B\n+# ╙─[A]──A\n+test_expect_failure 'squash and preserve merges' '\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+\ttest $(git show HEAD~2:file1) = A\n+'\n+\n test_done\n-- \n1.5.4.4\n"},{"id":"72543","messageId":"alpine.LSU.1.00.0803210040270.4124@racer.site","threadId":"12767","inReplyTo":"1206018070-3402-1-git-send-email-joerg@alea.gnuu.de","subject":"Re: [PATCH] New test for rebase with preserve merges and squash","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-03-20T23:46:34Z","receivedAt":"2008-03-20T23:46:34Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 20 Mar 2008, Jörg Sommer wrote:\n\n> diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh\n> index 62e65d7..c849415 100755\n> --- a/t/t3404-rebase-interactive.sh\n> +++ b/t/t3404-rebase-interactive.sh\n> @@ -362,4 +362,56 @@ test_expect_success 'rebase with a file named HEAD in worktree' '\n>  \n>  '\n>  \n> +test_expect_success 'squash and preserve merges' '\n> +\ttest_tick &&\n> +\tgit checkout -b squash-and-preserve-merges master &&\n> +\techo A > file1 &&\n> +\tgit commit -m SaPM-1 file1 &&\n> +\techo B > file1 &&\n> +\tgit commit -m SaPM-2 file1 &&\n> +\tgit merge to-be-preserved &&\n> +\techo C > file1 &&\n> +\tgit commit -m SaPM-3 file1\n> +'\n> +\n> +# This test should fail, because the prompt includes the commit from the\n> +# merge not only the merge:\n> +# -> pick 9604163 unrelated\n> +#    pick 5ef0364 SaPM-1\n> +#    pick 22aadcf SaPM-2\n> +#    pick 828f7d8 Merge branch 'to-be-preserved' into squash-and-preserve-merges\n> +#    pick 2a15a54 SaPM-3\n> +test_expect_failure 'expect preserve merges shown not commits from merge' '\n> +        EXPECT_COUNT=4 FAKE_LINES=\"1 2 squash 4 3\" \\\n> +          git rebase -i -p --onto branch1 master ||\n> +        { git rebase --abort;\n> +          EXPECT_COUNT=5 FAKE_LINES=\"1 2 3 squash 5 4\" \\\n> +          git rebase -i -p --onto branch1 master;\n> +          false; }\n> +'\n\nI'm sorry, but I have to tell you: I do not like that style at all (for \none, your expect_failure can succeed for all kind of reasons, the exit \nvalue of git rebase --abort is not even checked).\n\nAnd I do not understand the message \"expect preserve merges shown not \ncommits from merge\".\n\nWhich makes things kinda awkwardly hard for me.\n\nSo I have to guess that you think that in this case:\n\n  B---D-E-F-G\n /   ,---'\nA---C\n\na revision range B..G excludes C?  Not so.  \"^B ^C G\" would, but there is \nno way to specify this with a call to rebase.\n\nSo I find it quite logical that your test case fails.\n\nHth,\nDscho\n\n\n"},{"id":"72590","messageId":"20080321125650.GA4587@alea.gnuu.de","threadId":"12767","inReplyTo":"alpine.LSU.1.00.0803210040270.4124@racer.site","subject":"Why rebase with preserve merges asks for merged commits","fromName":"Jörg Sommer","fromEmail":"joerg@alea.gnuu.de","sentAt":"2008-03-21T12:56:50Z","receivedAt":"2008-03-21T12:56:50Z","isPatch":false,"sender":{"key":"joerg@alea.gnuu.de","avatar":null},"body":"Hallo Johannes,\n\nJohannes Schindelin schrieb am Fri 21. Mar, 00:46 (+0100):\n> On Thu, 20 Mar 2008, Jörg Sommer wrote:\n> \n> > diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh\n> > index 62e65d7..c849415 100755\n> > --- a/t/t3404-rebase-interactive.sh\n> > +++ b/t/t3404-rebase-interactive.sh\n> > @@ -362,4 +362,56 @@ test_expect_success 'rebase with a file named HEAD in worktree' '\n> >  \n> >  '\n> >  \n> > +test_expect_success 'squash and preserve merges' '\n> > +\ttest_tick &&\n> > +\tgit checkout -b squash-and-preserve-merges master &&\n> > +\techo A > file1 &&\n> > +\tgit commit -m SaPM-1 file1 &&\n> > +\techo B > file1 &&\n> > +\tgit commit -m SaPM-2 file1 &&\n> > +\tgit merge to-be-preserved &&\n> > +\techo C > file1 &&\n> > +\tgit commit -m SaPM-3 file1\n> > +'\n> > +\n> > +# This test should fail, because the prompt includes the commit from the\n> > +# merge not only the merge:\n> > +# -> pick 9604163 unrelated\n> > +#    pick 5ef0364 SaPM-1\n> > +#    pick 22aadcf SaPM-2\n> > +#    pick 828f7d8 Merge branch 'to-be-preserved' into squash-and-preserve-merges\n> > +#    pick 2a15a54 SaPM-3\n> > +test_expect_failure 'expect preserve merges shown not commits from merge' '\n> > +        EXPECT_COUNT=4 FAKE_LINES=\"1 2 squash 4 3\" \\\n> > +          git rebase -i -p --onto branch1 master ||\n> > +        { git rebase --abort;\n> > +          EXPECT_COUNT=5 FAKE_LINES=\"1 2 3 squash 5 4\" \\\n> > +          git rebase -i -p --onto branch1 master;\n> > +          false; }\n> > +'\n> \n> I'm sorry, but I have to tell you: I do not like that style at all (for \n> one, your expect_failure can succeed for all kind of reasons, the exit \n> value of git rebase --abort is not even checked).\n\nYes, it's ugly. So, let me step back. Think of the following situation:\n\nM----------U          to-be-preserved\n \\          \\\n  `--A---B---+---C    squash-and-preserve-merges\n\nWhen I do a rebase M..C with preserve merges I can decide about all commits\nincluding U which came in with the merge.\n\nU  pick 9604163 unrelated\nA  pick 5ef0364 SaPM-1\nB  pick 22aadcf SaPM-2\n+  pick 828f7d8 Merge branch 'to-be-preserved' into squash-and-preserve-merges\nC  pick 2a15a54 SaPM-3\n\nWhy I can decide about the commit U from the branch to-be-preserved? I\nexpect to see not the commit from the merged branches, because they\naren't related to the branch to be rebased.\n\nLet's take a different situation:\n\nM--U1--U2--U3\n \\           \\\n  `---A---B---+---C\n\nA rebase M..C with preserve merges asks you about the commits M..U3, too.\nWhy? I preserve the merge that pulls in these commmits.\n\nBye, Jörg.\n-- \nDie meisten Menschen wollen lieber durch Lob ruiniert\nals durch Kritik gerettet werden.\n"},{"id":"72591","messageId":"alpine.LSU.1.00.0803211410310.4124@racer.site","threadId":"12767","inReplyTo":"20080321125650.GA4587@alea.gnuu.de","subject":"Re: Why rebase with preserve merges asks for merged commits","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-03-21T13:14:33Z","receivedAt":"2008-03-21T13:14:33Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 21 Mar 2008, Jörg Sommer wrote:\n\n> Think of the following situation:\n> \n> M----------U          to-be-preserved\n>  \\          \\\n>   `--A---B---+---C    squash-and-preserve-merges\n> \n> When I do a rebase M..C with preserve merges I can decide about all commits\n> including U which came in with the merge.\n> \n> U  pick 9604163 unrelated\n> A  pick 5ef0364 SaPM-1\n> B  pick 22aadcf SaPM-2\n> +  pick 828f7d8 Merge branch 'to-be-preserved' into squash-and-preserve-merges\n> C  pick 2a15a54 SaPM-3\n> \n> Why I can decide about the commit U from the branch to-be-preserved?\n\nWell, -p obviously does not take the commits (it takes a superset in your \ncase) you would expect it to take.  I am not sure if that is always the \ncorrect thing to assume, though.\n\nIn the short run, you can do it manually by\n\n\t$ git checkout B\n\t$ git rebase --onto branch1 M\n\t$ git merge U\n\t$ git cherry-pick C\n\nCiao,\nDscho\n\nP.S.: Oh, BTW, just as in German, you have to put the verb before a \nsubject in an English question."}]}