]> git.phdru.name Git - git-scripts.git/blob - submodules/unabsorbgitdirs
Feat(submodules/remove): Add option `-c`
[git-scripts.git] / submodules / unabsorbgitdirs
1 #! /bin/sh
2 # See https://stackoverflow.com/a/77950870/7976758
3 set -e
4
5 # To the top-level directory of the current submodule
6 cd "`git rev-parse --show-toplevel`"
7
8 unset GIT_DIR
9
10 # If .git/ subdirectory is already here
11 [ -d .git ] && exit 0
12
13 if ! [ -f .git ]; then
14     echo "Error: Cannot find gitlink, aborting" >&2
15     exit 1
16 fi
17
18 # Fix core.worktree now
19 git config --unset core.worktree
20
21 read _gitdir gitpath < .git
22 if [ "$_gitdir" != gitdir: ]; then
23     echo "Error: Bad gitlink, aborting" >&2
24     exit 1
25 fi
26 unset _gitdir
27 rm .git
28 exec mv "$gitpath" .git