path: root/t/
diff options
authorJeff King <>2015-03-25 05:28:57 (GMT)
committerJunio C Hamano <>2015-03-25 17:23:58 (GMT)
commit6636cf7e907d889eb69fe645198e58c773b2f755 (patch)
treea5b780236a350e1e5f325f9ea2f756cbd60b7832 /t/
parentfd7771415b9447c8e53dd99d7946e00ee212d70d (diff)
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 <> Acked-by: Johan Herland <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 't/')
1 files changed, 3 insertions, 6 deletions
diff --git a/t/ b/t/
index b1ea64b..54460be 100755
--- a/t/
+++ b/t/
@@ -51,15 +51,12 @@ test_expect_success 'deleting most notes with git-notes' '
num_notes=250 &&
i=0 &&
git rev-list HEAD |
- while read sha1
+ while test $i -lt $num_notes && read sha1
i=$(($i + 1)) &&
- if test $i -gt $num_notes
- then
- break
- fi &&
test_tick &&
- git notes remove "$sha1"
+ git notes remove "$sha1" ||
+ exit 1