mirror of
https://github.com/git/git.git
synced 2024-12-26 18:24:21 +08:00
ebee5580ca
Dash bug https://bugs.launchpad.net/ubuntu/+source/dash/+bug/139097 lets the shell erroneously perform field splitting on the expansion of a command substitution during declaration of a local variable. It causes the parallel-checkout tests to fail e.g. when running them with /bin/dash on MacOS 11.4, where they error out like this: ./t2080-parallel-checkout-basics.sh: 33: local: 0: bad variable name That's because the output of wc -l contains leading spaces and the returned number of lines is treated as another variable to declare, i.e. as in "local workers= 0". Work around it by enclosing the command substitution in quotes. Helped-by: Matheus Tavares Bernardino <matheus.bernardino@usp.br> Helped-by: SZEDER Gábor <szeder.dev@gmail.com> Helped-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
46 lines
1.2 KiB
Bash
46 lines
1.2 KiB
Bash
# Helpers for tests invoking parallel-checkout
|
|
|
|
# Parallel checkout tests need full control of the number of workers
|
|
unset GIT_TEST_CHECKOUT_WORKERS
|
|
|
|
set_checkout_config () {
|
|
if test $# -ne 2
|
|
then
|
|
BUG "usage: set_checkout_config <workers> <threshold>"
|
|
fi &&
|
|
|
|
test_config_global checkout.workers $1 &&
|
|
test_config_global checkout.thresholdForParallelism $2
|
|
}
|
|
|
|
# Run "${@:2}" and check that $1 checkout workers were used
|
|
test_checkout_workers () {
|
|
if test $# -lt 2
|
|
then
|
|
BUG "too few arguments to test_checkout_workers"
|
|
fi &&
|
|
|
|
local expected_workers=$1 &&
|
|
shift &&
|
|
|
|
local trace_file=trace-test-checkout-workers &&
|
|
rm -f "$trace_file" &&
|
|
GIT_TRACE2="$(pwd)/$trace_file" "$@" 2>&8 &&
|
|
|
|
local workers="$(grep "child_start\[..*\] git checkout--worker" "$trace_file" | wc -l)" &&
|
|
test $workers -eq $expected_workers &&
|
|
rm "$trace_file"
|
|
} 8>&2 2>&4
|
|
|
|
# Verify that both the working tree and the index were created correctly
|
|
verify_checkout () {
|
|
if test $# -ne 1
|
|
then
|
|
BUG "usage: verify_checkout <repository path>"
|
|
fi &&
|
|
|
|
git -C "$1" diff-index --ignore-submodules=none --exit-code HEAD -- &&
|
|
git -C "$1" status --porcelain >"$1".status &&
|
|
test_must_be_empty "$1".status
|
|
}
|