Skip to content

Commit c6427a2

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 39bdb68 commit c6427a2

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
@@ -915,6 +915,10 @@ static enum protocol parse_connect_url(const char *url_orig, char **ret_host,
915915

916916
if (protocol == PROTO_LOCAL)
917917
path = end;
918+
else if (protocol == PROTO_FILE && *host != '/' &&
919+
!has_dos_drive_prefix(host) &&
920+
offset_1st_component(host - 2) > 1)
921+
path = host - 2; /* include the leading "//" */
918922
else if (protocol == PROTO_FILE && has_dos_drive_prefix(end))
919923
path = end; /* "file://$(pwd)" may be "file://C:/projects/repo" */
920924
else

t/t5500-fetch-pack.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -708,13 +708,22 @@ do
708708
# file with scheme
709709
for p in file
710710
do
711-
test_expect_success "fetch-pack --diag-url $p://$h/$r" '
711+
test_expect_success !MINGW "fetch-pack --diag-url $p://$h/$r" '
712712
check_prot_path $p://$h/$r $p "/$r"
713713
'
714+
test_expect_success MINGW "fetch-pack --diag-url $p://$h/$r" '
715+
check_prot_path $p://$h/$r $p "//$h/$r"
716+
'
717+
test_expect_success MINGW "fetch-pack --diag-url $p:///$r" '
718+
check_prot_path $p:///$r $p "/$r"
719+
'
714720
# No "/~" -> "~" conversion for file
715-
test_expect_success "fetch-pack --diag-url $p://$h/~$r" '
721+
test_expect_success !MINGW "fetch-pack --diag-url $p://$h/~$r" '
716722
check_prot_path $p://$h/~$r $p "/~$r"
717723
'
724+
test_expect_success MINGW "fetch-pack --diag-url $p://$h/~$r" '
725+
check_prot_path $p://$h/~$r $p "//$h/~$r"
726+
'
718727
done
719728
# file without scheme
720729
for h in nohost nohost:12 [::1] [::1]:23 [ [:aa

0 commit comments

Comments
 (0)