(command.CommandList children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:test_description) op: assign_op.Equal rhs: {(SQ (Token id:Id.Lit_Chars val:'git apply --3way' span_id:6))} spids: [4] ) ] ) (C {(.)} {(./test-lib.sh)}) (command.ShFunction name: create_file body: (command.BraceGroup children: [ (command.ForEach iter_name: i do_arg_iter: T body: (command.DoGroup children:[(C {(echo)} {(DQ ($ Id.VSub_DollarName '$i'))})]) ) ] ) ) (command.ShFunction name: sanitize_conflicted_diff body: (command.BraceGroup children: [ (C {(sed)} {(-e)} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:56) (Token id:Id.Lit_Chars val:'\t\t/^index /d\n' span_id:57) (Token id:Id.Lit_Chars val:'\t\ts/^\\(+[<>][<>][<>][<>]*\\) .*/\\1/\n' span_id:58) (Token id:Id.Lit_Chars val:'\t' span_id:59) ) } ) ] ) ) (C {(test_expect_success)} {(setup)} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:70) (Token id:Id.Lit_Chars val:'\ttest_tick &&\n' span_id:71) (Token id:Id.Lit_Chars val:'\tcreate_file >one 1 2 3 4 5 6 7 &&\n' span_id:72) (Token id:Id.Lit_Chars val:'\tcat one >two &&\n' span_id:73) (Token id:Id.Lit_Chars val:'\tgit add one two &&\n' span_id:74) (Token id:Id.Lit_Chars val:'\tgit commit -m initial &&\n' span_id:75) (Token id:Id.Lit_Chars val:'\n' span_id:76) (Token id:Id.Lit_Chars val:'\tgit branch side &&\n' span_id:77) (Token id:Id.Lit_Chars val:'\n' span_id:78) (Token id:Id.Lit_Chars val:'\ttest_tick &&\n' span_id:79) (Token id: Id.Lit_Chars val: '\tcreate_file >one 1 two 3 4 5 six 7 &&\n' span_id: 80 ) (Token id:Id.Lit_Chars val:'\tcreate_file >two 1 two 3 4 5 6 7 &&\n' span_id:81) (Token id:Id.Lit_Chars val:'\tgit commit -a -m master &&\n' span_id:82) (Token id:Id.Lit_Chars val:'\n' span_id:83) (Token id:Id.Lit_Chars val:'\tgit checkout side &&\n' span_id:84) (Token id:Id.Lit_Chars val:'\tcreate_file >one 1 2 3 4 five 6 7 &&\n' span_id:85) (Token id:Id.Lit_Chars val:'\tcreate_file >two 1 2 3 4 five 6 7 &&\n' span_id:86) (Token id:Id.Lit_Chars val:'\tgit commit -a -m side &&\n' span_id:87) (Token id:Id.Lit_Chars val:'\n' span_id:88) (Token id:Id.Lit_Chars val:'\tgit checkout master\n' span_id:89) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'apply without --3way' span_id:96))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:100) (Token id:Id.Lit_Chars val:'\tgit diff side^ side >P.diff &&\n' span_id:101) (Token id:Id.Lit_Chars val:'\n' span_id:102) (Token id:Id.Lit_Chars val:'\t# should fail to apply\n' span_id:103) (Token id:Id.Lit_Chars val:'\tgit reset --hard &&\n' span_id:104) (Token id:Id.Lit_Chars val:'\tgit checkout master^0 &&\n' span_id:105) (Token id:Id.Lit_Chars val:'\ttest_must_fail git apply --index P.diff &&\n' span_id:106) (Token id:Id.Lit_Chars val:'\t# should leave things intact\n' span_id:107) (Token id:Id.Lit_Chars val:'\tgit diff-files --exit-code &&\n' span_id:108) (Token id: Id.Lit_Chars val: '\tgit diff-index --exit-code --cached HEAD\n' span_id: 109 ) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'apply with --3way' span_id:116))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:120) (Token id: Id.Lit_Chars val: '\t# Merging side should be similar to applying this patch\n' span_id: 121 ) (Token id:Id.Lit_Chars val:'\tgit diff ...side >P.diff &&\n' span_id:122) (Token id:Id.Lit_Chars val:'\n' span_id:123) (Token id:Id.Lit_Chars val:'\t# The corresponding conflicted merge\n' span_id:124) (Token id:Id.Lit_Chars val:'\tgit reset --hard &&\n' span_id:125) (Token id:Id.Lit_Chars val:'\tgit checkout master^0 &&\n' span_id:126) (Token id: Id.Lit_Chars val: '\ttest_must_fail git merge --no-commit side &&\n' span_id: 127 ) (Token id:Id.Lit_Chars val:'\tgit ls-files -s >expect.ls &&\n' span_id:128) (Token id: Id.Lit_Chars val: '\tgit diff HEAD | sanitize_conflicted_diff >expect.diff &&\n' span_id: 129 ) (Token id:Id.Lit_Chars val:'\n' span_id:130) (Token id:Id.Lit_Chars val:'\t# should fail to apply\n' span_id:131) (Token id:Id.Lit_Chars val:'\tgit reset --hard &&\n' span_id:132) (Token id:Id.Lit_Chars val:'\tgit checkout master^0 &&\n' span_id:133) (Token id:Id.Lit_Chars val:'\ttest_must_fail git apply --index --3way P.diff &&\n' span_id:134) (Token id:Id.Lit_Chars val:'\tgit ls-files -s >actual.ls &&\n' span_id:135) (Token id: Id.Lit_Chars val: '\tgit diff HEAD | sanitize_conflicted_diff >actual.diff &&\n' span_id: 136 ) (Token id:Id.Lit_Chars val:'\n' span_id:137) (Token id: Id.Lit_Chars val: '\t# The result should resemble the corresponding merge\n' span_id: 138 ) (Token id:Id.Lit_Chars val:'\ttest_cmp expect.ls actual.ls &&\n' span_id:139) (Token id:Id.Lit_Chars val:'\ttest_cmp expect.diff actual.diff\n' span_id:140) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'apply with --3way with rerere enabled' span_id:147))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:151) (Token id:Id.Lit_Chars val:'\tgit config rerere.enabled true &&\n' span_id:152) (Token id:Id.Lit_Chars val:'\n' span_id:153) (Token id: Id.Lit_Chars val: '\t# Merging side should be similar to applying this patch\n' span_id: 154 ) (Token id:Id.Lit_Chars val:'\tgit diff ...side >P.diff &&\n' span_id:155) (Token id:Id.Lit_Chars val:'\n' span_id:156) (Token id:Id.Lit_Chars val:'\t# The corresponding conflicted merge\n' span_id:157) (Token id:Id.Lit_Chars val:'\tgit reset --hard &&\n' span_id:158) (Token id:Id.Lit_Chars val:'\tgit checkout master^0 &&\n' span_id:159) (Token id: Id.Lit_Chars val: '\ttest_must_fail git merge --no-commit side &&\n' span_id: 160 ) (Token id:Id.Lit_Chars val:'\n' span_id:161) (Token id: Id.Lit_Chars val: '\t# Manually resolve and record the resolution\n' span_id: 162 ) (Token id:Id.Lit_Chars val:'\tcreate_file 1 two 3 4 five six 7 >one &&\n' span_id:163) (Token id:Id.Lit_Chars val:'\tgit rerere &&\n' span_id:164) (Token id:Id.Lit_Chars val:'\tcat one >expect &&\n' span_id:165) (Token id:Id.Lit_Chars val:'\n' span_id:166) (Token id:Id.Lit_Chars val:'\t# should fail to apply\n' span_id:167) (Token id:Id.Lit_Chars val:'\tgit reset --hard &&\n' span_id:168) (Token id:Id.Lit_Chars val:'\tgit checkout master^0 &&\n' span_id:169) (Token id: Id.Lit_Chars val: '\ttest_must_fail git apply --index --3way P.diff &&\n' span_id: 170 ) (Token id:Id.Lit_Chars val:'\n' span_id:171) (Token id: Id.Lit_Chars val: '\t# but rerere should have replayed the recorded resolution\n' span_id: 172 ) (Token id:Id.Lit_Chars val:'\ttest_cmp expect one\n' span_id:173) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'apply -3 with add/add conflict setup' span_id:180))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:184) (Token id:Id.Lit_Chars val:'\tgit reset --hard &&\n' span_id:185) (Token id:Id.Lit_Chars val:'\n' span_id:186) (Token id:Id.Lit_Chars val:'\tgit checkout -b adder &&\n' span_id:187) (Token id:Id.Lit_Chars val:'\tcreate_file 1 2 3 4 5 6 7 >three &&\n' span_id:188) (Token id:Id.Lit_Chars val:'\tcreate_file 1 2 3 4 5 6 7 >four &&\n' span_id:189) (Token id:Id.Lit_Chars val:'\tgit add three four &&\n' span_id:190) (Token id: Id.Lit_Chars val: '\tgit commit -m "add three and four" &&\n' span_id: 191 ) (Token id:Id.Lit_Chars val:'\n' span_id:192) (Token id:Id.Lit_Chars val:'\tgit checkout -b another adder^ &&\n' span_id:193) (Token id:Id.Lit_Chars val:'\tcreate_file 1 2 3 4 5 6 7 >three &&\n' span_id:194) (Token id: Id.Lit_Chars val: '\tcreate_file 1 2 3 four 5 6 7 >four &&\n' span_id: 195 ) (Token id:Id.Lit_Chars val:'\tgit add three four &&\n' span_id:196) (Token id: Id.Lit_Chars val: '\tgit commit -m "add three and four" &&\n' span_id: 197 ) (Token id:Id.Lit_Chars val:'\n' span_id:198) (Token id: Id.Lit_Chars val: '\t# Merging another should be similar to applying this patch\n' span_id: 199 ) (Token id:Id.Lit_Chars val:'\tgit diff adder...another >P.diff &&\n' span_id:200) (Token id:Id.Lit_Chars val:'\n' span_id:201) (Token id:Id.Lit_Chars val:'\tgit checkout adder^0 &&\n' span_id:202) (Token id: Id.Lit_Chars val: '\ttest_must_fail git merge --no-commit another &&\n' span_id: 203 ) (Token id:Id.Lit_Chars val:'\tgit ls-files -s >expect.ls &&\n' span_id:204) (Token id: Id.Lit_Chars val: '\tgit diff HEAD | sanitize_conflicted_diff >expect.diff\n' span_id: 205 ) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'apply -3 with add/add conflict' span_id:212))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:216) (Token id:Id.Lit_Chars val:'\t# should fail to apply ...\n' span_id:217) (Token id:Id.Lit_Chars val:'\tgit reset --hard &&\n' span_id:218) (Token id:Id.Lit_Chars val:'\tgit checkout adder^0 &&\n' span_id:219) (Token id:Id.Lit_Chars val:'\ttest_must_fail git apply --index --3way P.diff &&\n' span_id:220) (Token id: Id.Lit_Chars val: '\t# ... and leave conflicts in the index and in the working tree\n' span_id: 221 ) (Token id:Id.Lit_Chars val:'\tgit ls-files -s >actual.ls &&\n' span_id:222) (Token id: Id.Lit_Chars val: '\tgit diff HEAD | sanitize_conflicted_diff >actual.diff &&\n' span_id: 223 ) (Token id:Id.Lit_Chars val:'\n' span_id:224) (Token id: Id.Lit_Chars val: '\t# The result should resemble the corresponding merge\n' span_id: 225 ) (Token id:Id.Lit_Chars val:'\ttest_cmp expect.ls actual.ls &&\n' span_id:226) (Token id:Id.Lit_Chars val:'\ttest_cmp expect.diff actual.diff\n' span_id:227) ) } ) (C {(test_expect_success)} { (SQ (Token id: Id.Lit_Chars val: 'apply -3 with add/add conflict (dirty working tree)' span_id: 234 ) ) } { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:238) (Token id:Id.Lit_Chars val:'\t# should fail to apply ...\n' span_id:239) (Token id:Id.Lit_Chars val:'\tgit reset --hard &&\n' span_id:240) (Token id:Id.Lit_Chars val:'\tgit checkout adder^0 &&\n' span_id:241) (Token id:Id.Lit_Chars val:'\techo >>four &&\n' span_id:242) (Token id:Id.Lit_Chars val:'\tcat four >four.save &&\n' span_id:243) (Token id:Id.Lit_Chars val:'\tcat three >three.save &&\n' span_id:244) (Token id:Id.Lit_Chars val:'\tgit ls-files -s >expect.ls &&\n' span_id:245) (Token id:Id.Lit_Chars val:'\ttest_must_fail git apply --index --3way P.diff &&\n' span_id:246) (Token id:Id.Lit_Chars val:'\t# ... and should not touch anything\n' span_id:247) (Token id:Id.Lit_Chars val:'\tgit ls-files -s >actual.ls &&\n' span_id:248) (Token id:Id.Lit_Chars val:'\ttest_cmp expect.ls actual.ls &&\n' span_id:249) (Token id:Id.Lit_Chars val:'\ttest_cmp four.save four &&\n' span_id:250) (Token id:Id.Lit_Chars val:'\ttest_cmp three.save three\n' span_id:251) ) } ) (C {(test_done)}) ] )