6c62f01552
'git for-each-repo --config=X' should return success without calling any subcommands when the config key 'X' has no value. The current implementation instead segfaults. A user could run into this issue if they used 'git maintenance start' to initialize their cron schedule using 'git for-each-repo --config=maintenance.repo ...' but then using 'git maintenance unregister' to remove the config option. (Note: 'git maintenance stop' would remove the config _and_ remove the cron schedule.) Add a simple test to ensure this works. Use 'git help --no-such-option' as the potential subcommand to ensure that we will hit a failure if the subcommand is ever run. Reported-by: Andreas Bühmann <dev@uuml.de> Helped-by: Eric Sunshine <sunshine@sunshineco.com> Helped-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
37 lines
1.1 KiB
Bash
Executable File
37 lines
1.1 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
test_description='git for-each-repo builtin'
|
|
|
|
. ./test-lib.sh
|
|
|
|
test_expect_success 'run based on configured value' '
|
|
git init one &&
|
|
git init two &&
|
|
git init three &&
|
|
git -C two commit --allow-empty -m "DID NOT RUN" &&
|
|
git config run.key "$TRASH_DIRECTORY/one" &&
|
|
git config --add run.key "$TRASH_DIRECTORY/three" &&
|
|
git for-each-repo --config=run.key commit --allow-empty -m "ran" &&
|
|
git -C one log -1 --pretty=format:%s >message &&
|
|
grep ran message &&
|
|
git -C two log -1 --pretty=format:%s >message &&
|
|
! grep ran message &&
|
|
git -C three log -1 --pretty=format:%s >message &&
|
|
grep ran message &&
|
|
git for-each-repo --config=run.key -- commit --allow-empty -m "ran again" &&
|
|
git -C one log -1 --pretty=format:%s >message &&
|
|
grep again message &&
|
|
git -C two log -1 --pretty=format:%s >message &&
|
|
! grep again message &&
|
|
git -C three log -1 --pretty=format:%s >message &&
|
|
grep again message
|
|
'
|
|
|
|
test_expect_success 'do nothing on empty config' '
|
|
# the whole thing would fail if for-each-ref iterated even
|
|
# once, because "git help --no-such-option" would fail
|
|
git for-each-repo --config=bogus.config -- help --no-such-option
|
|
'
|
|
|
|
test_done
|