Skip to content

Commit 6636cf7

Browse files
peffgitster
authored andcommitted
t3305: fix ignored exit code inside loop
When we test deleting notes, we run "git notes remove" in a loop. However, the exit value of the loop will only reflect the final note we process. We should break out of the loop with a failing exit code as soon as we see a problem. Note that we can call "exit 1" here without explicitly creating a subshell, because the while loop on the right-hand side of a pipe executes in its own implicit subshell. Note also that the "break" above does not suffer the same problem; it is meant to exit the loop early at a certain number of iterations. We can bump it into the conditional of the loop to make this more obvious. Signed-off-by: Jeff King <[email protected]> Acked-by: Johan Herland <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fd77714 commit 6636cf7

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

t/t3305-notes-fanout.sh

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,12 @@ test_expect_success 'deleting most notes with git-notes' '
5151
num_notes=250 &&
5252
i=0 &&
5353
git rev-list HEAD |
54-
while read sha1
54+
while test $i -lt $num_notes && read sha1
5555
do
5656
i=$(($i + 1)) &&
57-
if test $i -gt $num_notes
58-
then
59-
break
60-
fi &&
6157
test_tick &&
62-
git notes remove "$sha1"
58+
git notes remove "$sha1" ||
59+
exit 1
6360
done
6461
'
6562

0 commit comments

Comments
 (0)