Subject: Re: [RFC PATCH v3 1/3] t: document regression git safe.directory when using sudo

From: Junio C Hamano <[email-masked]>
Date: Mon, 02 May 2022 14:35:33 -0700

Carlo Marcelo Arenas Belón  <[email-masked]> writes:

> +test_lazy_prereq SUDO '
> +	sudo -n id -u >u &&
> +	id -u root >r &&
> +	test_cmp u r &&

OK.  We make sure we can become root with "sudo".

> +	command -v git >u &&
> +	sudo command -v git >r &&
> +	test_cmp u r

While this is not as thorough as the "make sure we see the
environment intact" that I alluded to during the previous review, it
at least makes sure PATH (which our test framework tweaks) is
propagated down to "sudo" environment intact, which should be good
enough to run just "init" and "status".  Keeping things simple is
good.

We may have to exclude this from tests that require specialized
environment like valgrind tests, but that is not of immediate
concern.

Will queue.

> +'
> +
> +test_expect_success SUDO 'setup' '
> +	sudo rm -rf root &&
> +	mkdir -p root/r &&
> +	sudo chown root root &&
> +	(
> +		cd root/r &&
> +		git init
> +	)
> +'
> +
> +test_expect_failure SUDO 'sudo git status as original owner' '
> +	(
> +		cd root/r &&
> +		git status &&
> +		sudo git status
> +	)
> +'
> +
> +# this MUST be always the last test
> +test_expect_success SUDO 'cleanup' '
> +	sudo rm -rf root
> +'
> +
> +test_done