[PATCH 1/3] t0033-safe-directory: check the error message without matching the trash dir
- From
SZEDER Gábor <szeder.dev@gmail.com>
- Date
- Apr 27, 2022, 17:06 UTC
- Message-ID
- <20220427170649.4949-2-szeder.dev@gmail.com>
- In-Reply-To
- <20220427170649.4949-1-szeder.dev@gmail.com>
Since 8959555cee (setup_git_directory(): add an owner check for the top-level directory, 2022-03-02) when git finds itself in a repository owned by someone else, it aborts with a "fatal: unsafe repository (<repo path>)" error message and an advice about how to set the 'safe.directory' config variable to mark that repository as safe. 't0033-safe-directory.sh' contains tests that check that this feature and handling said config work as intended. To ensure that git dies for the right reason, several of those tests check that its standard error contains the name of that config variable, but:
- it only appears in the advice part, not in the actual error
message. - it is interpreted as a regexp by 'grep', so, because of the dot,
it matches the name of the test script and the path of the trash
directory as well. Consequently, these tests could be fooled by
any error message that would happen to include the path of the
test repository.Tighten these checks to look for "unsafe repository" instead.
Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com> --- t/t0033-safe-directory.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/t/t0033-safe-directory.sh b/t/t0033-safe-directory.sh index 239d93f4d2..6f9680e8b0 100755 --- a/t/t0033-safe-directory.sh +++ b/t/t0033-safe-directory.sh @@ -9,7 +9,7 @@ export GIT_TEST_ASSUME_DIFFERENT_OWNER expect_rejected_dir () { test_must_fail git status 2>err && - grep "safe.directory" err + grep "unsafe repository" err } test_expect_success 'safe.directory is not set' '
-- 2.36.0.676.gf39b21ed98