]> git.phdru.name Git - git-scripts.git/blob - submodules/unabsorbgitdirs-recursive
Add scripts to unabsorb git dirs
[git-scripts.git] / submodules / unabsorbgitdirs-recursive
1 #! /bin/sh
2 # The script cannot be run with `git submodule foreach --recursive`
3 # because the command runs recursively from top to bottom
4 # while the command is required to be run from bottom to top
5 # because it doesn't fix childrens' gitlinks.
6 # So the script runs recursion itself;
7 # it can be run with `git submodule foreach` without `--recursive`.
8 set -e
9
10 START_DIR="`pwd`"
11 cd "`dirname \"$0\"`"
12 PROG_DIR="`pwd`"
13 cd "$START_DIR"
14
15 # To the top-level directory of the current submodule or the superproject
16 cd "`git rev-parse --show-toplevel`"
17
18 unset GIT_DIR
19
20 # If .git/ subdirectory is already here
21 test -d .git && exit 0
22
23 if ! test -f .git; then
24     echo "Error: Cannot find gitlink, aborting" >&2
25     exit 1
26 fi
27
28 if test -f .gitmodules; then
29     git submodule foreach "$PROG_DIR"/"`basename \"$0\"`"
30 fi
31
32 # Fix core.worktree now
33 git config --unset core.worktree
34
35 read _gitdir gitpath < .git
36 unset _gitdir
37 rm .git
38 exec mv "$gitpath" .git