Re: [PATCH] lib-submodule-update.sh: drop unneeded shell
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jan 13, 2017, 19:55 UTC
- Message-ID
- <xmqqa8auhgzt.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <xmqqtw92hkgc.fsf@gitster.mtv.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 8 quoted lines
> 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....
It turns out that there were two missing '>' ;-) It tentatively has become like this in my tree.
-- >8 -- From: Stefan Beller <sbeller@google.com> Date: Wed, 11 Jan 2017 10:47:32 -0800 Subject: [PATCH] lib-submodule-update.sh: reduce use of subshell by using "git -C"
We write
(cd <dir> && git <cmd>)
to avoid
cd <dir> && git <cmd> && cd ..
that allows a breakage in one part of the test script to leave the entire test process in an unexpected place. We can do this more concisely with "git -C <dir> <cmd>" with modern Git.
Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
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" &&