On Wed, Apr 13 2022, Derrick Stolee via GitGitGadget wrote: > From: Derrick Stolee <derrickstolee@xxxxxxxxxx> > > 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. I think this is a good trade-off, but FWIW I'd think we could test also without the git_env_bool() by having the test depend on !NOT_ROOT, then check the owner of t/test-lib.sh, and chown to that user (i.e. the "real" user). But that's all sorts of more fragile than just this test variable.. > +test_description='verify safe.directory checks' > + > +. ./test-lib.sh > + > +GIT_TEST_ASSUME_DIFFERENT_OWNER=1 > +export GIT_TEST_ASSUME_DIFFERENT_OWNER Instead of this "export" perhaps just add it in front of the "git status"? These tests also pass with SANITIZE=leak, so please add TEST_PASSES_SANITIZE_LEAK=true at the top. > +expect_rejected_dir () { > + test_must_fail git status 2>err && > + grep "safe.directory" err > +} > + > +test_expect_success 'safe.directory is not set' ' > + expect_rejected_dir > +' > + > +test_expect_success 'safe.directory does not match' ' > + git config --global safe.directory bogus && > + expect_rejected_dir > +' > + > +test_expect_success 'safe.directory matches' ' > + git config --global --add safe.directory "$(pwd)" && nit: $PWD instead of $(pwd)