summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ac8463d)
raw | patch | inline | side by side (parent: ac8463d)
author | Michael J Gruber <git@drmicha.warpmail.net> | |
Tue, 3 Mar 2009 15:08:21 +0000 (16:08 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 4 Mar 2009 05:46:09 +0000 (21:46 -0800) |
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.
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
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.
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-submodule.sh | patch | blob | history | |
t/t7400-submodule-basic.sh | patch | blob | history |
diff --git a/git-submodule.sh b/git-submodule.sh
index 2f47e065fe8b7ca856f4527d6a507a28f1b2a06b..68d6afd15c94844c2435b65a197d678aa52314c9 100755 (executable)
--- a/git-submodule.sh
+++ b/git-submodule.sh
;;
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|\([^/]*\)/\.\./||
+ tstart
+ s|/*$||
+ ')
git ls-files --error-unmatch "$path" > /dev/null 2>&1 &&
die "'$path' already exists in the index"
index 132d0b996375ed4b884df36b98a4460d7cc42c58..21c19a28cfdcef1478a97168cae8b6d6cae597a1 100755 (executable)
)
'
-test_expect_failure 'submodule add with ./ in path' '
+test_expect_success 'submodule add with ./ in path' '
(
cd addtest &&
git submodule add "$submodurl" ././dotsubmod/./frotz/./ &&
)
'
-test_expect_failure 'submodule add with // in path' '
+test_expect_success 'submodule add with // in path' '
(
cd addtest &&
git submodule add "$submodurl" slashslashsubmod///frotz// &&
)
'
-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/.. &&
)
'
-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/a/b/c/d/../../../../frotz//.. &&