From d0fd993137cf41be66b54628f124b6651eea0bd2 Mon Sep 17 00:00:00 2001 From: Eric Sunshine Date: Thu, 9 Dec 2021 00:11:14 -0500 Subject: t5000-t5999: detect and signal failure within loop Failures within `for` and `while` loops can go unnoticed if not detected and signaled manually since the loop itself does not abort when a contained command fails, nor will a failure necessarily be detected when the loop finishes since the loop returns the exit code of the last command it ran on the final iteration, which may not be the command which failed. Therefore, detect and signal failures manually within loops using the idiom `|| return 1` (or `|| exit 1` within subshells). Signed-off-by: Eric Sunshine Reviewed-by: Elijah Newren Signed-off-by: Junio C Hamano --- t/t5317-pack-objects-filter-objects.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 't/t5317-pack-objects-filter-objects.sh') diff --git a/t/t5317-pack-objects-filter-objects.sh b/t/t5317-pack-objects-filter-objects.sh index 8fb6acae47..33b740ce62 100755 --- a/t/t5317-pack-objects-filter-objects.sh +++ b/t/t5317-pack-objects-filter-objects.sh @@ -18,7 +18,7 @@ test_expect_success 'setup r1' ' do echo "This is file: $n" > r1/file.$n && git -C r1 add file.$n && - git -C r1 commit -m "$n" + git -C r1 commit -m "$n" || return 1 done ' @@ -118,7 +118,7 @@ test_expect_success 'setup r2' ' do printf "%"$n"s" X > r2/large.$n && git -C r2 add large.$n && - git -C r2 commit -m "$n" + git -C r2 commit -m "$n" || return 1 done ' @@ -281,7 +281,7 @@ test_expect_success 'setup r3' ' echo "This is file: $n" > r3/$n && git -C r3 add $n && echo "This is file: dir1/$n" > r3/dir1/$n && - git -C r3 add dir1/$n + git -C r3 add dir1/$n || return 1 done && git -C r3 commit -m "sparse" && echo dir1/ >pattern1 && @@ -334,7 +334,7 @@ test_expect_success 'setup r4' ' echo "This is file: $n" > r4/$n && git -C r4 add $n && echo "This is file: dir1/$n" > r4/dir1/$n && - git -C r4 add dir1/$n + git -C r4 add dir1/$n || return 1 done && echo dir1/ >r4/pattern && git -C r4 add pattern && @@ -409,7 +409,7 @@ test_expect_success 'setup r1 - delete loose blobs' ' for id in `cat expected | sed "s|..|&/|"` do - rm r1/.git/objects/$id + rm r1/.git/objects/$id || return 1 done ' -- cgit v1.3-5-g9baa