submodule: prevent backslash expantion in submodule names
When attempting to add a submodule with backslashes in its name 'git submodule' fails in a funny way. We can see that some of the backslashes are expanded resulting in a bogus path: git -C main submodule add ../sub\\with\\backslash fatal: repository '/tmp/test/sub\witackslash' does not exist fatal: clone of '/tmp/test/sub\witackslash' into submodule path To solve this, convert calls to 'read' to 'read -r' in git-submodule.sh in order to prevent backslash expantion in submodule names. Reported-by: Joachim Durchholz <jo@durchholz.org> Signed-off-by: Brandon Williams <bmwill@google.com> Reviewed-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
cf11a67975
commit
cf9e55f494
@ -273,6 +273,20 @@ test_expect_success 'submodule add with ./, /.. and // in path' '
|
||||
test_cmp empty untracked
|
||||
'
|
||||
|
||||
test_expect_success 'submodule add with \\ in path' '
|
||||
test_when_finished "rm -rf parent sub\\with\\backslash" &&
|
||||
|
||||
# Initialize a repo with a backslash in its name
|
||||
git init sub\\with\\backslash &&
|
||||
touch sub\\with\\backslash/empty.file &&
|
||||
git -C sub\\with\\backslash add empty.file &&
|
||||
git -C sub\\with\\backslash commit -m "Added empty.file" &&
|
||||
|
||||
# Add that repository as a submodule
|
||||
git init parent &&
|
||||
git -C parent submodule add ../sub\\with\\backslash
|
||||
'
|
||||
|
||||
test_expect_success 'submodule add in subdirectory' '
|
||||
echo "refs/heads/master" >expect &&
|
||||
>empty &&
|
||||
|
Reference in New Issue
Block a user