(command.CommandList children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:test_description) op: assign_op.Equal rhs: {(SQ <'git apply boundary tests\n'> <'\n'>)} spids: [13] ) ] ) (C {<.>} {<'./test-lib.sh'>}) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:L) op: assign_op.Equal rhs: {(DQ <'c d e f g h i j k l m n o p q r s t u v w x'>)} spids: [24] ) ] ) (C {<test_expect_success>} {<setup>} {(SQ <'\n'> <'\tfor i in b '>) (DQ ($ Id.VSub_DollarName '$L')) (SQ <' y\n'> <'\tdo\n'> <'\t\techo $i\n'> <'\tdone >victim &&\n'> <'\tcat victim >original &&\n'> <'\tgit update-index --add victim &&\n'> <'\n'> <'\t# add to the head\n'> <'\tfor i in a b '> ) (DQ ($ Id.VSub_DollarName '$L')) (SQ <' y\n'> <'\tdo\n'> <'\t\techo $i\n'> <'\tdone >victim &&\n'> <'\tcat victim >add-a-expect &&\n'> <'\tgit diff victim >add-a-patch.with &&\n'> <'\tgit diff --unified=0 >add-a-patch.without &&\n'> <'\n'> <'\t# insert at line two\n'> <'\tfor i in b a '> ) (DQ ($ Id.VSub_DollarName '$L')) (SQ <' y\n'> <'\tdo\n'> <'\t\techo $i\n'> <'\tdone >victim &&\n'> <'\tcat victim >insert-a-expect &&\n'> <'\tgit diff victim >insert-a-patch.with &&\n'> <'\tgit diff --unified=0 >insert-a-patch.without &&\n'> <'\n'> <'\t# modify at the head\n'> <'\tfor i in a '> ) (DQ ($ Id.VSub_DollarName '$L')) (SQ <' y\n'> <'\tdo\n'> <'\t\techo $i\n'> <'\tdone >victim &&\n'> <'\tcat victim >mod-a-expect &&\n'> <'\tgit diff victim >mod-a-patch.with &&\n'> <'\tgit diff --unified=0 >mod-a-patch.without &&\n'> <'\n'> <'\t# remove from the head\n'> <'\tfor i in '> ) (DQ ($ Id.VSub_DollarName '$L')) (SQ <' y\n'> <'\tdo\n'> <'\t\techo $i\n'> <'\tdone >victim &&\n'> <'\tcat victim >del-a-expect &&\n'> <'\tgit diff victim >del-a-patch.with &&\n'> <'\tgit diff --unified=0 >del-a-patch.without &&\n'> <'\n'> <'\t# add to the tail\n'> <'\tfor i in b '> ) (DQ ($ Id.VSub_DollarName '$L')) (SQ <' y z\n'> <'\tdo\n'> <'\t\techo $i\n'> <'\tdone >victim &&\n'> <'\tcat victim >add-z-expect &&\n'> <'\tgit diff victim >add-z-patch.with &&\n'> <'\tgit diff --unified=0 >add-z-patch.without &&\n'> <'\n'> <'\t# modify at the tail\n'> <'\tfor i in b '> ) (DQ ($ Id.VSub_DollarName '$L')) (SQ <' z\n'> <'\tdo\n'> <'\t\techo $i\n'> <'\tdone >victim &&\n'> <'\tcat victim >mod-z-expect &&\n'> <'\tgit diff victim >mod-z-patch.with &&\n'> <'\tgit diff --unified=0 >mod-z-patch.without &&\n'> <'\n'> <'\t# remove from the tail\n'> <'\tfor i in b '> ) (DQ ($ Id.VSub_DollarName '$L')) (SQ <'\n'> <'\tdo\n'> <'\t\techo $i\n'> <'\tdone >victim &&\n'> <'\tcat victim >del-z-expect &&\n'> <'\tgit diff victim >del-z-patch.with &&\n'> <'\tgit diff --unified=0 >del-z-patch.without\n'> <'\n'> <'\t# done\n'> ) } ) (command.ForEach iter_name: with iter_words: [{<with>} {<without>}] do_arg_iter: F body: (command.DoGroup children: [ (command.Case to_match: {(DQ ($ Id.VSub_DollarName '$with'))} arms: [ (case_arm pat_list: [{<with>}] action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:u) op: assign_op.Equal rhs: (word.Empty) spids: [183] ) ] ) ] spids: [180 181 185 -1] ) (case_arm pat_list: [{<without>}] action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:u) op: assign_op.Equal rhs: {(SQ <'--unidiff-zero '>)} spids: [191] ) ] ) ] spids: [188 189 196 -1] ) ] ) (command.ForEach iter_name: kind iter_words: [{<add-a>} {<add-z>} {<insert-a>} {<mod-a>} {<mod-z>} {<del-a>} {<del-z>}] do_arg_iter: F body: (command.DoGroup children: [ (C {<test_expect_success>} { (DQ <'apply '> ($ Id.VSub_DollarName '$kind') <'-patch '> ($ Id.VSub_DollarName '$with') <' context'> ) } { (SQ <'\n'> <'\t\t\tcat original >victim &&\n'> <'\t\t\tgit update-index victim &&\n'> <'\t\t\tgit apply --index '> ) (DQ ($ Id.VSub_DollarName '$u') ($ Id.VSub_DollarName '$kind') <-patch.> ($ Id.VSub_DollarName '$with') ) (SQ <' &&\n'> <'\t\t\ttest_cmp '>) (DQ ($ Id.VSub_DollarName '$kind')) (SQ <'-expect victim\n'> <'\t\t'>) } ) ] ) ) ] ) ) (command.ForEach iter_name: kind iter_words: [{<add-a>} {<add-z>} {<insert-a>} {<mod-a>} {<mod-z>} {<del-a>} {<del-z>}] do_arg_iter: F body: (command.DoGroup children: [ (C {<rm>} {<-f>} {($ Id.VSub_DollarName '$kind') <-ng.without>}) (command.Simple words: [{<sed>} {<-e>} {(DQ <'s/^diff --git /diff /'>)} {<-e>} {(SQ <'/^index /d'>)}] redirects: [ (redir op: <Id.Redir_Less '<'> loc: (redir_loc.Fd fd:0) arg: {($ Id.VSub_DollarName '$kind') <-patch.without>} ) (redir op: <Id.Redir_Great '>'> loc: (redir_loc.Fd fd:1) arg: {($ Id.VSub_DollarName '$kind') <-ng.without>} ) ] do_fork: T ) (C {<test_expect_success>} {(DQ <'apply non-git '> ($ Id.VSub_DollarName '$kind') <'-patch without context'>)} { (SQ <'\n'> <'\t\tcat original >victim &&\n'> <'\t\tgit update-index victim &&\n'> <'\t\tgit apply --unidiff-zero --index '> ) (DQ ($ Id.VSub_DollarName '$kind') <-ng.without>) (SQ <' &&\n'> <'\t\ttest_cmp '>) (DQ ($ Id.VSub_DollarName '$kind')) (SQ <'-expect victim\n'> <'\t'>) } ) ] ) ) (C {<test_expect_success>} {(SQ <'two lines'>)} { (SQ <'\n'> <'\n'> <'\t>file &&\n'> <'\tgit add file &&\n'> <'\techo aaa >file &&\n'> <'\tgit diff >patch &&\n'> <'\tgit add file &&\n'> <'\techo bbb >file &&\n'> <'\tgit add file &&\n'> <'\ttest_must_fail git apply --check patch\n'> <'\n'> ) } ) (C {<test_expect_success>} {(SQ <'apply patch with 3 context lines matching at end'>)} { (SQ <'\n'> <'\t{ echo a; echo b; echo c; echo d; } >file &&\n'> <'\tgit add file &&\n'> <'\techo e >>file &&\n'> <'\tgit diff >patch &&\n'> <'\t>file &&\n'> <'\ttest_must_fail git apply patch\n'> ) } ) (C {<test_done>}) ] )