lib-submodule-update.sh: reduce use of subshell by using "git -C"
authorStefan Beller <sbeller@google.com>
Wed, 11 Jan 2017 18:47:32 +0000 (10:47 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 13 Jan 2017 20:02:51 +0000 (12:02 -0800)
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. Modern version of Git
allows us to do this more concisely with "git -C <dir> <cmd>".

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/lib-submodule-update.sh
index 79cdd34a540ddc7230b1aefb7fb4af5915c7085f..915eb4a7c65ca5c574beddc676bf0115990eec3f 100755 (executable)
@@ -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" &&