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`.
15 # To the top-level directory of the current submodule or the superproject
16 cd "`git rev-parse --show-toplevel`"
20 # If .git/ subdirectory is already here
21 test -d .git && exit 0
23 if ! test -f .git; then
24 echo "Error: Cannot find gitlink, aborting" >&2
28 if test -f .gitmodules; then
29 git submodule foreach "$PROG_DIR"/"`basename \"$0\"`"
32 # Fix core.worktree now
33 git config --unset core.worktree
35 read _gitdir gitpath < .git
38 exec mv "$gitpath" .git