33# Copyright (c) 2005 Junio C Hamano
44#
55
6- test_description=' git apply boundary tests
6+ test_description=' git apply boundary tests'
77
8- '
98. ./test-lib.sh
109
1110L=" c d e f g h i j k l m n o p q r s t u v w x"
1211
1312test_expect_success setup '
14- for i in b ' " $L " ' y
15- do
16- echo $i
17- done >victim &&
13+ test_write_lines b $L y >victim &&
1814 cat victim >original &&
1915 git update-index --add victim &&
2016
2117 # add to the head
22- for i in a b ' " $L " ' y
23- do
24- echo $i
25- done >victim &&
18+ test_write_lines a b $L y >victim &&
2619 cat victim >add-a-expect &&
2720 git diff victim >add-a-patch.with &&
2821 git diff --unified=0 >add-a-patch.without &&
2922
3023 # insert at line two
31- for i in b a ' " $L " ' y
32- do
33- echo $i
34- done >victim &&
24+ test_write_lines b a $L y >victim &&
3525 cat victim >insert-a-expect &&
3626 git diff victim >insert-a-patch.with &&
3727 git diff --unified=0 >insert-a-patch.without &&
3828
3929 # modify at the head
40- for i in a ' " $L " ' y
41- do
42- echo $i
43- done >victim &&
30+ test_write_lines a $L y >victim &&
4431 cat victim >mod-a-expect &&
4532 git diff victim >mod-a-patch.with &&
4633 git diff --unified=0 >mod-a-patch.without &&
4734
4835 # remove from the head
49- for i in ' " $L " ' y
50- do
51- echo $i
52- done >victim &&
36+ test_write_lines $L y >victim &&
5337 cat victim >del-a-expect &&
5438 git diff victim >del-a-patch.with &&
5539 git diff --unified=0 >del-a-patch.without &&
5640
5741 # add to the tail
58- for i in b ' " $L " ' y z
59- do
60- echo $i
61- done >victim &&
42+ test_write_lines b $L y z >victim &&
6243 cat victim >add-z-expect &&
6344 git diff victim >add-z-patch.with &&
6445 git diff --unified=0 >add-z-patch.without &&
6546
6647 # modify at the tail
67- for i in b ' " $L " ' z
68- do
69- echo $i
70- done >victim &&
48+ test_write_lines b $L z >victim &&
7149 cat victim >mod-z-expect &&
7250 git diff victim >mod-z-patch.with &&
7351 git diff --unified=0 >mod-z-patch.without &&
7452
7553 # remove from the tail
76- for i in b ' " $L " '
77- do
78- echo $i
79- done >victim &&
54+ test_write_lines b $L >victim &&
8055 cat victim >del-z-expect &&
8156 git diff victim >del-z-patch.with &&
8257 git diff --unified=0 >del-z-patch.without
@@ -88,15 +63,15 @@ for with in with without
8863do
8964 case " $with " in
9065 with) u= ;;
91- without) u=' --unidiff-zero ' ;;
66+ without) u=--unidiff-zero ;;
9267 esac
9368 for kind in add-a add-z insert-a mod-a mod-z del-a del-z
9469 do
9570 test_expect_success " apply $kind -patch $with context" '
9671 cat original >victim &&
9772 git update-index victim &&
98- git apply --index ' " $u $kind -patch.$with " ' &&
99- test_cmp ' " $kind " ' -expect victim
73+ git apply --index $u " $kind-patch.$with" &&
74+ test_cmp "$kind-expect" victim
10075 '
10176 done
10277done
11085 test_expect_success " apply non-git $kind -patch without context" '
11186 cat original >victim &&
11287 git update-index victim &&
113- git apply --unidiff-zero --index ' " $kind -ng.without" ' &&
114- test_cmp ' " $kind " ' -expect victim
88+ git apply --unidiff-zero --index "$kind-ng.without" &&
89+ test_cmp "$kind-expect" victim
11590 '
11691done
11792
11893test_expect_success ' two lines' '
119-
12094 >file &&
12195 git add file &&
12296 echo aaa >file &&
@@ -125,11 +99,10 @@ test_expect_success 'two lines' '
12599 echo bbb >file &&
126100 git add file &&
127101 test_must_fail git apply --check patch
128-
129102'
130103
131104test_expect_success ' apply patch with 3 context lines matching at end' '
132- { echo a; echo b; echo c; echo d; } >file &&
105+ test_write_lines a b c d >file &&
133106 git add file &&
134107 echo e >>file &&
135108 git diff >patch &&
0 commit comments