(CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"recursive merge corner cases involving criss-cross merges">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (FuncDef name: get_clean_checkout body: (BraceGroup children: [ (AndOr children: [ (C {(git)} {(reset)} {(--hard)}) (AndOr children: [ (C {(git)} {(clean)} {(-fdqx)}) (C {(git)} {(checkout)} {(DQ ($ VSub_Number "$1"))}) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] spids: [20] ) spids: [15 19] ) (C {(test_expect_success)} {(SQ <"setup basic criss-cross + rename with no modifications">)} { (SQ <"\n"> <"\tten=\"0 1 2 3 4 5 6 7 8 9\" &&\n"> <"\tfor i in $ten\n"> <"\tdo\n"> <"\t\techo line $i in a sample file\n"> <"\tdone >one &&\n"> <"\tfor i in $ten\n"> <"\tdo\n"> <"\t\techo line $i in another sample file\n"> <"\tdone >two &&\n"> <"\tgit add one two &&\n"> <"\ttest_tick && git commit -m initial &&\n"> <"\n"> <"\tgit branch L1 &&\n"> <"\tgit checkout -b R1 &&\n"> <"\tgit mv one three &&\n"> <"\ttest_tick && git commit -m R1 &&\n"> <"\n"> <"\tgit checkout L1 &&\n"> <"\tgit mv two three &&\n"> <"\ttest_tick && git commit -m L1 &&\n"> <"\n"> <"\tgit checkout L1^0 &&\n"> <"\ttest_tick && git merge -s ours R1 &&\n"> <"\tgit tag L2 &&\n"> <"\n"> <"\tgit checkout R1^0 &&\n"> <"\ttest_tick && git merge -s ours L1 &&\n"> <"\tgit tag R2\n"> ) } ) (C {(test_expect_success)} {(SQ <"merge simple rename+criss-cross with no modifications">)} { (SQ <"\n"> <"\tgit reset --hard &&\n"> <"\tgit checkout L2^0 &&\n"> <"\n"> <"\ttest_must_fail git merge -s recursive R2^0 &&\n"> <"\n"> <"\ttest 2 = $(git ls-files -s | wc -l) &&\n"> <"\ttest 2 = $(git ls-files -u | wc -l) &&\n"> <"\ttest 2 = $(git ls-files -o | wc -l) &&\n"> <"\n"> <"\ttest $(git rev-parse :2:three) = $(git rev-parse L2:three) &&\n"> <"\ttest $(git rev-parse :3:three) = $(git rev-parse R2:three) &&\n"> <"\n"> <"\ttest $(git rev-parse L2:three) = $(git hash-object three~HEAD) &&\n"> <"\ttest $(git rev-parse R2:three) = $(git hash-object three~R2^0)\n"> ) } ) (C {(test_expect_success)} {(SQ <"setup criss-cross + rename merges with basic modification">)} { (SQ <"\n"> <"\tgit rm -rf . &&\n"> <"\tgit clean -fdqx &&\n"> <"\trm -rf .git &&\n"> <"\tgit init &&\n"> <"\n"> <"\tten=\"0 1 2 3 4 5 6 7 8 9\" &&\n"> <"\tfor i in $ten\n"> <"\tdo\n"> <"\t\techo line $i in a sample file\n"> <"\tdone >one &&\n"> <"\tfor i in $ten\n"> <"\tdo\n"> <"\t\techo line $i in another sample file\n"> <"\tdone >two &&\n"> <"\tgit add one two &&\n"> <"\ttest_tick && git commit -m initial &&\n"> <"\n"> <"\tgit branch L1 &&\n"> <"\tgit checkout -b R1 &&\n"> <"\tgit mv one three &&\n"> <"\techo more >>two &&\n"> <"\tgit add two &&\n"> <"\ttest_tick && git commit -m R1 &&\n"> <"\n"> <"\tgit checkout L1 &&\n"> <"\tgit mv two three &&\n"> <"\ttest_tick && git commit -m L1 &&\n"> <"\n"> <"\tgit checkout L1^0 &&\n"> <"\ttest_tick && git merge -s ours R1 &&\n"> <"\tgit tag L2 &&\n"> <"\n"> <"\tgit checkout R1^0 &&\n"> <"\ttest_tick && git merge -s ours L1 &&\n"> <"\tgit tag R2\n"> ) } ) (C {(test_expect_success)} {(SQ <"merge criss-cross + rename merges with basic modification">)} { (SQ <"\n"> <"\tgit reset --hard &&\n"> <"\tgit checkout L2^0 &&\n"> <"\n"> <"\ttest_must_fail git merge -s recursive R2^0 &&\n"> <"\n"> <"\ttest 2 = $(git ls-files -s | wc -l) &&\n"> <"\ttest 2 = $(git ls-files -u | wc -l) &&\n"> <"\ttest 2 = $(git ls-files -o | wc -l) &&\n"> <"\n"> <"\ttest $(git rev-parse :2:three) = $(git rev-parse L2:three) &&\n"> <"\ttest $(git rev-parse :3:three) = $(git rev-parse R2:three) &&\n"> <"\n"> <"\ttest $(git rev-parse L2:three) = $(git hash-object three~HEAD) &&\n"> <"\ttest $(git rev-parse R2:three) = $(git hash-object three~R2^0)\n"> ) } ) (C {(test_expect_success)} {(SQ <"setup differently handled merges of rename/add conflict">)} { (SQ <"\n"> <"\tgit rm -rf . &&\n"> <"\tgit clean -fdqx &&\n"> <"\trm -rf .git &&\n"> <"\tgit init &&\n"> <"\n"> <"\tprintf \"0\\n1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n\" >a &&\n"> <"\tgit add a &&\n"> <"\ttest_tick && git commit -m A &&\n"> <"\n"> <"\tgit branch B &&\n"> <"\tgit checkout -b C &&\n"> <"\techo 10 >>a &&\n"> <"\techo \"other content\" >>new_a &&\n"> <"\tgit add a new_a &&\n"> <"\ttest_tick && git commit -m C &&\n"> <"\n"> <"\tgit checkout B &&\n"> <"\tgit mv a new_a &&\n"> <"\ttest_tick && git commit -m B &&\n"> <"\n"> <"\tgit checkout B^0 &&\n"> <"\ttest_must_fail git merge C &&\n"> <"\tgit clean -f &&\n"> <"\ttest_tick && git commit -m D &&\n"> <"\tgit tag D &&\n"> <"\n"> <"\tgit checkout C^0 &&\n"> <"\ttest_must_fail git merge B &&\n"> <"\trm new_a~HEAD new_a &&\n"> <"\tprintf \"Incorrectly merged content\" >>new_a &&\n"> <"\tgit add -u &&\n"> <"\ttest_tick && git commit -m E &&\n"> <"\tgit tag E\n"> ) } ) (C {(test_expect_success)} {(SQ <"git detects differently handled merges conflict">)} { (SQ <"\n"> <"\tgit reset --hard &&\n"> <"\tgit checkout D^0 &&\n"> <"\n"> <"\ttest_must_fail git merge -s recursive E^0 &&\n"> <"\n"> <"\ttest 3 = $(git ls-files -s | wc -l) &&\n"> <"\ttest 3 = $(git ls-files -u | wc -l) &&\n"> <"\ttest 0 = $(git ls-files -o | wc -l) &&\n"> <"\n"> <"\ttest $(git rev-parse :2:new_a) = $(git rev-parse D:new_a) &&\n"> <"\ttest $(git rev-parse :3:new_a) = $(git rev-parse E:new_a) &&\n"> <"\n"> <"\tgit cat-file -p B:new_a >>merged &&\n"> <"\tgit cat-file -p C:new_a >>merge-me &&\n"> <"\t>empty &&\n"> <"\ttest_must_fail git merge-file \\\n"> <"\t\t-L \"Temporary merge branch 2\" \\\n"> <"\t\t-L \"\" \\\n"> <"\t\t-L \"Temporary merge branch 1\" \\\n"> <"\t\tmerged empty merge-me &&\n"> <"\tsed -e \"s/^\\([<=>]\\)/\\1\\1\\1/\" merged >merged-internal &&\n"> <"\ttest $(git rev-parse :1:new_a) = $(git hash-object merged-internal)\n"> ) } ) (C {(test_expect_success)} {(SQ <"setup criss-cross + modify/delete resolved differently">)} { (SQ <"\n"> <"\tgit rm -rf . &&\n"> <"\tgit clean -fdqx &&\n"> <"\trm -rf .git &&\n"> <"\tgit init &&\n"> <"\n"> <"\techo A >file &&\n"> <"\tgit add file &&\n"> <"\ttest_tick &&\n"> <"\tgit commit -m A &&\n"> <"\n"> <"\tgit branch B &&\n"> <"\tgit checkout -b C &&\n"> <"\tgit rm file &&\n"> <"\ttest_tick &&\n"> <"\tgit commit -m C &&\n"> <"\n"> <"\tgit checkout B &&\n"> <"\techo B >file &&\n"> <"\tgit add file &&\n"> <"\ttest_tick &&\n"> <"\tgit commit -m B &&\n"> <"\n"> <"\tgit checkout B^0 &&\n"> <"\ttest_must_fail git merge C &&\n"> <"\techo B >file &&\n"> <"\tgit add file &&\n"> <"\ttest_tick &&\n"> <"\tgit commit -m D &&\n"> <"\tgit tag D &&\n"> <"\n"> <"\tgit checkout C^0 &&\n"> <"\ttest_must_fail git merge B &&\n"> <"\tgit rm file &&\n"> <"\ttest_tick &&\n"> <"\tgit commit -m E &&\n"> <"\tgit tag E\n"> ) } ) (C {(test_expect_success)} {(SQ <"git detects conflict merging criss-cross+modify/delete">)} { (SQ <"\n"> <"\tgit checkout D^0 &&\n"> <"\n"> <"\ttest_must_fail git merge -s recursive E^0 &&\n"> <"\n"> <"\ttest 2 -eq $(git ls-files -s | wc -l) &&\n"> <"\ttest 2 -eq $(git ls-files -u | wc -l) &&\n"> <"\n"> <"\ttest $(git rev-parse :1:file) = $(git rev-parse master:file) &&\n"> <"\ttest $(git rev-parse :2:file) = $(git rev-parse B:file)\n"> ) } ) (C {(test_expect_success)} {(SQ <"git detects conflict merging criss-cross+modify/delete, reverse direction">)} { (SQ <"\n"> <"\tgit reset --hard &&\n"> <"\tgit checkout E^0 &&\n"> <"\n"> <"\ttest_must_fail git merge -s recursive D^0 &&\n"> <"\n"> <"\ttest 2 -eq $(git ls-files -s | wc -l) &&\n"> <"\ttest 2 -eq $(git ls-files -u | wc -l) &&\n"> <"\n"> <"\ttest $(git rev-parse :1:file) = $(git rev-parse master:file) &&\n"> <"\ttest $(git rev-parse :3:file) = $(git rev-parse B:file)\n"> ) } ) (C {(test_expect_success)} {(SQ <"setup differently handled merges of directory/file conflict">)} { (SQ <"\n"> <"\tgit rm -rf . &&\n"> <"\tgit clean -fdqx &&\n"> <"\trm -rf .git &&\n"> <"\tgit init &&\n"> <"\n"> <"\t>ignore-me &&\n"> <"\tgit add ignore-me &&\n"> <"\ttest_tick &&\n"> <"\tgit commit -m A &&\n"> <"\tgit tag A &&\n"> <"\n"> <"\tgit branch B &&\n"> <"\tgit checkout -b C &&\n"> <"\tmkdir a &&\n"> <"\techo 10 >a/file &&\n"> <"\tgit add a/file &&\n"> <"\ttest_tick &&\n"> <"\tgit commit -m C &&\n"> <"\n"> <"\tgit checkout B &&\n"> <"\techo 5 >a &&\n"> <"\tgit add a &&\n"> <"\ttest_tick &&\n"> <"\tgit commit -m B &&\n"> <"\n"> <"\tgit checkout B^0 &&\n"> <"\ttest_must_fail git merge C &&\n"> <"\tgit clean -f &&\n"> <"\trm -rf a/ &&\n"> <"\techo 5 >a &&\n"> <"\tgit add a &&\n"> <"\ttest_tick &&\n"> <"\tgit commit -m D &&\n"> <"\tgit tag D &&\n"> <"\n"> <"\tgit checkout C^0 &&\n"> <"\ttest_must_fail git merge B &&\n"> <"\tgit clean -f &&\n"> <"\tgit rm --cached a &&\n"> <"\techo 10 >a/file &&\n"> <"\tgit add a/file &&\n"> <"\ttest_tick &&\n"> <"\tgit commit -m E1 &&\n"> <"\tgit tag E1 &&\n"> <"\n"> <"\tgit checkout C^0 &&\n"> <"\ttest_must_fail git merge B &&\n"> <"\tgit clean -f &&\n"> <"\tgit rm --cached a &&\n"> <"\tprintf \"10\\n11\\n\" >a/file &&\n"> <"\tgit add a/file &&\n"> <"\ttest_tick &&\n"> <"\tgit commit -m E2 &&\n"> <"\tgit tag E2\n"> ) } ) (C {(test_expect_success)} {(SQ <"merge of D & E1 fails but has appropriate contents">)} { (SQ <"\n"> <"\tget_clean_checkout D^0 &&\n"> <"\n"> <"\ttest_must_fail git merge -s recursive E1^0 &&\n"> <"\n"> <"\ttest 2 -eq $(git ls-files -s | wc -l) &&\n"> <"\ttest 1 -eq $(git ls-files -u | wc -l) &&\n"> <"\ttest 0 -eq $(git ls-files -o | wc -l) &&\n"> <"\n"> <"\ttest $(git rev-parse :0:ignore-me) = $(git rev-parse A:ignore-me) &&\n"> <"\ttest $(git rev-parse :2:a) = $(git rev-parse B:a)\n"> ) } ) (C {(test_expect_success)} {(SQ <"merge of E1 & D fails but has appropriate contents">)} { (SQ <"\n"> <"\tget_clean_checkout E1^0 &&\n"> <"\n"> <"\ttest_must_fail git merge -s recursive D^0 &&\n"> <"\n"> <"\ttest 2 -eq $(git ls-files -s | wc -l) &&\n"> <"\ttest 1 -eq $(git ls-files -u | wc -l) &&\n"> <"\ttest 0 -eq $(git ls-files -o | wc -l) &&\n"> <"\n"> <"\ttest $(git rev-parse :0:ignore-me) = $(git rev-parse A:ignore-me) &&\n"> <"\ttest $(git rev-parse :3:a) = $(git rev-parse B:a)\n"> ) } ) (C {(test_expect_success)} {(SQ <"merge of D & E2 fails but has appropriate contents">)} { (SQ <"\n"> <"\tget_clean_checkout D^0 &&\n"> <"\n"> <"\ttest_must_fail git merge -s recursive E2^0 &&\n"> <"\n"> <"\ttest 4 -eq $(git ls-files -s | wc -l) &&\n"> <"\ttest 3 -eq $(git ls-files -u | wc -l) &&\n"> <"\ttest 1 -eq $(git ls-files -o | wc -l) &&\n"> <"\n"> <"\ttest $(git rev-parse :2:a) = $(git rev-parse B:a) &&\n"> <"\ttest $(git rev-parse :3:a/file) = $(git rev-parse E2:a/file) &&\n"> <"\ttest $(git rev-parse :1:a/file) = $(git rev-parse C:a/file) &&\n"> <"\ttest $(git rev-parse :0:ignore-me) = $(git rev-parse A:ignore-me) &&\n"> <"\n"> <"\ttest -f a~HEAD\n"> ) } ) (C {(test_expect_success)} {(SQ <"merge of E2 & D fails but has appropriate contents">)} { (SQ <"\n"> <"\tget_clean_checkout E2^0 &&\n"> <"\n"> <"\ttest_must_fail git merge -s recursive D^0 &&\n"> <"\n"> <"\ttest 4 -eq $(git ls-files -s | wc -l) &&\n"> <"\ttest 3 -eq $(git ls-files -u | wc -l) &&\n"> <"\ttest 1 -eq $(git ls-files -o | wc -l) &&\n"> <"\n"> <"\ttest $(git rev-parse :3:a) = $(git rev-parse B:a) &&\n"> <"\ttest $(git rev-parse :2:a/file) = $(git rev-parse E2:a/file) &&\n"> <"\ttest $(git rev-parse :1:a/file) = $(git rev-parse C:a/file) &&\n"> <"\ttest $(git rev-parse :0:ignore-me) = $(git rev-parse A:ignore-me) &&\n"> <"\n"> <"\ttest -f a~D^0\n"> ) } ) (C {(test_expect_success)} { (SQ < "setup rename/rename(1to2)/modify followed by what looks like rename/rename(2to1)/modify" > ) } { (SQ <"\n"> <"\tgit reset --hard &&\n"> <"\tgit rm -rf . &&\n"> <"\tgit clean -fdqx &&\n"> <"\trm -rf .git &&\n"> <"\tgit init &&\n"> <"\n"> <"\tprintf \"1\\n2\\n3\\n4\\n5\\n6\\n\" >a &&\n"> <"\tgit add a &&\n"> <"\tgit commit -m A &&\n"> <"\tgit tag A &&\n"> <"\n"> <"\tgit checkout -b B A &&\n"> <"\tgit mv a b &&\n"> <"\techo 7 >>b &&\n"> <"\tgit add -u &&\n"> <"\tgit commit -m B &&\n"> <"\n"> <"\tgit checkout -b C A &&\n"> <"\tgit mv a c &&\n"> <"\tgit commit -m C &&\n"> <"\n"> <"\tgit checkout -q B^0 &&\n"> <"\tgit merge --no-commit -s ours C^0 &&\n"> <"\tgit mv b newname &&\n"> <"\tgit commit -m \"Merge commit C^0 into HEAD\" &&\n"> <"\tgit tag D &&\n"> <"\n"> <"\tgit checkout -q C^0 &&\n"> <"\tgit merge --no-commit -s ours B^0 &&\n"> <"\tgit mv c newname &&\n"> <"\tprintf \"7\\n8\\n\" >>newname &&\n"> <"\tgit add -u &&\n"> <"\tgit commit -m \"Merge commit B^0 into HEAD\" &&\n"> <"\tgit tag E\n"> ) } ) (C {(test_expect_success)} { (SQ < "handle rename/rename(1to2)/modify followed by what looks like rename/rename(2to1)/modify" > ) } { (SQ <"\n"> <"\tgit checkout D^0 &&\n"> <"\n"> <"\tgit merge -s recursive E^0 &&\n"> <"\n"> <"\ttest 1 -eq $(git ls-files -s | wc -l) &&\n"> <"\ttest 0 -eq $(git ls-files -u | wc -l) &&\n"> <"\ttest 0 -eq $(git ls-files -o | wc -l) &&\n"> <"\n"> <"\ttest $(git rev-parse HEAD:newname) = $(git rev-parse E:newname)\n"> ) } ) (C {(test_expect_success)} {(SQ <"setup criss-cross + rename/rename/add + modify/modify">)} { (SQ <"\n"> <"\tgit rm -rf . &&\n"> <"\tgit clean -fdqx &&\n"> <"\trm -rf .git &&\n"> <"\tgit init &&\n"> <"\n"> <"\tprintf \"lots\\nof\\nwords\\nand\\ncontent\\n\" >a &&\n"> <"\tgit add a &&\n"> <"\tgit commit -m A &&\n"> <"\tgit tag A &&\n"> <"\n"> <"\tgit checkout -b B A &&\n"> <"\tgit mv a b &&\n"> <"\tgit commit -m B &&\n"> <"\n"> <"\tgit checkout -b C A &&\n"> <"\tgit mv a c &&\n"> <"\tprintf \"2\\n3\\n4\\n5\\n6\\n7\\n\" >a &&\n"> <"\tgit add a &&\n"> <"\tgit commit -m C &&\n"> <"\n"> <"\tgit checkout B^0 &&\n"> <"\tgit merge --no-commit -s ours C^0 &&\n"> <"\tgit checkout C -- a c &&\n"> <"\tmv a old_a &&\n"> <"\techo 1 >a &&\n"> <"\tcat old_a >>a &&\n"> <"\trm old_a &&\n"> <"\tgit add -u &&\n"> <"\tgit commit -m \"Merge commit C^0 into HEAD\" &&\n"> <"\tgit tag D &&\n"> <"\n"> <"\tgit checkout C^0 &&\n"> <"\tgit merge --no-commit -s ours B^0 &&\n"> <"\tgit checkout B -- b &&\n"> <"\techo 8 >>a &&\n"> <"\tgit add -u &&\n"> <"\tgit commit -m \"Merge commit B^0 into HEAD\" &&\n"> <"\tgit tag E\n"> ) } ) (C {(test_expect_failure)} {(SQ <"detect rename/rename/add-source for virtual merge-base">)} { (SQ <"\n"> <"\tgit checkout D^0 &&\n"> <"\n"> <"\tgit merge -s recursive E^0 &&\n"> <"\n"> <"\ttest 3 -eq $(git ls-files -s | wc -l) &&\n"> <"\ttest 0 -eq $(git ls-files -u | wc -l) &&\n"> <"\ttest 0 -eq $(git ls-files -o | wc -l) &&\n"> <"\n"> <"\ttest $(git rev-parse HEAD:b) = $(git rev-parse A:a) &&\n"> <"\ttest $(git rev-parse HEAD:c) = $(git rev-parse A:a) &&\n"> <"\ttest \"$(cat a)\" = \"$(printf \"1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n\")\"\n"> ) } ) (C {(test_expect_success)} {(SQ <"setup criss-cross+rename/rename/add-dest + simple modify">)} { (SQ <"\n"> <"\tgit rm -rf . &&\n"> <"\tgit clean -fdqx &&\n"> <"\trm -rf .git &&\n"> <"\tgit init &&\n"> <"\n"> <"\t>a &&\n"> <"\tgit add a &&\n"> <"\tgit commit -m A &&\n"> <"\tgit tag A &&\n"> <"\n"> <"\tgit checkout -b B A &&\n"> <"\tgit mv a b &&\n"> <"\tprintf \"1\\n2\\n3\\n4\\n5\\n6\\n7\\n\" >c &&\n"> <"\tgit add c &&\n"> <"\tgit commit -m B &&\n"> <"\n"> <"\tgit checkout -b C A &&\n"> <"\tgit mv a c &&\n"> <"\tgit commit -m C &&\n"> <"\n"> <"\tgit checkout B^0 &&\n"> <"\tgit merge --no-commit -s ours C^0 &&\n"> <"\tgit mv b a &&\n"> <"\tgit commit -m \"D is like B but renames b back to a\" &&\n"> <"\tgit tag D &&\n"> <"\n"> <"\tgit checkout B^0 &&\n"> <"\tgit merge --no-commit -s ours C^0 &&\n"> <"\tgit mv b a &&\n"> <"\techo 8 >>c &&\n"> <"\tgit add c &&\n"> <"\tgit commit -m \"E like D but has mod in c\" &&\n"> <"\tgit tag E\n"> ) } ) (C {(test_expect_success)} {(SQ <"virtual merge base handles rename/rename(1to2)/add-dest">)} { (SQ <"\n"> <"\tgit checkout D^0 &&\n"> <"\n"> <"\tgit merge -s recursive E^0 &&\n"> <"\n"> <"\ttest 2 -eq $(git ls-files -s | wc -l) &&\n"> <"\ttest 0 -eq $(git ls-files -u | wc -l) &&\n"> <"\ttest 0 -eq $(git ls-files -o | wc -l) &&\n"> <"\n"> <"\ttest $(git rev-parse HEAD:a) = $(git rev-parse A:a) &&\n"> <"\ttest $(git rev-parse HEAD:c) = $(git rev-parse E:c)\n"> ) } ) (C {(test_done)}) ] )