]> git.phdru.name Git - git-scripts.git/blobdiff - submodules/unabsorbgitdirs
Add scripts to unabsorb git dirs
[git-scripts.git] / submodules / unabsorbgitdirs
diff --git a/submodules/unabsorbgitdirs b/submodules/unabsorbgitdirs
new file mode 100755 (executable)
index 0000000..2416477
--- /dev/null
@@ -0,0 +1,23 @@
+#! /bin/sh
+set -e
+
+# To the top-level directory of the current submodule
+cd "`git rev-parse --show-toplevel`"
+
+unset GIT_DIR
+
+# If .git/ subdirectory is already here
+test -d .git && exit 0
+
+if ! test -f .git; then
+    echo "Error: Cannot find gitlink, aborting" >&2
+    exit 1
+fi
+
+# Fix core.worktree now
+git config --unset core.worktree
+
+read _gitdir gitpath < .git
+unset _gitdir
+rm .git
+exec mv "$gitpath" .git