Merge branch 'ps/submodule-sanitize-path-upon-add'
authorJunio C Hamano <gitster@pobox.com>
Sun, 22 Feb 2015 20:28:26 +0000 (12:28 -0800)
committerJunio C Hamano <gitster@pobox.com>
Sun, 22 Feb 2015 20:28:26 +0000 (12:28 -0800)
"git submodule add" failed to squash "path/to/././submodule" to
"path/to/submodule".

* ps/submodule-sanitize-path-upon-add:
git-submodule.sh: fix '/././' path normalization

git-submodule.sh
t/t7400-submodule-basic.sh
index 9245abfd4263881bdd6d0f21f648b46201b52a2d..36797c3c00f4890cfb6f176f298e050da7eb5a34 100755 (executable)
@@ -423,7 +423,7 @@ cmd_add()
                sed -e '
                        s|//*|/|g
                        s|^\(\./\)*||
-                       s|/\./|/|g
+                       s|/\(\./\)*|/|g
                        :start
                        s|\([^/]*\)/\.\./||
                        tstart
index 7c882450317b85ffdeabc105ee62a18ce3b04ca9..5811a982f472e3b79f31cc50dcdef92dcdb4a58c 100755 (executable)
@@ -171,6 +171,23 @@ test_expect_success 'submodule add with ./ in path' '
        test_cmp empty untracked
 '
 
+test_expect_success 'submodule add with /././ in path' '
+       echo "refs/heads/master" >expect &&
+       >empty &&
+
+       (
+               cd addtest &&
+               git submodule add "$submodurl" dotslashdotsubmod/././frotz/./ &&
+               git submodule init
+       ) &&
+
+       rm -f heads head untracked &&
+       inspect addtest/dotslashdotsubmod/frotz ../../.. &&
+       test_cmp expect heads &&
+       test_cmp expect head &&
+       test_cmp empty untracked
+'
+
 test_expect_success 'submodule add with // in path' '
        echo "refs/heads/master" >expect &&
        >empty &&