mirror of
https://github.com/git/git.git
synced 2024-12-04 07:24:41 +08:00
ecec57b3c9
Protected config is implemented by reading a fixed set of paths,
which ignores config [include]-s. Replace this implementation with a
call to config_with_options(), which handles [include]-s and saves us
from duplicating the logic of 1) identifying which paths to read and 2)
reading command line config.
As a result, git_configset_add_parameters() is unused, so remove it. It
was introduced alongside protected config in 5b3c650777
(config: learn
`git_protected_config()`, 2022-07-14) as a way to handle command line
config.
Signed-off-by: Glen Choo <chooglen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
64 lines
1.6 KiB
Bash
Executable File
64 lines
1.6 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
test_description='verify safe.bareRepository checks'
|
|
|
|
TEST_PASSES_SANITIZE_LEAK=true
|
|
. ./test-lib.sh
|
|
|
|
pwd="$(pwd)"
|
|
|
|
expect_accepted () {
|
|
git "$@" rev-parse --git-dir
|
|
}
|
|
|
|
expect_rejected () {
|
|
test_must_fail git "$@" rev-parse --git-dir 2>err &&
|
|
grep -F "cannot use bare repository" err
|
|
}
|
|
|
|
test_expect_success 'setup bare repo in worktree' '
|
|
git init outer-repo &&
|
|
git init --bare outer-repo/bare-repo
|
|
'
|
|
|
|
test_expect_success 'safe.bareRepository unset' '
|
|
expect_accepted -C outer-repo/bare-repo
|
|
'
|
|
|
|
test_expect_success 'safe.bareRepository=all' '
|
|
test_config_global safe.bareRepository all &&
|
|
expect_accepted -C outer-repo/bare-repo
|
|
'
|
|
|
|
test_expect_success 'safe.bareRepository=explicit' '
|
|
test_config_global safe.bareRepository explicit &&
|
|
expect_rejected -C outer-repo/bare-repo
|
|
'
|
|
|
|
test_expect_success 'safe.bareRepository in the repository' '
|
|
# safe.bareRepository must not be "explicit", otherwise
|
|
# git config fails with "fatal: not in a git directory" (like
|
|
# safe.directory)
|
|
test_config -C outer-repo/bare-repo safe.bareRepository \
|
|
all &&
|
|
test_config_global safe.bareRepository explicit &&
|
|
expect_rejected -C outer-repo/bare-repo
|
|
'
|
|
|
|
test_expect_success 'safe.bareRepository on the command line' '
|
|
test_config_global safe.bareRepository explicit &&
|
|
expect_accepted -C outer-repo/bare-repo \
|
|
-c safe.bareRepository=all
|
|
'
|
|
|
|
test_expect_success 'safe.bareRepository in included file' '
|
|
cat >gitconfig-include <<-\EOF &&
|
|
[safe]
|
|
bareRepository = explicit
|
|
EOF
|
|
git config --global --add include.path "$(pwd)/gitconfig-include" &&
|
|
expect_rejected -C outer-repo/bare-repo
|
|
'
|
|
|
|
test_done
|