{"thread":{"id":"9962","subject":"[PATCH] Add test-script for git-merge porcelain","startedAt":"2007-09-21T18:23:19Z","lastAt":"2007-09-21T18:23:19Z","messageCount":1,"participants":["Lars Hjemli"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"53737","messageId":"1190398999-7350-1-git-send-email-hjemli@gmail.com","threadId":"9962","inReplyTo":null,"subject":"[PATCH] Add test-script for git-merge porcelain","fromName":"Lars Hjemli","fromEmail":"hjemli@gmail.com","sentAt":"2007-09-21T18:23:19Z","receivedAt":"2007-09-21T18:23:19Z","isPatch":true,"sender":{"key":"hjemli@gmail.com","avatar":null},"body":"This test-script tries to excercise the porcelainish aspects of git-merge.\n\nSigned-off-by: Lars Hjemli <hjemli@gmail.com>\n---\n t/t7600-merge.sh |  317 ++++++++++++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 317 insertions(+), 0 deletions(-)\n create mode 100644 t/t7600-merge.sh\n\ndiff --git a/t/t7600-merge.sh b/t/t7600-merge.sh\nnew file mode 100644\nindex 0000000..9e58636\n--- /dev/null\n+++ b/t/t7600-merge.sh\n@@ -0,0 +1,317 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2007 Lars Hjemli\n+#\n+\n+test_description='git-merge\n+\n+Testing basic merge operations/option parsing.'\n+\n+. ./test-lib.sh\n+\n+test_expect_success 'setup' '\n+\techo \"\n+1\n+2\n+3\n+4\n+5\n+6\n+7\n+8\n+9\n+\" > file &&\n+\tgit add file &&\n+\tgit commit -m \"commit 0\" &&\n+\tgit tag c0 &&\n+\tc0=$(git rev-parse HEAD) &&\n+\techo \"\n+1 X\n+2\n+3\n+4\n+5\n+6\n+7\n+8\n+9\n+\" > file &&\n+\tgit add file &&\n+\tgit commit -m \"commit 1\" &&\n+\tgit tag c1 &&\n+\tc1=$(git rev-parse HEAD) &&\n+\tgit reset --hard \"$c0\" &&\n+\techo \"\n+1\n+2\n+3\n+4\n+5 X\n+6\n+7\n+8\n+9\n+\" > file &&\n+\tgit add file &&\n+\tgit commit -m \"commit 2\" &&\n+\tgit tag c2 &&\n+\tc2=$(git rev-parse HEAD) &&\n+\tgit reset --hard \"$c0\" &&\n+\techo \"\n+1\n+2\n+3\n+4\n+5\n+6\n+7\n+8\n+9 X\n+\" > file &&\n+\tgit add file &&\n+\tgit commit -m \"commit 3\" &&\n+\tgit tag c3 &&\n+\tc3=$(git rev-parse HEAD)\n+\tgit reset --hard \"$c0\"\n+'\n+\n+test_debug 'gitk --all'\n+\n+test_expect_success 'test option parsing' '\n+\tif git merge -$ c1\n+\tthen\n+\t\techo \"[OOPS] -$ accepted\"\n+\t\tfalse\n+\tfi &&\n+\tif git merge --no-such c1\n+\tthen\n+\t\techo \"[OOPS] --no-such accepted\"\n+\t\tfalse\n+\tfi &&\n+\tif git merge -s foobar c1\n+\tthen\n+\t\techo \"[OOPS] -s foobar accepted\"\n+\t\tfalse\n+\tfi &&\n+\tif git merge -s=foobar c1\n+\tthen\n+\t\techo \"[OOPS] -s=foobar accepted\"\n+\t\tfalse\n+\tfi &&\n+\tif git merge -m\n+\tthen\n+\t\techo \"[OOPS] missing commit msg accepted\"\n+\t\tfalse\n+\tfi &&\n+\tif git merge\n+\tthen\n+\t\techo \"[OOPS] missing commit references accepted\"\n+\t\tfalse\n+\tfi\n+'\n+\n+test_expect_success 'merge c0 with c1' '\n+\tgit reset --hard c0 &&\n+\tgit merge c1 &&\n+\ttest \"$c1\" = \"$(git rev-parse HEAD)\"\n+'\n+\n+test_debug 'gitk --all'\n+\n+test_expect_success 'verify merge result' '\n+\techo \"\n+1 X\n+2\n+3\n+4\n+5\n+6\n+7\n+8\n+9\n+\" > result.1 &&\n+\tcmp -s file result.1\n+'\n+\n+test_expect_success 'merge c1 with c2' '\n+\tgit reset --hard c1 &&\n+\tgit merge c2 &&\n+\ttest \"$c1\" = \"$(git rev-parse HEAD^1)\" &&\n+\ttest \"$c2\" = \"$(git rev-parse HEAD^2)\"\n+'\n+\n+test_debug 'gitk --all'\n+\n+test_expect_success 'verify merge result' '\n+\techo \"\n+1 X\n+2\n+3\n+4\n+5 X\n+6\n+7\n+8\n+9\n+\" > result.1-5 &&\n+\tcmp -s file result.1-5\n+'\n+\n+test_expect_success 'merge c1 with c2 and c3' '\n+\tgit reset --hard c1 &&\n+\tgit merge c2 c3 &&\n+\ttest \"$c1\" = \"$(git rev-parse HEAD^1)\" &&\n+\ttest \"$c2\" = \"$(git rev-parse HEAD^2)\" &&\n+\ttest \"$c3\" = \"$(git rev-parse HEAD^3)\"\n+'\n+\n+test_debug 'gitk --all'\n+\n+test_expect_success 'verify merge result' '\n+\techo \"\n+1 X\n+2\n+3\n+4\n+5 X\n+6\n+7\n+8\n+9 X\n+\" > result.1-5-9 &&\n+\tcmp -s file result.1-5-9\n+'\n+\n+test_expect_success 'merge c0 with c1 (no-commit)' '\n+\tgit reset --hard c0 &&\n+\tgit merge --no-commit c1 &&\n+\tif test \"$c1\" != \"$(git rev-parse HEAD)\"\n+\tthen\n+\t\techo \"[OOPS] fast-forward not performed\"\n+\t\tfalse\n+\tfi &&\n+\tif ! cmp -s file result.1\n+\tthen\n+\t\techo \"[OOPS] merge result is wrong\"\n+\t\tfalse\n+\tfi\n+'\n+\n+test_debug 'gitk --all'\n+\n+test_expect_success 'merge c1 with c2 (no-commit)' '\n+\tgit reset --hard c1 &&\n+\tgit merge --no-commit c2 &&\n+\tif test \"$c1\" != \"$(git rev-parse HEAD)\"\n+\tthen\n+\t\techo \"[OOPS] HEAD changed\"\n+\t\tfalse\n+\tfi &&\n+\tif ! cmp -s file result.1-5\n+\tthen\n+\t\techo \"[OOPS] merge result is wrong\"\n+\t\tfalse\n+\tfi &&\n+\tif test \"$c2\" != \"$(cat .git/MERGE_HEAD)\"\n+\tthen\n+\t\techo \"[OOPS] MERGE_HEAD is wrong\"\n+\t\tfalse\n+\tfi\n+'\n+\n+test_debug 'gitk --all'\n+\n+test_expect_success 'merge c1 with c2 and c3 (no-commit)' '\n+\tgit reset --hard c1 &&\n+\tgit merge --no-commit c2 c3 &&\n+\tif test \"$c1\" != \"$(git rev-parse HEAD)\"\n+\tthen\n+\t\techo \"[OOPS] HEAD changed\"\n+\t\tfalse\n+\tfi &&\n+\tif ! cmp -s file result.1-5-9\n+\tthen\n+\t\techo \"[OOPS] merge result is wrong\"\n+\t\tfalse\n+\tfi &&\n+\tif ! grep -q \"$c2\" .git/MERGE_HEAD\n+\tthen\n+\t\techo \"[OOPS] c2 not in MERGE_HEAD\"\n+\t\tfalse\n+\tfi &&\n+\tif ! grep -q \"$c3\" .git/MERGE_HEAD\n+\tthen\n+\t\techo \"[OOPS] c3 not in MERGE_HEAD\"\n+\t\tfalse\n+\tfi\n+'\n+\n+test_debug 'gitk --all'\n+\n+test_expect_success 'merge c0 with c1 (squash)' '\n+\tgit reset --hard c0 &&\n+\tgit merge --squash c1 &&\n+\tif test \"$c0\" != \"$(git rev-parse HEAD)\"\n+\tthen\n+\t\techo \"[OOPS] HEAD changed\"\n+\t\tfalse\n+\tfi &&\n+\tif ! cmp -s file result.1\n+\tthen\n+\t\techo \"[OOPS] merge result is wrong\"\n+\t\tfalse\n+\tfi &&\n+\tif test -f .git/MERGE_HEAD\n+\tthen\n+\t\techo \"[OOPS] MERGE_HEAD exists\"\n+\t\tfalse\n+\tfi\n+'\n+\n+test_debug 'gitk --all'\n+\n+test_expect_success 'merge c1 with c2 (squash)' '\n+\tgit reset --hard c1 &&\n+\tgit merge --squash c2 &&\n+\tif test \"$c1\" != \"$(git rev-parse HEAD)\"\n+\tthen\n+\t\techo \"[OOPS] new commit created\"\n+\t\tfalse\n+\tfi &&\n+\tif ! cmp -s file result.1-5\n+\tthen\n+\t\techo \"[OOPS] merge result is wrong\"\n+\t\tfalse\n+\tfi &&\n+\tif test -f .git/MERGE_HEAD\n+\tthen\n+\t\techo \"[OOPS] MERGE_HEAD exists\"\n+\t\tfalse\n+\tfi\n+'\n+\n+test_debug 'gitk --all'\n+\n+test_expect_success 'merge c1 with c2 and c3 (squash)' '\n+\tgit reset --hard c1 &&\n+\tgit merge --squash c2 c3 &&\n+\tif test \"$c1\" != \"$(git rev-parse HEAD)\"\n+\tthen\n+\t\techo \"[OOPS] HEAD changed\"\n+\t\tfalse\n+\tfi &&\n+\tif ! cmp -s file result.1-5-9\n+\tthen\n+\t\techo \"[OOPS] merge result is wrong\"\n+\t\tfalse\n+\tfi &&\n+\tif test -f .git/MERGE_HEAD\n+\tthen\n+\t\techo \"[OOPS] MERGE_HEAD exists\"\n+\t\tfalse\n+\tfi\n+'\n+\n+test_debug 'gitk --all'\n+\n+test_done\n-- \n1.5.3.2.82.g75c8d\n"}]}