(CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <'git apply --3way'>)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (FuncDef name: create_file body: (BraceGroup children: [ (ForEach iter_name: i do_arg_iter: True body: (DoGroup children:[(C {(echo)} {(DQ ($ VSub_Name '$i'))})] spids:[2838]) spids: [-1 -1] ) ] spids: [20] ) spids: [15 19] ) (FuncDef name: sanitize_conflicted_diff body: (BraceGroup children: [ (C {(sed)} {(-e)} {(SQ <'\n'> <'\t\t/^index /d\n'> <'\t\ts/^\\(+[<>][<>][<>][<>]*\\) .*/\\1/\n'> <'\t'>)} ) ] spids: [48] ) spids: [43 47] ) (C {(test_expect_success)} {(setup)} { (SQ <'\n'> <'\ttest_tick &&\n'> <'\tcreate_file >one 1 2 3 4 5 6 7 &&\n'> <'\tcat one >two &&\n'> <'\tgit add one two &&\n'> <'\tgit commit -m initial &&\n'> <'\n'> <'\tgit branch side &&\n'> <'\n'> <'\ttest_tick &&\n'> <'\tcreate_file >one 1 two 3 4 5 six 7 &&\n'> <'\tcreate_file >two 1 two 3 4 5 6 7 &&\n'> <'\tgit commit -a -m master &&\n'> <'\n'> <'\tgit checkout side &&\n'> <'\tcreate_file >one 1 2 3 4 five 6 7 &&\n'> <'\tcreate_file >two 1 2 3 4 five 6 7 &&\n'> <'\tgit commit -a -m side &&\n'> <'\n'> <'\tgit checkout master\n'> ) } ) (C {(test_expect_success)} {(SQ <'apply without --3way'>)} { (SQ <'\n'> <'\tgit diff side^ side >P.diff &&\n'> <'\n'> <'\t# should fail to apply\n'> <'\tgit reset --hard &&\n'> <'\tgit checkout master^0 &&\n'> <'\ttest_must_fail git apply --index P.diff &&\n'> <'\t# should leave things intact\n'> <'\tgit diff-files --exit-code &&\n'> <'\tgit diff-index --exit-code --cached HEAD\n'> ) } ) (C {(test_expect_success)} {(SQ <'apply with --3way'>)} { (SQ <'\n'> <'\t# Merging side should be similar to applying this patch\n'> <'\tgit diff ...side >P.diff &&\n'> <'\n'> <'\t# The corresponding conflicted merge\n'> <'\tgit reset --hard &&\n'> <'\tgit checkout master^0 &&\n'> <'\ttest_must_fail git merge --no-commit side &&\n'> <'\tgit ls-files -s >expect.ls &&\n'> <'\tgit diff HEAD | sanitize_conflicted_diff >expect.diff &&\n'> <'\n'> <'\t# should fail to apply\n'> <'\tgit reset --hard &&\n'> <'\tgit checkout master^0 &&\n'> <'\ttest_must_fail git apply --index --3way P.diff &&\n'> <'\tgit ls-files -s >actual.ls &&\n'> <'\tgit diff HEAD | sanitize_conflicted_diff >actual.diff &&\n'> <'\n'> <'\t# The result should resemble the corresponding merge\n'> <'\ttest_cmp expect.ls actual.ls &&\n'> <'\ttest_cmp expect.diff actual.diff\n'> ) } ) (C {(test_expect_success)} {(SQ <'apply with --3way with rerere enabled'>)} { (SQ <'\n'> <'\tgit config rerere.enabled true &&\n'> <'\n'> <'\t# Merging side should be similar to applying this patch\n'> <'\tgit diff ...side >P.diff &&\n'> <'\n'> <'\t# The corresponding conflicted merge\n'> <'\tgit reset --hard &&\n'> <'\tgit checkout master^0 &&\n'> <'\ttest_must_fail git merge --no-commit side &&\n'> <'\n'> <'\t# Manually resolve and record the resolution\n'> <'\tcreate_file 1 two 3 4 five six 7 >one &&\n'> <'\tgit rerere &&\n'> <'\tcat one >expect &&\n'> <'\n'> <'\t# should fail to apply\n'> <'\tgit reset --hard &&\n'> <'\tgit checkout master^0 &&\n'> <'\ttest_must_fail git apply --index --3way P.diff &&\n'> <'\n'> <'\t# but rerere should have replayed the recorded resolution\n'> <'\ttest_cmp expect one\n'> ) } ) (C {(test_expect_success)} {(SQ <'apply -3 with add/add conflict setup'>)} { (SQ <'\n'> <'\tgit reset --hard &&\n'> <'\n'> <'\tgit checkout -b adder &&\n'> <'\tcreate_file 1 2 3 4 5 6 7 >three &&\n'> <'\tcreate_file 1 2 3 4 5 6 7 >four &&\n'> <'\tgit add three four &&\n'> <'\tgit commit -m "add three and four" &&\n'> <'\n'> <'\tgit checkout -b another adder^ &&\n'> <'\tcreate_file 1 2 3 4 5 6 7 >three &&\n'> <'\tcreate_file 1 2 3 four 5 6 7 >four &&\n'> <'\tgit add three four &&\n'> <'\tgit commit -m "add three and four" &&\n'> <'\n'> <'\t# Merging another should be similar to applying this patch\n'> <'\tgit diff adder...another >P.diff &&\n'> <'\n'> <'\tgit checkout adder^0 &&\n'> <'\ttest_must_fail git merge --no-commit another &&\n'> <'\tgit ls-files -s >expect.ls &&\n'> <'\tgit diff HEAD | sanitize_conflicted_diff >expect.diff\n'> ) } ) (C {(test_expect_success)} {(SQ <'apply -3 with add/add conflict'>)} { (SQ <'\n'> <'\t# should fail to apply ...\n'> <'\tgit reset --hard &&\n'> <'\tgit checkout adder^0 &&\n'> <'\ttest_must_fail git apply --index --3way P.diff &&\n'> <'\t# ... and leave conflicts in the index and in the working tree\n'> <'\tgit ls-files -s >actual.ls &&\n'> <'\tgit diff HEAD | sanitize_conflicted_diff >actual.diff &&\n'> <'\n'> <'\t# The result should resemble the corresponding merge\n'> <'\ttest_cmp expect.ls actual.ls &&\n'> <'\ttest_cmp expect.diff actual.diff\n'> ) } ) (C {(test_expect_success)} {(SQ <'apply -3 with add/add conflict (dirty working tree)'>)} { (SQ <'\n'> <'\t# should fail to apply ...\n'> <'\tgit reset --hard &&\n'> <'\tgit checkout adder^0 &&\n'> <'\techo >>four &&\n'> <'\tcat four >four.save &&\n'> <'\tcat three >three.save &&\n'> <'\tgit ls-files -s >expect.ls &&\n'> <'\ttest_must_fail git apply --index --3way P.diff &&\n'> <'\t# ... and should not touch anything\n'> <'\tgit ls-files -s >actual.ls &&\n'> <'\ttest_cmp expect.ls actual.ls &&\n'> <'\ttest_cmp four.save four &&\n'> <'\ttest_cmp three.save three\n'> ) } ) (C {(test_done)}) ] )