Skip to content

Commit 8196e72

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Acked-by: Jens Lehmann <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3d8a54e commit 8196e72

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

git-submodule.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ cmd_add()
420420
sed -e '
421421
s|//*|/|g
422422
s|^\(\./\)*||
423-
s|/\./|/|g
423+
s|/\(\./\)*|/|g
424424
:start
425425
s|\([^/]*\)/\.\./||
426426
tstart

t/t7400-submodule-basic.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,23 @@ test_expect_success 'submodule add with ./ in path' '
171171
test_cmp empty untracked
172172
'
173173

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+
174191
test_expect_success 'submodule add with // in path' '
175192
echo "refs/heads/master" >expect &&
176193
>empty &&

0 commit comments

Comments
 (0)