{"thread":{"id":"13238","subject":"[PATCH 1/5] New merge tests","startedAt":"2008-04-24T05:43:27Z","lastAt":"2008-05-03T22:00:39Z","messageCount":3,"participants":["Sverre Hvammen Johansen","Jakub Narebski"],"isPatch":true,"patchVersion":1,"patchTotal":5},"messages":[{"id":"75130","messageId":"402c10cd0804232243u700f4f6fv130d69283c40ff1d@mail.gmail.com","threadId":"13238","inReplyTo":null,"subject":"[PATCH 1/5] New merge tests","fromName":"Sverre Hvammen Johansen","fromEmail":"hvammen@gmail.com","sentAt":"2008-04-24T05:43:27Z","receivedAt":"2008-04-24T05:43:27Z","isPatch":true,"sender":{"key":"hvammen@gmail.com","avatar":"https://gravatar.com/avatar/d1fc25ec327eea135af60fe7b56b2a2e21f711aa32167e7f505014ec88aa24bc?d=mp&s=160"},"body":"Introduce new merge tests for preparation of new features:\n\n  --ff=<fast forward option>\n  Head reduction\n  --ff=only\n\nSigned-off-by: Sverre Hvammen Johansen <hvammen@gmail.com>\n---\n t/t7601-merge-ff-options.sh |  461 +++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 461 insertions(+), 0 deletions(-)\n create mode 100755 t/t7601-merge-ff-options.sh\n\ndiff --git a/t/t7601-merge-ff-options.sh b/t/t7601-merge-ff-options.sh\nnew file mode 100755\nindex 0000000..408122e\n--- /dev/null\n+++ b/t/t7601-merge-ff-options.sh\n@@ -0,0 +1,461 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2008 Sverre Hvammen Johansen, based on t7600 by Lars Hjemli\n+#\n+\n+test_description='git-merge\n+\n+Testing basic merge operations/option parsing.'\n+\n+. ./test-lib.sh\n+\n+cat >file <<EOF\n+1\n+2\n+3\n+4\n+5\n+6\n+7\n+8\n+9\n+10\n+11\n+12\n+EOF\n+\n+cat >file.1 <<EOF\n+1 X\n+2\n+3\n+4\n+5\n+6\n+7\n+8\n+9\n+10\n+11\n+12\n+EOF\n+\n+cat >file.5 <<EOF\n+1\n+2\n+3\n+4\n+5 X\n+6\n+7\n+8\n+9\n+10\n+11\n+12\n+EOF\n+\n+cat >file.9 <<EOF\n+1\n+2\n+3\n+4\n+5\n+6\n+7\n+8\n+9 X\n+10\n+11\n+12\n+EOF\n+\n+cat  >result.0 <<EOF\n+1\n+2\n+3\n+4\n+5\n+6\n+7\n+8\n+9\n+10\n+11\n+12\n+EOF\n+\n+cat  >result.1 <<EOF\n+1 X\n+2\n+3\n+4\n+5\n+6\n+7\n+8\n+9\n+10\n+11\n+12\n+EOF\n+\n+cat >result.1-5 <<EOF\n+1 X\n+2\n+3\n+4\n+5 X\n+6\n+7\n+8\n+9\n+10\n+11\n+12\n+EOF\n+\n+cat >result.9 <<EOF\n+1\n+2\n+3\n+4\n+5\n+6\n+7\n+8\n+9 X\n+10\n+11\n+12\n+EOF\n+\n+cat >result.1-5-9 <<EOF\n+1 X\n+2\n+3\n+4\n+5 X\n+6\n+7\n+8\n+9 X\n+10\n+11\n+12\n+EOF\n+\n+cat >result.1-5-9-13 <<EOF\n+1 X\n+2\n+3\n+4\n+5 X\n+6\n+7\n+8\n+9 X\n+10\n+11\n+12\n+13 x\n+EOF\n+\n+cat >result.1-5-13 <<EOF\n+1 X\n+2\n+3\n+4\n+5 X\n+6\n+7\n+8\n+9\n+10\n+11\n+12\n+13 x\n+EOF\n+\n+cat >result.5-13 <<EOF\n+1\n+2\n+3\n+4\n+5 X\n+6\n+7\n+8\n+9\n+10\n+11\n+12\n+13 x\n+EOF\n+\n+cat >result.1-13 <<EOF\n+1 X\n+2\n+3\n+4\n+5\n+6\n+7\n+8\n+9\n+10\n+11\n+12\n+13 x\n+EOF\n+\n+cat >extend <<EOF\n+13 x\n+EOF\n+\n+\n+create_merge_msgs() {\n+       echo \"Merge commit 'c2'\" >msg.1-5 &&\n+       echo \"Merge commit 'c2'; commit 'c3'\" >msg.1-5-9 &&\n+       echo \"Squashed commit of the following:\" >squash.1 &&\n+       echo >>squash.1 &&\n+       git log --no-merges ^HEAD c1 >>squash.1 &&\n+       echo \"Squashed commit of the following:\" >squash.1-5 &&\n+       echo >>squash.1-5 &&\n+       git log --no-merges ^HEAD c2 >>squash.1-5 &&\n+       echo \"Squashed commit of the following:\" >squash.1-5-9 &&\n+       echo >>squash.1-5-9 &&\n+       git log --no-merges ^HEAD c2 c3 >>squash.1-5-9\n+}\n+\n+verify_diff() {\n+       if ! diff -u \"$1\" \"$2\"\n+       then\n+               echo \"$3\"\n+               false\n+       fi\n+}\n+\n+verify_merge() {\n+       verify_diff \"$2\" \"$1\" \"[OOPS] bad merge result\" &&\n+       if test $(git ls-files -u | wc -l) -gt 0\n+       then\n+               echo \"[OOPS] unmerged files\"\n+               false\n+       fi &&\n+       if ! git diff --exit-code\n+       then\n+               echo \"[OOPS] working tree != index\"\n+               false\n+       fi &&\n+       if test -n \"$3\"\n+       then\n+               git show -s --pretty=format:%s HEAD >msg.act &&\n+               verify_diff \"$3\" msg.act \"[OOPS] bad merge message\"\n+       fi\n+}\n+\n+verify_head() {\n+       if test \"$1\" != \"$(git rev-parse HEAD)\"\n+       then\n+               echo \"[OOPS] HEAD != $1\"\n+               false\n+       fi\n+}\n+\n+verify_parents() {\n+       i=1\n+       while test $# -gt 0\n+       do\n+               if test \"$1\" != \"$(git rev-parse HEAD^$i)\"\n+               then\n+                       echo \"[OOPS] HEAD^$i != $1\"\n+                       return 1\n+               fi\n+               i=$(expr $i + 1)\n+               shift\n+       done\n+}\n+\n+verify_mergeheads() {\n+       i=1\n+       if ! test -f .git/MERGE_HEAD\n+       then\n+               echo \"[OOPS] MERGE_HEAD is missing\"\n+               false\n+       fi &&\n+       while test $# -gt 0\n+       do\n+               head=$(head -n $i .git/MERGE_HEAD | tail -n 1)\n+               if test \"$1\" != \"$head\"\n+               then\n+                       echo \"[OOPS] MERGE_HEAD $i != $1\"\n+                       return 1\n+               fi\n+               i=$(expr $i + 1)\n+               shift\n+       done\n+}\n+\n+verify_no_mergehead() {\n+       if test -f .git/MERGE_HEAD\n+       then\n+               echo \"[OOPS] MERGE_HEAD exists\"\n+               false\n+       fi\n+}\n+\n+\n+test_expect_success 'setup' '\n+       git add file &&\n+       test_tick &&\n+       git commit -m \"commit 0\" &&\n+       git tag c0 &&\n+       c0=$(git rev-parse HEAD) &&\n+\n+       cp file.1 file &&\n+       git add file &&\n+       test_tick &&\n+       git commit -m \"commit 1\" &&\n+       git tag c1 &&\n+       c1=$(git rev-parse HEAD) &&\n+       test_tick &&\n+\n+       git reset --hard \"$c0\" &&\n+       cp file.5 file &&\n+       git add file &&\n+       git commit -m \"commit 2\" &&\n+       test_tick &&\n+       git tag c2 &&\n+       c2=$(git rev-parse HEAD) &&\n+\n+       git reset --hard \"$c0\" &&\n+       cp file.9 file &&\n+       git add file &&\n+       test_tick &&\n+       git commit -m \"commit 3\" &&\n+       git tag c3 &&\n+       c3=$(git rev-parse HEAD) &&\n+       test_tick &&\n+\n+       git reset --hard \"$c1\" &&\n+       cat extend >>file &&\n+       git add file &&\n+       git commit -m \"commit 4\" &&\n+       git tag x1 &&\n+       x1=$(git rev-parse HEAD) &&\n+       test_tick &&\n+\n+       git reset --hard \"$c1\" &&\n+       git merge \"$c2\" &&\n+       git tag x0 &&\n+       x0=$(git rev-parse HEAD) &&\n+       test_tick &&\n+\n+       git reset --hard \"$c2\" &&\n+       cat extend >>file &&\n+       git add file &&\n+       git commit -m \"commit 5\" &&\n+       git tag x2 &&\n+       x2=$(git rev-parse HEAD) &&\n+       test_tick &&\n+\n+       git reset --hard \"$x1\" &&\n+       git merge \"$x0\" &&\n+       git tag y1 &&\n+       y1=$(git rev-parse HEAD) &&\n+       test_tick &&\n+\n+       git reset --hard \"$x0\" &&\n+       git merge \"$x2\" &&\n+       git tag y2 &&\n+       y2=$(git rev-parse HEAD) &&\n+       test_tick &&\n+\n+       git reset --hard \"$y1\" &&\n+       git merge \"$y2\" &&\n+       git tag y3 &&\n+       y3=$(git rev-parse HEAD) &&\n+       test_tick &&\n+       git reset --hard \"$c0\" &&\n+       create_merge_msgs &&\n+\n+       git reset --hard x1 &&\n+       git clone .git clone &&\n+       git config remote.clone.url clone &&\n+       git config remote.clone.fetch \"+refs/heads/*:refs/remotes/clone/*\" &&\n+\n+       (mkdir new && cd new && git init && cp ../file.9 file2 && git\nadd file2 && test_tick && git commit -m \"commit new\") &&\n+       git config remote.new.url new &&\n+       git config remote.new.fetch \"+refs/heads/*:refs/remotes/new/*\"\n+'\n+\n+test_debug 'gitk --all'\n+\n+test_expect_success 'merge c1 with c0 and c0' '\n+       git reset --hard c1 &&\n+       git config branch.master.mergeoptions \"\" &&\n+       test_tick &&\n+       git merge c0 c0 &&\n+       verify_merge file result.1 &&\n+       verify_head $c1\n+'\n+\n+test_debug 'gitk --all'\n+\n+test_expect_success 'merge c0 with c1 and c2' '\n+       git reset --hard c0 &&\n+       git config branch.master.mergeoptions \"\" &&\n+       test_tick &&\n+       git merge c1 c2 &&\n+       verify_merge file result.1-5 &&\n+       verify_parents $c1 $c2\n+'\n+\n+test_debug 'gitk --all'\n+\n+test_expect_success 'merge c1 with c0, c2, c0, and c1' '\n+       git reset --hard c1 &&\n+       git config branch.master.mergeoptions \"\" &&\n+       test_tick &&\n+       git merge c0 c2 c0 c1 &&\n+       verify_merge file result.1-5 &&\n+       verify_parents $c1 $c2\n+'\n+\n+test_debug 'gitk --all'\n+\n+test_expect_success 'merge y2 with x0, c3, and c0' '\n+       git reset --hard y2 &&\n+       git config branch.master.mergeoptions \"\" &&\n+       test_tick &&\n+       git merge x0 c3 c0 &&\n+       verify_merge file result.1-5-9-13 &&\n+       verify_parents $y2 $c3\n+'\n+\n+test_debug 'gitk --all'\n+\n+test_expect_success 'merge x0 with y2, c3, and c0' '\n+       git reset --hard x0 &&\n+       git config branch.master.mergeoptions \"\" &&\n+       test_tick &&\n+       git merge y2 c3 c0 &&\n+       verify_merge file result.1-5-9-13 &&\n+       verify_parents $y2 $c3\n+'\n+\n+test_debug 'gitk --all'\n+\n+\n+test_expect_success 'merge c1 with c2 and x1' '\n+       git reset --hard c1 &&\n+       git config branch.master.mergeoptions \"\" &&\n+       test_tick &&\n+       git merge c2 x1 &&\n+       verify_merge file result.1-5-13 &&\n+       verify_parents $c2 $x1\n+'\n+\n+test_debug 'gitk --all'\n+\n+test_done\n-- \nSverre Hvammen Johansen\n"},{"id":"75175","messageId":"m3tzhqp96h.fsf@localhost.localdomain","threadId":"13238","inReplyTo":"402c10cd0804232243u700f4f6fv130d69283c40ff1d@mail.gmail.com","subject":"Re: [PATCH 1/5] New merge tests","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2008-04-25T09:37:35Z","receivedAt":"2008-04-25T09:37:35Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"\"Sverre Hvammen Johansen\" <hvammen@gmail.com> writes:\n\n> Introduce new merge tests for preparation of new features:\n> \n>   --ff=<fast forward option>\n>   Head reduction\n>   --ff=only\n\nI think you should describe here _what_ is tested by the new test(s),\nand how it is named.\n\nBTW. the test itself is a bit short on comments...\n \n> +create_merge_msgs() {\n[...]\n> +verify_diff() {\n[...]\n> +verify_merge() {\n[...]\n> +verify_head() {\n[...]\n> +verify_parents() {\n\nIt would be nice to have 1 or 2 lines description of those functions,\nperhaps with calling convention.  See for example comments in\nt/test-lib.sh (some of which are in t/README instead ;-).\n\n> +verify_merge() {\n> +       verify_diff \"$2\" \"$1\" \"[OOPS] bad merge result\" &&\n> +       if test $(git ls-files -u | wc -l) -gt 0\n\nWhat are conventions used by other tests?  Somehow I doublt is is\n\"[OOPS]\"...\n\nInstead of\n       if test $(git ls-files -u | wc -l) -gt 0\nyou should write IMHO\n       if test -n \"$(git ls-files -u)\"\nor just\n       if test \"$(git ls-files -u)\"\n\n[...]\n> +test_expect_success 'setup' '\n> +       git add file &&\n> +       test_tick &&\n> +       git commit -m \"commit 0\" &&\n> +       git tag c0 &&\n> +       c0=$(git rev-parse HEAD) &&\n[...]\n> +'\n\nIt would be nice if you have provides, as comment to this step,\nASCII-art graph of commits you want to have created.\n\nBTW. instead of\n       c0=$(git rev-parse HEAD) &&\nyou can use\n       c0=$(git rev-parse c0^{}) &&\n\nor even \"c0^{commit}\".\n\n[...]\n> +test_expect_success 'merge c1 with c0 and c0' '\n> +       git reset --hard c1 &&\n> +       git config branch.master.mergeoptions \"\" &&\n\nNot \"git config --unset branch.master.mergeoptions\"?\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"75961","messageId":"402c10cd0805031500m234dcc7bu72682e1b8b821d1e@mail.gmail.com","threadId":"13238","inReplyTo":"m3tzhqp96h.fsf@localhost.localdomain","subject":"Re: [PATCH 1/5] New merge tests","fromName":"Sverre Hvammen Johansen","fromEmail":"hvammen@gmail.com","sentAt":"2008-05-03T22:00:39Z","receivedAt":"2008-05-03T22:00:39Z","isPatch":true,"sender":{"key":"hvammen@gmail.com","avatar":"https://gravatar.com/avatar/d1fc25ec327eea135af60fe7b56b2a2e21f711aa32167e7f505014ec88aa24bc?d=mp&s=160"},"body":"On Fri, Apr 25, 2008 at 2:37 AM, Jakub Narebski <jnareb@gmail.com> wrote:\n>\n>  I think you should describe here _what_ is tested by the new test(s),\n>  and how it is named.\n\nI do not intend to use more time on this.  They follow more or less\nthe same outline as t7600.\n\n-- \nSverre Hvammen Johansen\n"}]}