mirror of
https://github.com/git/git
synced 2024-08-28 12:09:19 +00:00
![Eric Sunshine](/assets/img/avatar_default.png)
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>
41 lines
710 B
Bash
Executable file
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
|