From 1017c1abcb6d733e1de83eb5a1cf7e1bf4ad6aca Mon Sep 17 00:00:00 2001 From: Jens Lehmann Date: Tue, 24 Jan 2012 22:49:56 +0100 Subject: submodule add: fix breakage when re-adding a deep submodule Since recently a submodule with name has its git directory in the .git/modules/ directory of the superproject while the work tree contains a gitfile pointing there. When the same submodule is added on a branch where it wasn't present so far (it is not found in the .gitmodules file), the name is not initialized from the path as it should. This leads to a wrong path entered in the gitfile when the .git/modules/ directory is found, as this happily uses the - now empty - name. It then always points only a single directory up, even if we have a path deeper in the directory hierarchy. Fix that by initializing the name of the submodule early in module_clone() if module_name() returned an empty name and add a test to catch that bug. Reported-by: Jehan Bing Signed-off-by: Jens Lehmann Signed-off-by: Junio C Hamano --- git-submodule.sh | 1 + 1 file changed, 1 insertion(+) (limited to 'git-submodule.sh') diff --git a/git-submodule.sh b/git-submodule.sh index 3adab9363..9bb2e13e9 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -131,6 +131,7 @@ module_clone() gitdir= gitdir_base= name=$(module_name "$path" 2>/dev/null) + test -n "$name" || name="$path" base_path=$(dirname "$path") gitdir=$(git rev-parse --git-dir) -- cgit v1.2.1