1010 test_done
1111fi
1212
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+
1326test_expect_success ' setup (initial)' '
1427 echo content >file &&
1528 git add file &&
@@ -35,7 +48,7 @@ test_expect_success 'setup expected' '
3548test_expect_success ' diff works (initial)' '
3649 (echo d; echo 1) | git add -i >output &&
3750 sed -ne "/new file/,/content/p" <output >diff &&
38- test_cmp expected diff
51+ diff_cmp expected diff
3952'
4053test_expect_success ' revert works (initial)' '
4154 git add file &&
@@ -72,7 +85,7 @@ test_expect_success 'setup expected' '
7285test_expect_success ' diff works (commit)' '
7386 (echo d; echo 1) | git add -i >output &&
7487 sed -ne "/^index/,/content/p" <output >diff &&
75- test_cmp expected diff
88+ diff_cmp expected diff
7689'
7790test_expect_success ' revert works (commit)' '
7891 git add file &&
@@ -91,7 +104,7 @@ test_expect_success 'dummy edit works' '
91104 test_set_editor : &&
92105 (echo e; echo a) | git add -p &&
93106 git diff > diff &&
94- test_cmp expected diff
107+ diff_cmp expected diff
95108'
96109
97110test_expect_success ' setup patch' '
@@ -159,7 +172,7 @@ test_expect_success 'setup expected' '
159172test_expect_success ' real edit works' '
160173 (echo e; echo n; echo d) | git add -p &&
161174 git diff >output &&
162- test_cmp expected output
175+ diff_cmp expected output
163176'
164177
165178test_expect_success ' skip files similarly as commit -a' '
@@ -171,7 +184,7 @@ test_expect_success 'skip files similarly as commit -a' '
171184 git reset &&
172185 git commit -am commit &&
173186 git diff >expected &&
174- test_cmp expected output &&
187+ diff_cmp expected output &&
175188 git reset --hard HEAD^
176189'
177190rm -f .gitignore
@@ -248,7 +261,7 @@ test_expect_success 'add first line works' '
248261 git apply patch &&
249262 (echo s; echo y; echo y) | git add -p file &&
250263 git diff --cached > diff &&
251- test_cmp expected diff
264+ diff_cmp expected diff
252265'
253266
254267test_expect_success ' setup expected' '
@@ -271,7 +284,7 @@ test_expect_success 'deleting a non-empty file' '
271284 rm non-empty &&
272285 echo y | git add -p non-empty &&
273286 git diff --cached >diff &&
274- test_cmp expected diff
287+ diff_cmp expected diff
275288'
276289
277290test_expect_success ' setup expected' '
@@ -290,7 +303,7 @@ test_expect_success 'deleting an empty file' '
290303 rm empty &&
291304 echo y | git add -p empty &&
292305 git diff --cached >diff &&
293- test_cmp expected diff
306+ diff_cmp expected diff
294307'
295308
296309test_expect_success ' split hunk setup' '
@@ -355,7 +368,7 @@ test_expect_success 'patch mode ignores unmerged entries' '
355368 +changed
356369 EOF
357370 git diff --cached >diff &&
358- test_cmp expected diff
371+ diff_cmp expected diff
359372'
360373
361374test_expect_success TTY ' diffs can be colorized' '
@@ -384,7 +397,7 @@ test_expect_success 'patch-mode via -i prompts for files' '
384397
385398 echo test >expect &&
386399 git diff --cached --name-only >actual &&
387- test_cmp expect actual
400+ diff_cmp expect actual
388401'
389402
390403test_expect_success ' add -p handles globs' '
0 commit comments