This fixes a problem where moving a git repository with checked-out submodules would cause a fatal error when commands such as 'git submodule update' were run. Git submoule clone uses git clone --separate-git-dir to checkout a submodule's git repository into <supermodule>/.git/modules, if this folder does not already exist. git clone --separate-git-dir was designed for a scenario where the git repository stays in one location and the working copy can be moved. Therefore the .git file in the working copy uses an absolute path to specify the location of the repository. In the submodules scenario, neither the git repository nor the working copy will be moved relative to each other. However, the supermodule may be moved, which moves both the submodule's git repository and its working copy. This means that the submodule's .git file no longer points to its repository, causing the error. Previously, if git submodule clone was called when the submodule's git repository already existed in <supermodule>/.git/modules, it would simply re-create the submodule's .git file, using a relative path. This patch uses the above mechanism to re-write the .git file after git clone --separate-git-dir is run, replacing the absolute path with a relative one. An alternative patch would teach git-clone an option to control whether an absolute or relative path is used when --separate-git-dir is passed. Signed-off-by: Antony Male <antony.male@xxxxxxxxx> --- git-submodule.sh | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/git-submodule.sh b/git-submodule.sh index 3adab93..18eb5ff 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -159,7 +159,6 @@ module_clone() if test -d "$gitdir" then mkdir -p "$path" - echo "gitdir: $rel_gitdir" >"$path/.git" rm -f "$gitdir/index" else mkdir -p "$gitdir_base" @@ -171,6 +170,7 @@ module_clone() fi || die "$(eval_gettext "Clone of '\$url' into submodule path '\$path' failed")" fi + echo "gitdir: $rel_gitdir" >"$path/.git" } # -- 1.7.8 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html