From: Oleg Broytman Date: Sat, 16 Nov 2024 21:32:36 +0000 (+0300) Subject: Refactor(submodules/remove): Get `GIT_DIR` once X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=c6af4d8f974b605bc83c722510f4f87c41c0a05f;p=git-scripts.git Refactor(submodules/remove): Get `GIT_DIR` once Call `git rev-parse --git-dir` once. Also replace `$()` with backticks. --- 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