Skip to content

Commit d239ef1

Browse files
avargitster
authored andcommitted
diff tests: don't ignore "git diff" exit code
Fix a test pattern that originated in f1af60b (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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 277ce79 commit d239ef1

File tree

1 file changed

+22
-27
lines changed

1 file changed

+22
-27
lines changed

t/t4020-diff-external.sh

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,15 @@ test_expect_success 'GIT_EXTERNAL_DIFF environment' '
3737
3838
'
3939

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
4443
4544
'
4645

4746
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
5149
5250
'
5351

@@ -83,16 +81,16 @@ test_expect_success 'diff.external' '
8381
}
8482
'
8583

86-
test_expect_success 'diff.external should apply only to diff' '
84+
test_expect_success !SANITIZE_LEAK 'diff.external should apply only to diff' '
8785
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
9088
'
9189

9290
test_expect_success 'diff.external and --no-ext-diff' '
9391
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
9694
'
9795

9896
test_expect_success 'diff attribute' '
@@ -115,17 +113,15 @@ test_expect_success 'diff attribute' '
115113
116114
'
117115

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
122119
123120
'
124121

125122
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
129125
130126
'
131127

@@ -148,17 +144,15 @@ test_expect_success 'diff attribute' '
148144
149145
'
150146

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
155150
156151
'
157152

158153
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
162156
163157
'
164158

@@ -177,7 +171,8 @@ test_expect_success 'attributes trump GIT_EXTERNAL_DIFF and diff.external' '
177171

178172
test_expect_success 'no diff with -diff' '
179173
echo >.gitattributes "file -diff" &&
180-
git diff | grep Binary
174+
git diff >out &&
175+
grep Binary out
181176
'
182177

183178
echo NULZbetweenZwords | perl -pe 'y/Z/\000/' > file

0 commit comments

Comments
 (0)