Skip to content

Commit 206ca04

Browse files
trieu1162000gitster
authored andcommitted
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>
1 parent 67ad421 commit 206ca04

1 file changed

Lines changed: 31 additions & 17 deletions

File tree

t/t8003-blame-corner-cases.sh

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -50,67 +50,78 @@ test_expect_success setup '
5050

5151
test_expect_success 'straight copy without -C' '
5252
53-
git blame uno | grep Second
53+
git blame uno >actual &&
54+
test_grep Second actual
5455
5556
'
5657

5758
test_expect_success 'straight move without -C' '
5859
59-
git blame dos | grep Initial
60+
git blame dos >actual &&
61+
test_grep Initial actual
6062
6163
'
6264

6365
test_expect_success 'straight copy with -C' '
6466
65-
git blame -C1 uno | grep Second
67+
git blame -C1 uno >actual &&
68+
test_grep Second actual
6669
6770
'
6871

6972
test_expect_success 'straight move with -C' '
7073
71-
git blame -C1 dos | grep Initial
74+
git blame -C1 dos >actual &&
75+
test_grep Initial actual
7276
7377
'
7478

7579
test_expect_success 'straight copy with -C -C' '
7680
77-
git blame -C -C1 uno | grep Initial
81+
git blame -C -C1 uno >actual &&
82+
test_grep Initial actual
7883
7984
'
8085

8186
test_expect_success 'straight move with -C -C' '
8287
83-
git blame -C -C1 dos | grep Initial
88+
git blame -C -C1 dos >actual &&
89+
test_grep Initial actual
8490
8591
'
8692

8793
test_expect_success 'append without -C' '
8894
89-
git blame -L2 tres | grep Second
95+
git blame -L2 tres >actual &&
96+
test_grep Second actual
9097
9198
'
9299

93100
test_expect_success 'append with -C' '
94101
95-
git blame -L2 -C1 tres | grep Second
102+
git blame -L2 -C1 tres >actual &&
103+
test_grep Second actual
96104
97105
'
98106

99107
test_expect_success 'append with -C -C' '
100108
101-
git blame -L2 -C -C1 tres | grep Second
109+
git blame -L2 -C -C1 tres >actual &&
110+
test_grep Second actual
102111
103112
'
104113

105114
test_expect_success 'append with -C -C -C' '
106115
107-
git blame -L2 -C -C -C1 tres | grep Initial
116+
git blame -L2 -C -C -C1 tres >actual &&
117+
test_grep Initial actual
108118
109119
'
110120

111121
test_expect_success 'blame wholesale copy' '
112122
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 &&
114125
cat >expected <<-\EOF &&
115126
mouse-Initial
116127
mouse-Second
@@ -122,7 +133,8 @@ test_expect_success 'blame wholesale copy' '
122133

123134
test_expect_success 'blame wholesale copy and more' '
124135
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 &&
126138
cat >expected <<-\EOF &&
127139
mouse-Initial
128140
mouse-Second
@@ -144,7 +156,8 @@ test_expect_success 'blame wholesale copy and more in the index' '
144156
EOF
145157
git add horse &&
146158
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 &&
148161
cat >expected <<-\EOF &&
149162
mouse-Initial
150163
mouse-Second
@@ -168,7 +181,8 @@ test_expect_success 'blame during cherry-pick with file rename conflict' '
168181
(git cherry-pick HEAD@{1} || test $? -eq 1) &&
169182
git show HEAD@{1}:rodent > rodent &&
170183
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 &&
172186
cat >expected <<-\EOF &&
173187
mouse-Initial
174188
mouse-Second
@@ -246,14 +260,14 @@ test_expect_success 'setup file with CRLF newlines' '
246260
test_expect_success 'blame file with CRLF core.autocrlf true' '
247261
git config core.autocrlf true &&
248262
git blame crlffile >actual &&
249-
grep "A U Thor" actual
263+
test_grep "A U Thor" actual
250264
'
251265

252266
test_expect_success 'blame file with CRLF attributes text' '
253267
git config core.autocrlf false &&
254268
echo "crlffile text" >.gitattributes &&
255269
git blame crlffile >actual &&
256-
grep "A U Thor" actual
270+
test_grep "A U Thor" actual
257271
'
258272

259273
test_expect_success 'blame file with CRLF core.autocrlf=true' '
@@ -267,7 +281,7 @@ test_expect_success 'blame file with CRLF core.autocrlf=true' '
267281
git checkout crlfinrepo &&
268282
rm tmp &&
269283
git blame crlfinrepo >actual &&
270-
grep "A U Thor" actual
284+
test_grep "A U Thor" actual
271285
'
272286

273287
test_expect_success 'setup coalesce tests' '

0 commit comments

Comments
 (0)