diff options
author | Eric Sunshine <sunshine@sunshineco.com> | 2021-12-09 08:11:13 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-12-13 21:29:48 +0300 |
commit | cbe1d9d630e529d3dd240eacf3d1c9799fef702b (patch) | |
tree | 5aaa08925285248af953dc01916f33b26d0eb142 /t/t4057-diff-combined-paths.sh | |
parent | db5875aa9fe056c2db3a463989091c5f70d6c8d1 (diff) |
t4000-t4999: 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 <sunshine@sunshineco.com>
Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t4057-diff-combined-paths.sh')
-rwxr-xr-x | t/t4057-diff-combined-paths.sh | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/t/t4057-diff-combined-paths.sh b/t/t4057-diff-combined-paths.sh index 7e5b74f72e..04b8a1542a 100755 --- a/t/t4057-diff-combined-paths.sh +++ b/t/t4057-diff-combined-paths.sh @@ -18,13 +18,13 @@ test_expect_success 'trivial merge - combine-diff empty' ' for i in $(test_seq 1 9) do echo $i >$i.txt && - git add $i.txt + git add $i.txt || return 1 done && git commit -m "init" && git checkout -b side && for i in $(test_seq 2 9) do - echo $i/2 >>$i.txt + echo $i/2 >>$i.txt || return 1 done && git commit -a -m "side 2-9" && git checkout main && @@ -40,14 +40,14 @@ test_expect_success 'only one truly conflicting path' ' git checkout side && for i in $(test_seq 2 9) do - echo $i/3 >>$i.txt + echo $i/3 >>$i.txt || return 1 done && echo "4side" >>4.txt && git commit -a -m "side 2-9 +4" && git checkout main && for i in $(test_seq 1 9) do - echo $i/3 >>$i.txt + echo $i/3 >>$i.txt || return 1 done && echo "4main" >>4.txt && git commit -a -m "main 1-9 +4" && @@ -69,13 +69,13 @@ test_expect_success 'merge introduces new file' ' git checkout side && for i in $(test_seq 5 9) do - echo $i/4 >>$i.txt + echo $i/4 >>$i.txt || return 1 done && git commit -a -m "side 5-9" && git checkout main && for i in $(test_seq 1 3) do - echo $i/4 >>$i.txt + echo $i/4 >>$i.txt || return 1 done && git commit -a -m "main 1-3 +4hello" && git merge side && @@ -90,13 +90,13 @@ test_expect_success 'merge removed a file' ' git checkout side && for i in $(test_seq 5 9) do - echo $i/5 >>$i.txt + echo $i/5 >>$i.txt || return 1 done && git commit -a -m "side 5-9" && git checkout main && for i in $(test_seq 1 3) do - echo $i/4 >>$i.txt + echo $i/4 >>$i.txt || return 1 done && git commit -a -m "main 1-3" && git merge side && |