git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] lib-submodule-update.sh: drop unneeded shell

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 13, 2017, 18:40 UTC
Message-ID
<xmqqtw92hkgc.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20170111184732.26416-1-sbeller@google.com>
Stefan Beller <sbeller@google.com> writes:
> In modern Git we prefer "git -C <cmd" over "(cd <somewhere && git <cmd>)"
> as it doesn't need an extra shell.

There is a matching '>' missing. The description is correct (I am not sure if there actually is "preference", though), but I found the title a bit misleading. With 'drop unneeded subshell', I would imagine a patch like

		(
	-		( do something )
	+		do something;
			do something else;
		)

It looks more like "reduce use of subshell by using 'git -C <dir>'" to me.

> And because it is in a setup function, we actually save the invocation
> of 22 shells for a single run of the whole test suite.
Nice.
Show 26 quoted lines
>
> Noticed while adding a lot more in near vincinity, though not as near
> to cause merge conflicts, so sending it extra.
>
> Thanks,
> Stefan
>
>  t/lib-submodule-update.sh | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/t/lib-submodule-update.sh b/t/lib-submodule-update.sh
> index 79cdd34a54..915eb4a7c6 100755
> --- a/t/lib-submodule-update.sh
> +++ b/t/lib-submodule-update.sh
> @@ -69,10 +69,7 @@ create_lib_submodule_repo () {
>  
>  		git checkout -b "replace_sub1_with_directory" "add_sub1" &&
>  		git submodule update &&
> -		(
> -			cd sub1 &&
> -			git checkout modifications
> -		) &&
> +		git -C sub1 checkout modifications &&
>  		git rm --cached sub1 &&
>  		rm sub1/.git* &&
>  		git config -f .gitmodules --remove-section "submodule.sub1" &&
Previous: Stefan BellerNext: Stefan Beller
Message 2 of 6 in “lib-submodule-update.sh: drop unneeded shell”
  1. lib-submodule-update.sh: drop unneeded shellStefan Beller, Jan 11, 2017
  2. Junio C HamanoJan 13, 2017
  3. lib-submodule-update.sh: reduce use of subshell by using git -C <dir>Stefan Beller, Jan 13, 2017
  4. Junio C HamanoJan 13, 2017
  5. Stefan BellerJan 13, 2017
  6. Junio C HamanoJan 13, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.