Subject: Re: [PATCH 06/10] hook tests: get rid of unnecessary sub-shells

From: Junio C Hamano <[email-masked]>
Date: Wed, 02 Mar 2022 13:31:18 -0800

Ævar Arnfjörð Bjarmason  <[email-masked]> writes:

> Refactor the repository setup code for tests that test hooks the use
> of sub-shells when setting up the test repository and hooks.
>
> A subsequent commit will change the hook setup to use a helper that
> makes use of "test_when_finished", which cannot be used in
> sub-shells. Let's change that setup code, and the adjacent and similar
> "mk_empty" code.

Makes sense.

> diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
> index 1a20e54adc1..e4bb7581568 100755
> --- a/t/t5516-fetch-push.sh
> +++ b/t/t5516-fetch-push.sh
> @@ -24,12 +24,8 @@ D=$(pwd)
>  mk_empty () {
>  	repo_name="$1"
>  	rm -fr "$repo_name" &&
> -	mkdir "$repo_name" &&
> -	(
> -		cd "$repo_name" &&
> -		git init &&
> -		git config receive.denyCurrentBranch warn
> -	)
> +	git init "$repo_name" &&
> +	git -C "$repo_name" config receive.denyCurrentBranch warn
>  }

I thought of this exact change when I saw a change to this part in
this series in an earlier step.  Excellent.