]> git.phdru.name Git - git-scripts.git/blobdiff - submodules/unabsorbgitdirs
Feat(submodules/remove): Add option `-c`
[git-scripts.git] / submodules / unabsorbgitdirs
index 2416477c05c4b7716b53ae34fc3ec715d0211b6e..53cd46dab2764444d9c8fa23c7729627c8ca9c80 100755 (executable)
@@ -1,4 +1,5 @@
 #! /bin/sh
+# See https://stackoverflow.com/a/77950870/7976758
 set -e
 
 # To the top-level directory of the current submodule
@@ -7,9 +8,9 @@ cd "`git rev-parse --show-toplevel`"
 unset GIT_DIR
 
 # If .git/ subdirectory is already here
-test -d .git && exit 0
+[ -d .git ] && exit 0
 
-if ! test -f .git; then
+if ! [ -f .git ]; then
     echo "Error: Cannot find gitlink, aborting" >&2
     exit 1
 fi
@@ -18,6 +19,10 @@ fi
 git config --unset core.worktree
 
 read _gitdir gitpath < .git
+if [ "$_gitdir" != gitdir: ]; then
+    echo "Error: Bad gitlink, aborting" >&2
+    exit 1
+fi
 unset _gitdir
 rm .git
 exec mv "$gitpath" .git