#!/bin/sh global test_description := ''git merge Testing the resolve strategy.'' source ./test-lib.sh test_expect_success 'setup' ' echo c0 > c0.c && git add c0.c && git commit -m c0 && git tag c0 && echo c1 > c1.c && git add c1.c && git commit -m c1 && git tag c1 && git reset --hard c0 && echo c2 > c2.c && git add c2.c && git commit -m c2 && git tag c2 && git reset --hard c0 && echo c3 > c2.c && git add c2.c && git commit -m c3 && git tag c3 ' global merge_c1_to_c2_cmds := '' git reset --hard c1 && git merge -s resolve c2 && test "$(git rev-parse c1)" != "$(git rev-parse HEAD)" && test "$(git rev-parse c1)" = "$(git rev-parse HEAD^1)" && test "$(git rev-parse c2)" = "$(git rev-parse HEAD^2)" && git diff --exit-code && test -f c0.c && test -f c1.c && test -f c2.c && test 3 = $(git ls-tree -r HEAD | wc -l) && test 3 = $(git ls-files | wc -l) '' test_expect_success 'merge c1 to c2' $merge_c1_to_c2_cmds test_expect_success 'merge c1 to c2, again' $merge_c1_to_c2_cmds test_expect_success 'merge c2 to c3 (fails)' ' git reset --hard c2 && test_must_fail git merge -s resolve c3 ' test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"git merge\n"> <"\n"> <"Testing the resolve strategy.">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (C {(test_expect_success)} {(SQ )} { (SQ <"\n"> <"\techo c0 > c0.c &&\n"> <"\tgit add c0.c &&\n"> <"\tgit commit -m c0 &&\n"> <"\tgit tag c0 &&\n"> <"\techo c1 > c1.c &&\n"> <"\tgit add c1.c &&\n"> <"\tgit commit -m c1 &&\n"> <"\tgit tag c1 &&\n"> <"\tgit reset --hard c0 &&\n"> <"\techo c2 > c2.c &&\n"> <"\tgit add c2.c &&\n"> <"\tgit commit -m c2 &&\n"> <"\tgit tag c2 &&\n"> <"\tgit reset --hard c0 &&\n"> <"\techo c3 > c2.c &&\n"> <"\tgit add c2.c &&\n"> <"\tgit commit -m c3 &&\n"> <"\tgit tag c3\n"> ) } ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:merge_c1_to_c2_cmds) op: Equal rhs: { (SQ <"\n"> <"\tgit reset --hard c1 &&\n"> <"\tgit merge -s resolve c2 &&\n"> <"\ttest \"$(git rev-parse c1)\" != \"$(git rev-parse HEAD)\" &&\n"> <"\ttest \"$(git rev-parse c1)\" = \"$(git rev-parse HEAD^1)\" &&\n"> <"\ttest \"$(git rev-parse c2)\" = \"$(git rev-parse HEAD^2)\" &&\n"> <"\tgit diff --exit-code &&\n"> <"\ttest -f c0.c &&\n"> <"\ttest -f c1.c &&\n"> <"\ttest -f c2.c &&\n"> <"\ttest 3 = $(git ls-tree -r HEAD | wc -l) &&\n"> <"\ttest 3 = $(git ls-files | wc -l)\n"> ) } spids: [46] ) ] spids: [46] ) (C {(test_expect_success)} {(SQ <"merge c1 to c2">)} {(DQ ($ VSub_Name "$merge_c1_to_c2_cmds"))}) (C {(test_expect_success)} {(SQ <"merge c1 to c2, again">)} {(DQ ($ VSub_Name "$merge_c1_to_c2_cmds"))} ) (C {(test_expect_success)} {(SQ <"merge c2 to c3 (fails)">)} {(SQ <"\n"> <"\tgit reset --hard c2 &&\n"> <"\ttest_must_fail git merge -s resolve c3\n">)} ) (C {(test_done)}) ] )