blob: b4de075a3e5df86fe399f9133f7437c4a8d8e26d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
#!/bin/sh
#
# Copyright (c) 2005 Junio C Hamano
#
test_description='git-apply with rejects
'
. ./test-lib.sh
test_expect_success setup '
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
do
echo $i
done >file1 &&
cat file1 >saved.file1 &&
git update-index --add file1 &&
git commit -m initial &&
for i in 1 2 A B 4 5 6 7 8 9 10 11 12 C 13 14 15 16 17 18 19 20 D 21
do
echo $i
done >file1 &&
git diff >patch.1 &&
cat file1 >clean &&
for i in 1 E 2 3 4 5 6 7 8 9 10 11 12 C 13 14 15 16 17 18 19 20 F 21
do
echo $i
done >expected &&
mv file1 file2 &&
git update-index --add --remove file1 file2 &&
git diff -M HEAD >patch.2 &&
rm -f file1 file2 &&
mv saved.file1 file1 &&
git update-index --add --remove file1 file2 &&
for i in 1 E 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 F 21
do
echo $i
done >file1 &&
cat file1 >saved.file1
'
test_expect_success 'apply without --reject should fail' '
if git apply patch.1
then
echo "Eh? Why?"
exit 1
fi
diff -u file1 saved.file1
'
test_expect_success 'apply without --reject should fail' '
if git apply --verbose patch.1
then
echo "Eh? Why?"
exit 1
fi
diff -u file1 saved.file1
'
test_expect_success 'apply with --reject should fail but update the file' '
cat saved.file1 >file1 &&
rm -f file1.rej file2.rej &&
if git apply --reject patch.1
then
echo "succeeds with --reject?"
exit 1
fi
diff -u file1 expected &&
cat file1.rej &&
if test -f file2.rej
then
echo "file2 should not have been touched"
exit 1
fi
'
test_expect_success 'apply with --reject should fail but update the file' '
cat saved.file1 >file1 &&
rm -f file1.rej file2.rej file2 &&
if git apply --reject patch.2 >rejects
then
echo "succeeds with --reject?"
exit 1
fi
test -f file1 && {
echo "file1 still exists?"
exit 1
}
diff -u file2 expected &&
cat file2.rej &&
if test -f file1.rej
then
echo "file2 should not have been touched"
exit 1
fi
'
test_expect_success 'the same test with --verbose' '
cat saved.file1 >file1 &&
rm -f file1.rej file2.rej file2 &&
if git apply --reject --verbose patch.2 >rejects
then
echo "succeeds with --reject?"
exit 1
fi
test -f file1 && {
echo "file1 still exists?"
exit 1
}
diff -u file2 expected &&
cat file2.rej &&
if test -f file1.rej
then
echo "file2 should not have been touched"
exit 1
fi
'
test_expect_success 'apply cleanly with --verbose' '
git cat-file -p HEAD:file1 >file1 &&
rm -f file?.rej file2 &&
git apply --verbose patch.1 &&
diff -u file1 clean
'
test_done
|