t8003: avoid suppressing git's exit code
Update t8003-blame-corner-cases.sh to redirect git-blame output to a temporary file instead of piping it directly to not hide the exit code of git commands behind pipes, as a crash in git might go unnoticed. Signed-off-by: Trieu Huynh <vikingtc4@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Trieu Huynh committed
Mar 28, 2026 at 22:29 UTC
206ca04c8669ddf5aa75c162dd97d8e1c499cda9
1 file changed
+31
-17
t/t8003-blame-corner-cases.sh
+31
-17
@@ -50,67 +50,78 @@ test_expect_success setup '
50
51
test_expect_success 'straight copy without -C' '
52
53
- git blame uno | grep Second
53
+ git blame uno >actual &&
54
+ test_grep Second actual
55
56
'
57
58
test_expect_success 'straight move without -C' '
59
59
- git blame dos | grep Initial
60
+ git blame dos >actual &&
61
+ test_grep Initial actual
62
63
'
64
65
test_expect_success 'straight copy with -C' '
66
65
- git blame -C1 uno | grep Second
67
+ git blame -C1 uno >actual &&
68
+ test_grep Second actual
69
70
'
71
72
test_expect_success 'straight move with -C' '
73
71
- git blame -C1 dos | grep Initial
74
+ git blame -C1 dos >actual &&
75
+ test_grep Initial actual
76
77
'
78
79
test_expect_success 'straight copy with -C -C' '
80
77
- git blame -C -C1 uno | grep Initial
81
+ git blame -C -C1 uno >actual &&
82
+ test_grep Initial actual
83
84
'
85
86
test_expect_success 'straight move with -C -C' '
87
83
- git blame -C -C1 dos | grep Initial
88
+ git blame -C -C1 dos >actual &&
89
+ test_grep Initial actual
90
91
'
92
93
test_expect_success 'append without -C' '
94
89
- git blame -L2 tres | grep Second
95
+ git blame -L2 tres >actual &&
96
+ test_grep Second actual
97
98
'
99
100
test_expect_success 'append with -C' '
101
95
- git blame -L2 -C1 tres | grep Second
102
+ git blame -L2 -C1 tres >actual &&
103
+ test_grep Second actual
104
105
'
106
107
test_expect_success 'append with -C -C' '
108
101
- git blame -L2 -C -C1 tres | grep Second
109
+ git blame -L2 -C -C1 tres >actual &&
110
+ test_grep Second actual
111
112
'
113
114
test_expect_success 'append with -C -C -C' '
115
107
- git blame -L2 -C -C -C1 tres | grep Initial
116
+ git blame -L2 -C -C -C1 tres >actual &&
117
+ test_grep Initial actual
118
119
'
120
121
test_expect_success 'blame wholesale copy' '
122
113
- git blame -f -C -C1 HEAD^ -- cow | sed -e "$pick_fc" >current &&
123
+ git blame -f -C -C1 HEAD^ -- cow >actual &&
124
+ sed -e "$pick_fc" actual >current &&
125
cat >expected <<-\EOF &&
126
mouse-Initial
127
mouse-Second
@@ -122,7 +133,8 @@ test_expect_success 'blame wholesale copy' '
133
134
test_expect_success 'blame wholesale copy and more' '
135
125
- git blame -f -C -C1 HEAD -- cow | sed -e "$pick_fc" >current &&
136
+ git blame -f -C -C1 HEAD -- cow >actual &&
137
+ sed -e "$pick_fc" actual >current &&
138
cat >expected <<-\EOF &&
139
mouse-Initial
140
mouse-Second
@@ -144,7 +156,8 @@ test_expect_success 'blame wholesale copy and more in the index' '
156
EOF
157
git add horse &&
158
test_when_finished "git rm -f horse" &&
147
- git blame -f -C -C1 -- horse | sed -e "$pick_fc" >current &&
159
+ git blame -f -C -C1 -- horse >actual &&
160
+ sed -e "$pick_fc" actual >current &&
161
cat >expected <<-\EOF &&
162
mouse-Initial
163
mouse-Second
@@ -168,7 +181,8 @@ test_expect_success 'blame during cherry-pick with file rename conflict' '
181
(git cherry-pick HEAD@{1} || test $? -eq 1) &&
182
git show HEAD@{1}:rodent > rodent &&
183
git add rodent &&
171
- git blame -f -C -C1 rodent | sed -e "$pick_fc" >current &&
184
+ git blame -f -C -C1 rodent >actual &&
185
+ sed -e "$pick_fc" actual >current &&
186
cat >expected <<-\EOF &&
187
mouse-Initial
188
mouse-Second
@@ -246,14 +260,14 @@ test_expect_success 'setup file with CRLF newlines' '
260
test_expect_success 'blame file with CRLF core.autocrlf true' '
261
git config core.autocrlf true &&
262
git blame crlffile >actual &&
249
- grep "A U Thor" actual
263
+ test_grep "A U Thor" actual
264
'
265
266
test_expect_success 'blame file with CRLF attributes text' '
267
git config core.autocrlf false &&
268
echo "crlffile text" >.gitattributes &&
269
git blame crlffile >actual &&
256
- grep "A U Thor" actual
270
+ test_grep "A U Thor" actual
271
'
272
273
test_expect_success 'blame file with CRLF core.autocrlf=true' '
@@ -267,7 +281,7 @@ test_expect_success 'blame file with CRLF core.autocrlf=true' '
281
git checkout crlfinrepo &&
282
rm tmp &&
283
git blame crlfinrepo >actual &&
270
- grep "A U Thor" actual
284
+ test_grep "A U Thor" actual
285
'
286
287
test_expect_success 'setup coalesce tests' '