@@ -4,18 +4,24 @@ test_description='add -i basic tests'
4
4
. ./test-lib.sh
5
5
. " $TEST_DIRECTORY " /lib-prereq-FILEMODE.sh
6
6
7
- test_expect_success PERL ' setup (initial)' '
7
+ if ! test_have_prereq PERL
8
+ then
9
+ skip_all=' skipping add -i tests, perl not available'
10
+ test_done
11
+ fi
12
+
13
+ test_expect_success ' setup (initial)' '
8
14
echo content >file &&
9
15
git add file &&
10
16
echo more >>file &&
11
17
echo lines >>file
12
18
'
13
- test_expect_success PERL ' status works (initial)' '
19
+ test_expect_success ' status works (initial)' '
14
20
git add -i </dev/null >output &&
15
21
grep "+1/-0 *+2/-0 file" output
16
22
'
17
23
18
- test_expect_success PERL ' setup expected' '
24
+ test_expect_success ' setup expected' '
19
25
cat >expected <<EOF
20
26
new file mode 100644
21
27
index 0000000..d95f3ad
@@ -26,19 +32,19 @@ index 0000000..d95f3ad
26
32
EOF
27
33
'
28
34
29
- test_expect_success PERL ' diff works (initial)' '
35
+ test_expect_success ' diff works (initial)' '
30
36
(echo d; echo 1) | git add -i >output &&
31
37
sed -ne "/new file/,/content/p" <output >diff &&
32
38
test_cmp expected diff
33
39
'
34
- test_expect_success PERL ' revert works (initial)' '
40
+ test_expect_success ' revert works (initial)' '
35
41
git add file &&
36
42
(echo r; echo 1) | git add -i &&
37
43
git ls-files >output &&
38
44
! grep . output
39
45
'
40
46
41
- test_expect_success PERL ' setup (commit)' '
47
+ test_expect_success ' setup (commit)' '
42
48
echo baseline >file &&
43
49
git add file &&
44
50
git commit -m commit &&
@@ -47,12 +53,12 @@ test_expect_success PERL 'setup (commit)' '
47
53
echo more >>file &&
48
54
echo lines >>file
49
55
'
50
- test_expect_success PERL ' status works (commit)' '
56
+ test_expect_success ' status works (commit)' '
51
57
git add -i </dev/null >output &&
52
58
grep "+1/-0 *+2/-0 file" output
53
59
'
54
60
55
- test_expect_success PERL ' setup expected' '
61
+ test_expect_success ' setup expected' '
56
62
cat >expected <<EOF
57
63
index 180b47c..b6f2c08 100644
58
64
--- a/file
@@ -63,37 +69,37 @@ index 180b47c..b6f2c08 100644
63
69
EOF
64
70
'
65
71
66
- test_expect_success PERL ' diff works (commit)' '
72
+ test_expect_success ' diff works (commit)' '
67
73
(echo d; echo 1) | git add -i >output &&
68
74
sed -ne "/^index/,/content/p" <output >diff &&
69
75
test_cmp expected diff
70
76
'
71
- test_expect_success PERL ' revert works (commit)' '
77
+ test_expect_success ' revert works (commit)' '
72
78
git add file &&
73
79
(echo r; echo 1) | git add -i &&
74
80
git add -i </dev/null >output &&
75
81
grep "unchanged *+3/-0 file" output
76
82
'
77
83
78
84
79
- test_expect_success PERL ' setup expected' '
85
+ test_expect_success ' setup expected' '
80
86
cat >expected <<EOF
81
87
EOF
82
88
'
83
89
84
- test_expect_success PERL ' setup fake editor' '
90
+ test_expect_success ' setup fake editor' '
85
91
>fake_editor.sh &&
86
92
chmod a+x fake_editor.sh &&
87
93
test_set_editor "$(pwd)/fake_editor.sh"
88
94
'
89
95
90
- test_expect_success PERL ' dummy edit works' '
96
+ test_expect_success ' dummy edit works' '
91
97
(echo e; echo a) | git add -p &&
92
98
git diff > diff &&
93
99
test_cmp expected diff
94
100
'
95
101
96
- test_expect_success PERL ' setup patch' '
102
+ test_expect_success ' setup patch' '
97
103
cat >patch <<EOF
98
104
@@ -1,1 +1,4 @@
99
105
this
@@ -103,7 +109,7 @@ cat >patch <<EOF
103
109
EOF
104
110
'
105
111
106
- test_expect_success PERL ' setup fake editor' '
112
+ test_expect_success ' setup fake editor' '
107
113
echo "#!$SHELL_PATH" >fake_editor.sh &&
108
114
cat >>fake_editor.sh <<\EOF &&
109
115
mv -f "$1" oldpatch &&
@@ -113,26 +119,26 @@ EOF
113
119
test_set_editor "$(pwd)/fake_editor.sh"
114
120
'
115
121
116
- test_expect_success PERL ' bad edit rejected' '
122
+ test_expect_success ' bad edit rejected' '
117
123
git reset &&
118
124
(echo e; echo n; echo d) | git add -p >output &&
119
125
grep "hunk does not apply" output
120
126
'
121
127
122
- test_expect_success PERL ' setup patch' '
128
+ test_expect_success ' setup patch' '
123
129
cat >patch <<EOF
124
130
this patch
125
131
is garbage
126
132
EOF
127
133
'
128
134
129
- test_expect_success PERL ' garbage edit rejected' '
135
+ test_expect_success ' garbage edit rejected' '
130
136
git reset &&
131
137
(echo e; echo n; echo d) | git add -p >output &&
132
138
grep "hunk does not apply" output
133
139
'
134
140
135
- test_expect_success PERL ' setup patch' '
141
+ test_expect_success ' setup patch' '
136
142
cat >patch <<EOF
137
143
@@ -1,0 +1,0 @@
138
144
baseline
@@ -142,7 +148,7 @@ cat >patch <<EOF
142
148
EOF
143
149
'
144
150
145
- test_expect_success PERL ' setup expected' '
151
+ test_expect_success ' setup expected' '
146
152
cat >expected <<EOF
147
153
diff --git a/file b/file
148
154
index b5dd6c9..f910ae9 100644
@@ -157,13 +163,13 @@ index b5dd6c9..f910ae9 100644
157
163
EOF
158
164
'
159
165
160
- test_expect_success PERL ' real edit works' '
166
+ test_expect_success ' real edit works' '
161
167
(echo e; echo n; echo d) | git add -p &&
162
168
git diff >output &&
163
169
test_cmp expected output
164
170
'
165
171
166
- test_expect_success PERL ' skip files similarly as commit -a' '
172
+ test_expect_success ' skip files similarly as commit -a' '
167
173
git reset &&
168
174
echo file >.gitignore &&
169
175
echo changed >file &&
@@ -177,7 +183,7 @@ test_expect_success PERL 'skip files similarly as commit -a' '
177
183
'
178
184
rm -f .gitignore
179
185
180
- test_expect_success PERL, FILEMODE ' patch does not affect mode' '
186
+ test_expect_success FILEMODE ' patch does not affect mode' '
181
187
git reset --hard &&
182
188
echo content >>file &&
183
189
chmod +x file &&
@@ -186,7 +192,7 @@ test_expect_success PERL,FILEMODE 'patch does not affect mode' '
186
192
git diff file | grep "new mode"
187
193
'
188
194
189
- test_expect_success PERL, FILEMODE ' stage mode but not hunk' '
195
+ test_expect_success FILEMODE ' stage mode but not hunk' '
190
196
git reset --hard &&
191
197
echo content >>file &&
192
198
chmod +x file &&
@@ -196,7 +202,7 @@ test_expect_success PERL,FILEMODE 'stage mode but not hunk' '
196
202
'
197
203
198
204
199
- test_expect_success PERL, FILEMODE ' stage mode and hunk' '
205
+ test_expect_success FILEMODE ' stage mode and hunk' '
200
206
git reset --hard &&
201
207
echo content >>file &&
202
208
chmod +x file &&
@@ -208,14 +214,14 @@ test_expect_success PERL,FILEMODE 'stage mode and hunk' '
208
214
209
215
# end of tests disabled when filemode is not usable
210
216
211
- test_expect_success PERL ' setup again' '
217
+ test_expect_success ' setup again' '
212
218
git reset --hard &&
213
219
test_chmod +x file &&
214
220
echo content >>file
215
221
'
216
222
217
223
# Write the patch file with a new line at the top and bottom
218
- test_expect_success PERL ' setup patch' '
224
+ test_expect_success ' setup patch' '
219
225
cat >patch <<EOF
220
226
index 180b47c..b6f2c08 100644
221
227
--- a/file
229
235
'
230
236
231
237
# Expected output, similar to the patch but w/ diff at the top
232
- test_expect_success PERL ' setup expected' '
238
+ test_expect_success ' setup expected' '
233
239
cat >expected <<EOF
234
240
diff --git a/file b/file
235
241
index b6f2c08..61b9053 100755
@@ -244,15 +250,15 @@ EOF
244
250
'
245
251
246
252
# Test splitting the first patch, then adding both
247
- test_expect_success PERL ' add first line works' '
253
+ test_expect_success ' add first line works' '
248
254
git commit -am "clear local changes" &&
249
255
git apply patch &&
250
256
(echo s; echo y; echo y) | git add -p file &&
251
257
git diff --cached > diff &&
252
258
test_cmp expected diff
253
259
'
254
260
255
- test_expect_success PERL ' setup expected' '
261
+ test_expect_success ' setup expected' '
256
262
cat >expected <<EOF
257
263
diff --git a/non-empty b/non-empty
258
264
deleted file mode 100644
@@ -264,7 +270,7 @@ index d95f3ad..0000000
264
270
EOF
265
271
'
266
272
267
- test_expect_success PERL ' deleting a non-empty file' '
273
+ test_expect_success ' deleting a non-empty file' '
268
274
git reset --hard &&
269
275
echo content >non-empty &&
270
276
git add non-empty &&
@@ -275,15 +281,15 @@ test_expect_success PERL 'deleting a non-empty file' '
275
281
test_cmp expected diff
276
282
'
277
283
278
- test_expect_success PERL ' setup expected' '
284
+ test_expect_success ' setup expected' '
279
285
cat >expected <<EOF
280
286
diff --git a/empty b/empty
281
287
deleted file mode 100644
282
288
index e69de29..0000000
283
289
EOF
284
290
'
285
291
286
- test_expect_success PERL ' deleting an empty file' '
292
+ test_expect_success ' deleting an empty file' '
287
293
git reset --hard &&
288
294
> empty &&
289
295
git add empty &&
@@ -294,7 +300,7 @@ test_expect_success PERL 'deleting an empty file' '
294
300
test_cmp expected diff
295
301
'
296
302
297
- test_expect_success PERL ' split hunk setup' '
303
+ test_expect_success ' split hunk setup' '
298
304
git reset --hard &&
299
305
for i in 10 20 30 40 50 60
300
306
do
@@ -310,7 +316,7 @@ test_expect_success PERL 'split hunk setup' '
310
316
done >test
311
317
'
312
318
313
- test_expect_success PERL ' split hunk "add -p (edit)"' '
319
+ test_expect_success ' split hunk "add -p (edit)"' '
314
320
# Split, say Edit and do nothing. Then:
315
321
#
316
322
# 1. Broken version results in a patch that does not apply and
0 commit comments