git-submodule.sh: fix '/././' path normalization

When we add a new submodule the path of the submodule is being normalized. We fail to normalize multiple adjacent '/./', though. Thus 'path/to/././submodule' will become 'path/to/./submodule' where it should be 'path/to/submodule' instead. Signed-off-by: Patrick Steinhardt <ps@pks.im> Acked-by: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Jan 30, 2015 at 16:14 UTC 8196e728955a084303e99affff2ebc1120112516
2 files changed +18 -1
git-submodule.sh
+1 -1
@@ -420,7 +420,7 @@ cmd_add()
420 sed -e '
421 s|//*|/|g
422 s|^\(\./\)*||
423 - s|/\./|/|g
423 + s|/\(\./\)*|/|g
424 :start
425 s|\([^/]*\)/\.\./||
426 tstart
t/t7400-submodule-basic.sh
+17
@@ -171,6 +171,23 @@ test_expect_success 'submodule add with ./ in path' '
171 test_cmp empty untracked
172 '
173
174 +test_expect_success 'submodule add with /././ in path' '
175 + echo "refs/heads/master" >expect &&
176 + >empty &&
177 +
178 + (
179 + cd addtest &&
180 + git submodule add "$submodurl" dotslashdotsubmod/././frotz/./ &&
181 + git submodule init
182 + ) &&
183 +
184 + rm -f heads head untracked &&
185 + inspect addtest/dotslashdotsubmod/frotz ../../.. &&
186 + test_cmp expect heads &&
187 + test_cmp expect head &&
188 + test_cmp empty untracked
189 +'
190 +
191 test_expect_success 'submodule add with // in path' '
192 echo "refs/heads/master" >expect &&
193 >empty &&