10
10
test_done
11
11
fi
12
12
13
+ diff_cmp () {
14
+ for x
15
+ do
16
+ sed -e ' /^index/s/[0-9a-f]*[1-9a-f][0-9a-f]*\.\./1234567../' \
17
+ -e ' /^index/s/\.\.[0-9a-f]*[1-9a-f][0-9a-f]*/..9abcdef/' \
18
+ -e ' /^index/s/ 00*\.\./ 0000000../' \
19
+ -e ' /^index/s/\.\.00*$/..0000000/' \
20
+ -e ' /^index/s/\.\.00* /..0000000 /' \
21
+ " $x " > " $x .filtered"
22
+ done
23
+ test_cmp " $1 .filtered" " $2 .filtered"
24
+ }
25
+
13
26
test_expect_success ' setup (initial)' '
14
27
echo content >file &&
15
28
git add file &&
@@ -35,7 +48,7 @@ test_expect_success 'setup expected' '
35
48
test_expect_success ' diff works (initial)' '
36
49
(echo d; echo 1) | git add -i >output &&
37
50
sed -ne "/new file/,/content/p" <output >diff &&
38
- test_cmp expected diff
51
+ diff_cmp expected diff
39
52
'
40
53
test_expect_success ' revert works (initial)' '
41
54
git add file &&
@@ -72,7 +85,7 @@ test_expect_success 'setup expected' '
72
85
test_expect_success ' diff works (commit)' '
73
86
(echo d; echo 1) | git add -i >output &&
74
87
sed -ne "/^index/,/content/p" <output >diff &&
75
- test_cmp expected diff
88
+ diff_cmp expected diff
76
89
'
77
90
test_expect_success ' revert works (commit)' '
78
91
git add file &&
@@ -91,7 +104,7 @@ test_expect_success 'dummy edit works' '
91
104
test_set_editor : &&
92
105
(echo e; echo a) | git add -p &&
93
106
git diff > diff &&
94
- test_cmp expected diff
107
+ diff_cmp expected diff
95
108
'
96
109
97
110
test_expect_success ' setup patch' '
@@ -159,7 +172,7 @@ test_expect_success 'setup expected' '
159
172
test_expect_success ' real edit works' '
160
173
(echo e; echo n; echo d) | git add -p &&
161
174
git diff >output &&
162
- test_cmp expected output
175
+ diff_cmp expected output
163
176
'
164
177
165
178
test_expect_success ' skip files similarly as commit -a' '
@@ -171,7 +184,7 @@ test_expect_success 'skip files similarly as commit -a' '
171
184
git reset &&
172
185
git commit -am commit &&
173
186
git diff >expected &&
174
- test_cmp expected output &&
187
+ diff_cmp expected output &&
175
188
git reset --hard HEAD^
176
189
'
177
190
rm -f .gitignore
@@ -248,7 +261,7 @@ test_expect_success 'add first line works' '
248
261
git apply patch &&
249
262
(echo s; echo y; echo y) | git add -p file &&
250
263
git diff --cached > diff &&
251
- test_cmp expected diff
264
+ diff_cmp expected diff
252
265
'
253
266
254
267
test_expect_success ' setup expected' '
@@ -271,7 +284,7 @@ test_expect_success 'deleting a non-empty file' '
271
284
rm non-empty &&
272
285
echo y | git add -p non-empty &&
273
286
git diff --cached >diff &&
274
- test_cmp expected diff
287
+ diff_cmp expected diff
275
288
'
276
289
277
290
test_expect_success ' setup expected' '
@@ -290,7 +303,7 @@ test_expect_success 'deleting an empty file' '
290
303
rm empty &&
291
304
echo y | git add -p empty &&
292
305
git diff --cached >diff &&
293
- test_cmp expected diff
306
+ diff_cmp expected diff
294
307
'
295
308
296
309
test_expect_success ' split hunk setup' '
@@ -355,7 +368,7 @@ test_expect_success 'patch mode ignores unmerged entries' '
355
368
+changed
356
369
EOF
357
370
git diff --cached >diff &&
358
- test_cmp expected diff
371
+ diff_cmp expected diff
359
372
'
360
373
361
374
test_expect_success TTY ' diffs can be colorized' '
@@ -384,7 +397,7 @@ test_expect_success 'patch-mode via -i prompts for files' '
384
397
385
398
echo test >expect &&
386
399
git diff --cached --name-only >actual &&
387
- test_cmp expect actual
400
+ diff_cmp expect actual
388
401
'
389
402
390
403
test_expect_success ' add -p handles globs' '
0 commit comments