summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2022-07-22 22:04:01 (GMT)
committerJunio C Hamano <gitster@pobox.com>2022-07-22 22:04:02 (GMT)
commit18bbc795fc52dc543e279c213fd1bfe27afc6092 (patch)
tree64f5824d95f3b7aa055e7eb14c975333d4db8c21 /t
parente72d93e88cb20b06e88e6e7d81bd1dc4effe453f (diff)
parent8d1a7448206e11cdea657c35b04cc49db39be933 (diff)
downloadgit-18bbc795fc52dc543e279c213fd1bfe27afc6092.zip
git-18bbc795fc52dc543e279c213fd1bfe27afc6092.tar.gz
git-18bbc795fc52dc543e279c213fd1bfe27afc6092.tar.bz2
Merge branch 'gc/bare-repo-discovery'
Introduce a discovery.barerepository configuration variable that allows users to forbid discovery of bare repositories. * gc/bare-repo-discovery: setup.c: create `safe.bareRepository` safe.directory: use git_protected_config() config: learn `git_protected_config()` Documentation: define protected configuration Documentation/git-config.txt: add SCOPES section
Diffstat (limited to 't')
-rwxr-xr-xt/t0033-safe-directory.sh24
-rwxr-xr-xt/t0035-safe-bare-repository.sh54
-rwxr-xr-xt/t5544-pack-objects-hook.sh7
3 files changed, 70 insertions, 15 deletions
diff --git a/t/t0033-safe-directory.sh b/t/t0033-safe-directory.sh
index 3908597..f4d737d 100755
--- a/t/t0033-safe-directory.sh
+++ b/t/t0033-safe-directory.sh
@@ -16,24 +16,20 @@ test_expect_success 'safe.directory is not set' '
expect_rejected_dir
'
-test_expect_success 'ignoring safe.directory on the command line' '
- test_must_fail git -c safe.directory="$(pwd)" status 2>err &&
- grep "dubious ownership" err
+test_expect_success 'safe.directory on the command line' '
+ git -c safe.directory="$(pwd)" status
'
-test_expect_success 'ignoring safe.directory in the environment' '
- test_must_fail env GIT_CONFIG_COUNT=1 \
- GIT_CONFIG_KEY_0="safe.directory" \
- GIT_CONFIG_VALUE_0="$(pwd)" \
- git status 2>err &&
- grep "dubious ownership" err
+test_expect_success 'safe.directory in the environment' '
+ env GIT_CONFIG_COUNT=1 \
+ GIT_CONFIG_KEY_0="safe.directory" \
+ GIT_CONFIG_VALUE_0="$(pwd)" \
+ git status
'
-test_expect_success 'ignoring safe.directory in GIT_CONFIG_PARAMETERS' '
- test_must_fail env \
- GIT_CONFIG_PARAMETERS="${SQ}safe.directory${SQ}=${SQ}$(pwd)${SQ}" \
- git status 2>err &&
- grep "dubious ownership" err
+test_expect_success 'safe.directory in GIT_CONFIG_PARAMETERS' '
+ env GIT_CONFIG_PARAMETERS="${SQ}safe.directory${SQ}=${SQ}$(pwd)${SQ}" \
+ git status
'
test_expect_success 'ignoring safe.directory in repo config' '
diff --git a/t/t0035-safe-bare-repository.sh b/t/t0035-safe-bare-repository.sh
new file mode 100755
index 0000000..ecbdc82
--- /dev/null
+++ b/t/t0035-safe-bare-repository.sh
@@ -0,0 +1,54 @@
+#!/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_done
diff --git a/t/t5544-pack-objects-hook.sh b/t/t5544-pack-objects-hook.sh
index dd5f44d..54f54f8 100755
--- a/t/t5544-pack-objects-hook.sh
+++ b/t/t5544-pack-objects-hook.sh
@@ -56,7 +56,12 @@ test_expect_success 'hook does not run from repo config' '
! grep "hook running" stderr &&
test_path_is_missing .git/hook.args &&
test_path_is_missing .git/hook.stdin &&
- test_path_is_missing .git/hook.stdout
+ test_path_is_missing .git/hook.stdout &&
+
+ # check that global config is used instead
+ test_config_global uploadpack.packObjectsHook ./hook &&
+ git clone --no-local . dst2.git 2>stderr &&
+ grep "hook running" stderr
'
test_expect_success 'hook works with partial clone' '