Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Sunshine <sunshine@sunshineco.com>2021-12-09 08:11:14 +0300
committerJunio C Hamano <gitster@pobox.com>2021-12-13 21:29:48 +0300
commitd0fd993137cf41be66b54628f124b6651eea0bd2 (patch)
tree5cf3d6ab76f75dabaac0ddff6cdca03dcaaf289d /t/t5616-partial-clone.sh
parentcbe1d9d630e529d3dd240eacf3d1c9799fef702b (diff)
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 <sunshine@sunshineco.com> Reviewed-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t5616-partial-clone.sh')
-rwxr-xr-xt/t5616-partial-clone.sh12
1 files changed, 6 insertions, 6 deletions
diff --git a/t/t5616-partial-clone.sh b/t/t5616-partial-clone.sh
index 23c156e399..34469b6ac1 100755
--- a/t/t5616-partial-clone.sh
+++ b/t/t5616-partial-clone.sh
@@ -19,7 +19,7 @@ test_expect_success 'setup normal src repo' '
echo "This is file: $n" > src/file.$n.txt &&
git -C src add file.$n.txt &&
git -C src commit -m "file $n" &&
- git -C src ls-files -s file.$n.txt >>temp
+ git -C src ls-files -s file.$n.txt >>temp || return 1
done &&
awk -f print_2.awk <temp | sort >expect_1.oids &&
test_line_count = 4 expect_1.oids
@@ -74,7 +74,7 @@ test_expect_success 'push new commits to server' '
do
echo "Mod file.1.txt $x" >>src/file.1.txt &&
git -C src add file.1.txt &&
- git -C src commit -m "mod $x"
+ git -C src commit -m "mod $x" || return 1
done &&
git -C src blame main -- file.1.txt >expect.blame &&
git -C src push -u srv main
@@ -116,7 +116,7 @@ test_expect_success 'push new commits to server for file.2.txt' '
do
echo "Mod file.2.txt $x" >>src/file.2.txt &&
git -C src add file.2.txt &&
- git -C src commit -m "mod $x"
+ git -C src commit -m "mod $x" || return 1
done &&
git -C src push -u srv main
'
@@ -137,7 +137,7 @@ test_expect_success 'push new commits to server for file.3.txt' '
do
echo "Mod file.3.txt $x" >>src/file.3.txt &&
git -C src add file.3.txt &&
- git -C src commit -m "mod $x"
+ git -C src commit -m "mod $x" || return 1
done &&
git -C src push -u srv main
'
@@ -385,7 +385,7 @@ setup_triangle () {
for i in $(test_seq 1 100)
do
echo "make the tree big" >server/file$i &&
- git -C server add file$i
+ git -C server add file$i || return 1
done &&
git -C server commit -m "initial" &&
git clone --bare --filter=tree:0 "file://$(pwd)/server" client &&
@@ -669,7 +669,7 @@ test_expect_success 'tolerate server sending REF_DELTA against missing promisor
for i in $(test_seq 10)
do
echo "this is a line" >>"$SERVER/foo.txt" &&
- echo "this is another line" >>"$SERVER/have.txt"
+ echo "this is another line" >>"$SERVER/have.txt" || return 1
done &&
git -C "$SERVER" add foo.txt have.txt &&
git -C "$SERVER" commit -m bar &&