diff tests: don't ignore "git diff" exit code

Fix a test pattern that originated in f1af60bdba4 (Support 'diff=pgm' attribute, 2007-04-22) so that we'll stop using "git diff" on the left-hand-side of a pipe, and thus ignoring its exit code. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Mar 7, 2022 at 13:48 UTC d239ef1cbacfa021175147ae69e6b5ec0de234a6
1 file changed +22 -27
t/t4020-diff-external.sh
+22 -27
@@ -37,17 +37,15 @@ test_expect_success 'GIT_EXTERNAL_DIFF environment' '
37
38 '
39
40 -test_expect_success 'GIT_EXTERNAL_DIFF environment should apply only to diff' '
41 -
42 - GIT_EXTERNAL_DIFF=echo git log -p -1 HEAD |
43 - grep "^diff --git a/file b/file"
40 +test_expect_success !SANITIZE_LEAK 'GIT_EXTERNAL_DIFF environment should apply only to diff' '
41 + GIT_EXTERNAL_DIFF=echo git log -p -1 HEAD >out &&
42 + grep "^diff --git a/file b/file" out
43
44 '
45
46 test_expect_success 'GIT_EXTERNAL_DIFF environment and --no-ext-diff' '
48 -
49 - GIT_EXTERNAL_DIFF=echo git diff --no-ext-diff |
50 - grep "^diff --git a/file b/file"
47 + GIT_EXTERNAL_DIFF=echo git diff --no-ext-diff >out &&
48 + grep "^diff --git a/file b/file" out
49
50 '
51
@@ -83,16 +81,16 @@ test_expect_success 'diff.external' '
81 }
82 '
83
86 -test_expect_success 'diff.external should apply only to diff' '
84 +test_expect_success !SANITIZE_LEAK 'diff.external should apply only to diff' '
85 test_config diff.external echo &&
88 - git log -p -1 HEAD |
89 - grep "^diff --git a/file b/file"
86 + git log -p -1 HEAD >out &&
87 + grep "^diff --git a/file b/file" out
88 '
89
90 test_expect_success 'diff.external and --no-ext-diff' '
91 test_config diff.external echo &&
94 - git diff --no-ext-diff |
95 - grep "^diff --git a/file b/file"
92 + git diff --no-ext-diff >out &&
93 + grep "^diff --git a/file b/file" out
94 '
95
96 test_expect_success 'diff attribute' '
@@ -115,17 +113,15 @@ test_expect_success 'diff attribute' '
113
114 '
115
118 -test_expect_success 'diff attribute should apply only to diff' '
119 -
120 - git log -p -1 HEAD |
121 - grep "^diff --git a/file b/file"
116 +test_expect_success !SANITIZE_LEAK 'diff attribute should apply only to diff' '
117 + git log -p -1 HEAD >out &&
118 + grep "^diff --git a/file b/file" out
119
120 '
121
122 test_expect_success 'diff attribute and --no-ext-diff' '
126 -
127 - git diff --no-ext-diff |
128 - grep "^diff --git a/file b/file"
123 + git diff --no-ext-diff >out &&
124 + grep "^diff --git a/file b/file" out
125
126 '
127
@@ -148,17 +144,15 @@ test_expect_success 'diff attribute' '
144
145 '
146
151 -test_expect_success 'diff attribute should apply only to diff' '
152 -
153 - git log -p -1 HEAD |
154 - grep "^diff --git a/file b/file"
147 +test_expect_success !SANITIZE_LEAK 'diff attribute should apply only to diff' '
148 + git log -p -1 HEAD >out &&
149 + grep "^diff --git a/file b/file" out
150
151 '
152
153 test_expect_success 'diff attribute and --no-ext-diff' '
159 -
160 - git diff --no-ext-diff |
161 - grep "^diff --git a/file b/file"
154 + git diff --no-ext-diff >out &&
155 + grep "^diff --git a/file b/file" out
156
157 '
158
@@ -177,7 +171,8 @@ test_expect_success 'attributes trump GIT_EXTERNAL_DIFF and diff.external' '
171
172 test_expect_success 'no diff with -diff' '
173 echo >.gitattributes "file -diff" &&
180 - git diff | grep Binary
174 + git diff >out &&
175 + grep Binary out
176 '
177
178 echo NULZbetweenZwords | perl -pe 'y/Z/\000/' > file