X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=submodules%2Funabsorbgitdirs-recursive;h=bd1f10d789078e46b22eedfaed6adb48e0299af0;hb=HEAD;hp=72b4464a6ceb8ba54acc8eb3d4fd12b462b2fdb8;hpb=99f22d0045c5002c384a599cc0f0b203f429eedf;p=git-scripts.git diff --git a/submodules/unabsorbgitdirs-recursive b/submodules/unabsorbgitdirs-recursive index 72b4464..bd1f10d 100755 --- a/submodules/unabsorbgitdirs-recursive +++ b/submodules/unabsorbgitdirs-recursive @@ -5,6 +5,7 @@ # because it doesn't fix childrens' gitlinks. # So the script runs recursion itself; # it can be run with `git submodule foreach` without `--recursive`. +# See https://stackoverflow.com/a/77950870/7976758 set -e START_DIR="`pwd`" @@ -18,14 +19,14 @@ 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 -if test -f .gitmodules; then +if [ -f .gitmodules ]; then git submodule foreach "$PROG_DIR"/"`basename \"$0\"`" fi @@ -33,6 +34,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