From c6af4d8f974b605bc83c722510f4f87c41c0a05f Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sun, 17 Nov 2024 00:32:36 +0300 Subject: [PATCH] Refactor(submodules/remove): Get `GIT_DIR` once Call `git rev-parse --git-dir` once. Also replace `$()` with backticks. --- submodules/remove | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/submodules/remove b/submodules/remove index f9436ce..4906a0b 100755 --- a/submodules/remove +++ b/submodules/remove @@ -18,7 +18,7 @@ if [ \! -f .gitmodules ]; then fi name="$1" -path="$(git config -f .gitmodules --get "submodule.$name.path")" +path="`git config -f .gitmodules --get "submodule.$name.path"`" if [ -z "$path" ]; then echo "Error: submodule $name does not exist" >&2 @@ -26,13 +26,14 @@ if [ -z "$path" ]; then fi git rm $cached "$path" && -rm -rf "`git rev-parse --git-dir`"/modules/"$name" && +GIT_DIR=`git rev-parse --git-dir` && +rm -rf "$GIT_DIR"/modules/"$name" && git config --remove-section submodule."$name" && if [ \! -s .gitmodules ]; then git rm -f .gitmodules fi && -if [ -z $(ls -A "`git rev-parse --git-dir`/modules") ]; then - exec rmdir "`git rev-parse --git-dir`/modules" +if [ -z `ls -A "$GIT_DIR/modules"` ]; then + exec rmdir "$GIT_DIR/modules" fi -- 2.39.5