# 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`"
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