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 https://github.com/git-for-windows/git/issues/1264. Signed-off-by: Torsten Bögershausen <tboegi@web.de> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Torsten Bögershausen committed Aug 24, 2019 at 15:07 UTC ebb8d2c90fb0840a0803935804e37e2205505f23
2 files changed +15 -2
connect.c
+4
@@ -915,6 +915,10 @@ static enum protocol parse_connect_url(const char *url_orig, char **ret_host,
915
916 if (protocol == PROTO_LOCAL)
917 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 "//" */
922 else if (protocol == PROTO_FILE && has_dos_drive_prefix(end))
923 path = end; /* "file://$(pwd)" may be "file://C:/projects/repo" */
924 else
t/t5500-fetch-pack.sh
+11 -2
@@ -708,13 +708,22 @@ do
708 # file with scheme
709 for p in file
710 do
711 - test_expect_success "fetch-pack --diag-url $p://$h/$r" '
711 + test_expect_success !MINGW "fetch-pack --diag-url $p://$h/$r" '
712 check_prot_path $p://$h/$r $p "/$r"
713 '
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 + '
720 # 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" '
722 check_prot_path $p://$h/~$r $p "/~$r"
723 '
724 + test_expect_success MINGW "fetch-pack --diag-url $p://$h/~$r" '
725 + check_prot_path $p://$h/~$r $p "//$h/~$r"
726 + '
727 done
728 # file without scheme
729 for h in nohost nohost:12 [::1] [::1]:23 [ [:aa