Make 'git submodule add' normalize the submodule path in the same way as 'git ls-files' does, so that 'git submodule init' looks up the information in .gitmodules with the same key under which 'git submodule add' stores it. This fixes 4 known breakages. --- Note that sed on AIX does not like comments, which is why they are not in the sed expression. git-submodule.sh | 15 ++++++++++++--- t/t7400-submodule-basic.sh | 8 ++++---- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/git-submodule.sh b/git-submodule.sh index 204aab6..7a25f47 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -167,9 +167,18 @@ cmd_add() ;; esac - # strip trailing slashes from path - path=$(echo "$path" | sed -e 's|/*$||') - + # normalize path: + # multiple //; leading ./; /./; /../; trailing / + path=$(printf '%s/\n' "$path" | + sed -e ' + s|//*|/|g + s|^\(\./\)*|| + s|/\./|/|g + :start + s|\([^/]*\)/\.\./||g + tstart + s|/*$|| + ') git ls-files --error-unmatch "$path" > /dev/null 2>&1 && die "'$path' already exists in the index" diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh index 4f42585..1c82f8c 100755 --- a/t/t7400-submodule-basic.sh +++ b/t/t7400-submodule-basic.sh @@ -64,7 +64,7 @@ test_expect_success 'submodule add' ' ) ' -test_expect_failure 'submodule add with ./ in path' ' +test_expect_success 'submodule add with ./ in path' ' ( cd addtest && git submodule add "$submodurl" ././dotsubmod/./frotz/./ && @@ -72,7 +72,7 @@ test_expect_failure 'submodule add with ./ in path' ' ) ' -test_expect_failure 'submodule add with // in path' ' +test_expect_success 'submodule add with // in path' ' ( cd addtest && git submodule add "$submodurl" slashslashsubmod///frotz// && @@ -80,7 +80,7 @@ test_expect_failure 'submodule add with // in path' ' ) ' -test_expect_failure 'submodule add with /.. in path' ' +test_expect_success 'submodule add with /.. in path' ' ( cd addtest && git submodule add "$submodurl" dotdotsubmod/../realsubmod/frotz/.. && @@ -88,7 +88,7 @@ test_expect_failure 'submodule add with /.. in path' ' ) ' -test_expect_failure 'submodule add with ./, /.. and // in path' ' +test_expect_success 'submodule add with ./, /.. and // in path' ' ( cd addtest && git submodule add "$submodurl" dot/dotslashsubmod/./../..////realsubmod2/frotz//.. && -- 1.6.2.rc2 -- 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