Skip to content

Commit 782ca35

Browse files
tboegiGit for Windows Build Agent
authored and
Git for Windows Build Agent
committed
mingw: support UNC in git clone file://server/share/repo
Extend the parser to accept file://server/share/repo in the way that Windows users expect it to be parsed who are used to referring to file shares by UNC paths of the form \\server\share\folder. [jes: tightened check to avoid handling file://C:/some/path as a UNC path.] This closes #1264. Signed-off-by: Torsten Bögershausen <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 266422c commit 782ca35

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

connect.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,10 @@ static enum protocol parse_connect_url(const char *url_orig, char **ret_host,
652652

653653
if (protocol == PROTO_LOCAL)
654654
path = end;
655+
else if (protocol == PROTO_FILE && *host != '/' &&
656+
!has_dos_drive_prefix(host) &&
657+
offset_1st_component(host - 2) > 1)
658+
path = host - 2; /* include the leading "//" */
655659
else if (protocol == PROTO_FILE && has_dos_drive_prefix(end))
656660
path = end; /* "file://$(pwd)" may be "file://C:/projects/repo" */
657661
else

t/t5500-fetch-pack.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -647,13 +647,22 @@ do
647647
# file with scheme
648648
for p in file
649649
do
650-
test_expect_success "fetch-pack --diag-url $p://$h/$r" '
650+
test_expect_success !MINGW "fetch-pack --diag-url $p://$h/$r" '
651651
check_prot_path $p://$h/$r $p "/$r"
652652
'
653+
test_expect_success MINGW "fetch-pack --diag-url $p://$h/$r" '
654+
check_prot_path $p://$h/$r $p "//$h/$r"
655+
'
656+
test_expect_success MINGW "fetch-pack --diag-url $p:///$r" '
657+
check_prot_path $p:///$r $p "/$r"
658+
'
653659
# No "/~" -> "~" conversion for file
654-
test_expect_success "fetch-pack --diag-url $p://$h/~$r" '
660+
test_expect_success !MINGW "fetch-pack --diag-url $p://$h/~$r" '
655661
check_prot_path $p://$h/~$r $p "/~$r"
656662
'
663+
test_expect_success MINGW "fetch-pack --diag-url $p://$h/~$r" '
664+
check_prot_path $p://$h/~$r $p "//$h/~$r"
665+
'
657666
done
658667
# file without scheme
659668
for h in nohost nohost:12 [::1] [::1]:23 [ [:aa

0 commit comments

Comments
 (0)