From: Michael J Gruber Date: Wed, 25 Feb 2009 13:26:32 GMT Subject: [PATCHv2 4/4] git submodule: Fix handling of // and /.. in paths for added submodules Message-ID: <1235568392-19705-5-git-send-email-git@drmicha.warpmail.net> In-Reply-To: <1235568392-19705-4-git-send-email-git@drmicha.warpmail.net> This hopefully brings "git submodule add"'s parsing of paths in line with "git submodule init"'s (which uses "git ls-files"), at least for practical purposes. It fixes 2 known breakages which are marked "success" now. Signed-off-by: Michael J Gruber --- git-submodule.sh | 6 ++++++ t/t7400-submodule-basic.sh | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/git-submodule.sh b/git-submodule.sh index 4f26be4..375362e 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -167,6 +167,12 @@ cmd_add() ;; esac + # simplify multiple / + path=$(echo "$path" | sed -e 's|/\+|/|g') + + # resolve /.. (add trailing / for matching /..$) + path=$(echo "$path/" | sed -e 's|\([^/]*\)/../||g') + # strip superfluous ./ from path path=$(echo "$path" | sed -e 's|^\(\./\)*||' -e's|/\./|/|g') diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh index 21bdfeb..473d0e8 100755 --- a/t/t7400-submodule-basic.sh +++ b/t/t7400-submodule-basic.sh @@ -64,12 +64,12 @@ test_expect_success 'submodule add with ./ in path' ' git submodule init ' -test_expect_failure 'submodule add with // in path' ' +test_expect_success 'submodule add with // in path' ' git submodule add "$submodurl" slashslashsubmod///frotz// && git submodule init ' -test_expect_failure 'submodule add with /.. in path' ' +test_expect_success 'submodule add with /.. in path' ' git submodule add "$submodurl" dotdotsubmod/../realsubmod/frotz/.. && git submodule init ' -- 1.6.2.rc1.30.gd43c