3
# Copyright (c) 2005 Junio C Hamano
4
#
5
6
-test_description='git apply boundary tests
6
+test_description='git apply boundary tests'
7
8
-'
8
. ./test-lib.sh
9
10
L="c d e f g h i j k l m n o p q r s t u v w x"
11
12
test_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 &&
14
cat victim >original &&
15
git update-index --add victim &&
16
17
# 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 &&
19
cat victim >add-a-expect &&
20
git diff victim >add-a-patch.with &&
21
git diff --unified=0 >add-a-patch.without &&
22
23
# 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 &&
25
cat victim >insert-a-expect &&
26
git diff victim >insert-a-patch.with &&
27
git diff --unified=0 >insert-a-patch.without &&
28
29
# 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 &&
31
cat victim >mod-a-expect &&
32
git diff victim >mod-a-patch.with &&
33
git diff --unified=0 >mod-a-patch.without &&
34
35
# 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 &&
37
cat victim >del-a-expect &&
38
git diff victim >del-a-patch.with &&
39
git diff --unified=0 >del-a-patch.without &&
40
41
# 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 &&
43
cat victim >add-z-expect &&
44
git diff victim >add-z-patch.with &&
45
git diff --unified=0 >add-z-patch.without &&
46
47
# 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 &&
49
cat victim >mod-z-expect &&
50
git diff victim >mod-z-patch.with &&
51
git diff --unified=0 >mod-z-patch.without &&
52
53
# 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 &&
55
cat victim >del-z-expect &&
56
git diff victim >del-z-patch.with &&
57
git diff --unified=0 >del-z-patch.without
63
do
64
case "$with" in
65
with) u= ;;
91
- without) u='--unidiff-zero ' ;;
66
+ without) u=--unidiff-zero ;;
67
esac
68
for kind in add-a add-z insert-a mod-a mod-z del-a del-z
69
do
70
test_expect_success "apply $kind-patch $with context" '
71
cat original >victim &&
72
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
75
'
76
done
77
done
85
test_expect_success "apply non-git $kind-patch without context" '
86
cat original >victim &&
87
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
90
'
91
done
92
93
test_expect_success 'two lines' '
119
-
94
>file &&
95
git add file &&
96
echo aaa >file &&
99
echo bbb >file &&
100
git add file &&
101
test_must_fail git apply --check patch
128
-
102
'
103
104
test_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 &&
106
git add file &&
107
echo e >>file &&
108
git diff >patch &&