Re: [PATCH 1/3] t0033: add tests for safe.directory
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Apr 13, 2022, 16:24 UTC
- Message-ID
- <xmqqwnft9cjg.fsf@gitster.g>
- In-Reply-To
- <5b18bd1852d673ab5c62a67f873987d74294cd70.1649863951.git.gitgitgadget@gmail.com>
"Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 6 quoted lines
> From: Derrick Stolee <derrickstolee@github.com> > > It is difficult to change the ownership on a directory in our test > suite, so insert a new GIT_TEST_ASSUME_DIFFERENT_OWNER environment > variable to trick Git into thinking we are in a differently-owned > directory. This allows us to test that the config is parsed correctly.
OK.
> - if (is_path_owned_by_current_user(path))
> + if (is_path_owned_by_current_user(path) &&
> + !git_env_bool("GIT_TEST_ASSUME_DIFFERENT_OWNER", 0))
> return 1;Shouldn't the overriding "GIT_TEST_BLAH" be checked before the real logic kicks in, I wonder?
Show 24 quoted lines
> diff --git a/t/t0033-safe-directory.sh b/t/t0033-safe-directory.sh
> new file mode 100755
> index 00000000000..9380ff3d017
> --- /dev/null
> +++ b/t/t0033-safe-directory.sh
> @@ -0,0 +1,34 @@
> +#!/bin/sh
> +
> +test_description='verify safe.directory checks'
> +
> +. ./test-lib.sh
> +
> +GIT_TEST_ASSUME_DIFFERENT_OWNER=1
> +export GIT_TEST_ASSUME_DIFFERENT_OWNER
> +
> +expect_rejected_dir () {
> + test_must_fail git status 2>err &&
> + grep "safe.directory" err
> +}
> +...
> +test_expect_success 'safe.directory matches' '
> + git config --global --add safe.directory "$(pwd)" &&
> + git status
> +'Just double checking, as I know you are much closer to the affected platform than I'd ever be ;-) but is the use of $(pwd) safe and correct here?
I always get confused between $(pwd) and $PWD, which does not make any difference on platforms I have access to, but makes difference to hurt Windows users.
Show 6 quoted lines
> +test_expect_success 'safe.directory matches, but is reset' ' > + git config --global --add safe.directory "" && > + expect_rejected_dir > +' > + > +test_done
Thanks. This step should apply to maint-2.30 cleanly, I would think.