[PATCH 2/3] t0033-safe-directory: check when 'safe.directory' is ignored
- From
SZEDER Gábor <szeder.dev@gmail.com>
- Date
- Apr 27, 2022, 17:06 UTC
- Message-ID
- <20220427170649.4949-3-szeder.dev@gmail.com>
- In-Reply-To
- <20220427170649.4949-1-szeder.dev@gmail.com>
According to the documentation 'safe.directory' "is only respected when specified in a system or global config, not when it is specified in a repository config or via the command line option -c safe.directory=<path>".
Add tests to check that 'safe.directory' in the repository config or on the command line is indeed ignored.
Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com> --- t/t0033-safe-directory.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+)
diff --git a/t/t0033-safe-directory.sh b/t/t0033-safe-directory.sh index 6f9680e8b0..82dac0eb93 100755 --- a/t/t0033-safe-directory.sh +++ b/t/t0033-safe-directory.sh @@ -16,6 +16,19 @@ 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 "unsafe repository" err +' + +test_expect_success 'ignoring safe.directory in repo config' ' + ( + unset GIT_TEST_ASSUME_DIFFERENT_OWNER && + git config safe.directory "$(pwd)" + ) && + expect_rejected_dir +' + test_expect_success 'safe.directory does not match' ' git config --global safe.directory bogus && expect_rejected_dir
-- 2.36.0.676.gf39b21ed98