From cf9e55f49438d07dd554c5ade92f1c266363af36 Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Fri, 7 Apr 2017 10:23:06 -0700 Subject: 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 Signed-off-by: Brandon Williams Reviewed-by: Jeff King Signed-off-by: Junio C Hamano --- t/t7400-submodule-basic.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 't/t7400-submodule-basic.sh') diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh index cf77a3a357..c2706fe472 100755 --- a/t/t7400-submodule-basic.sh +++ b/t/t7400-submodule-basic.sh @@ -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 && -- cgit v1.2.1