git-commit-vandalism/t/perf/p1451-fsck-skip-list.sh
Eric Sunshine db5875aa9f t0000-t3999: 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>
2021-12-13 10:29:48 -08:00

41 lines
710 B
Bash
Executable File

#!/bin/sh
test_description='Test fsck skipList performance'
. ./perf-lib.sh
test_perf_fresh_repo
n=1000000
test_expect_success "setup $n bad commits" '
for i in $(test_seq 1 $n)
do
echo "commit refs/heads/master" &&
echo "committer C <c@example.com> 1234567890 +0000" &&
echo "data <<EOF" &&
echo "$i.Q." &&
echo "EOF" || return 1
done | q_to_nul | git fast-import
'
skip=0
while test $skip -le $n
do
test_expect_success "create skipList for $skip bad commits" '
git log --format=%H --max-count=$skip |
sort >skiplist
'
test_perf "fsck with $skip skipped bad commits" '
git -c fsck.skipList=skiplist fsck
'
case $skip in
0) skip=1 ;;
*) skip=${skip}0 ;;
esac
done
test_done