mingw: support UNC in git clone file://server/share/repo
authorTorsten Bögershausen <tboegi@web.de>
Sat, 24 Aug 2019 22:07:59 +0000 (15:07 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 26 Aug 2019 17:00:33 +0000 (10:00 -0700)
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>
connect.c
t/t5500-fetch-pack.sh
index 2778481264d0e1fdd8864743fc860ef63718524e..da7daa2b683f9aed7e1e63656bbefd83a1a4fa56 100644 (file)
--- a/connect.c
+++ b/connect.c
@@ -915,6 +915,10 @@ static enum protocol parse_connect_url(const char *url_orig, char **ret_host,
 
        if (protocol == PROTO_LOCAL)
                path = end;
+       else if (protocol == PROTO_FILE && *host != '/' &&
+                !has_dos_drive_prefix(host) &&
+                offset_1st_component(host - 2) > 1)
+               path = host - 2; /* include the leading "//" */
        else if (protocol == PROTO_FILE && has_dos_drive_prefix(end))
                path = end; /* "file://$(pwd)" may be "file://C:/projects/repo" */
        else
index 8210f63d41edbea01dffaae37282436846d3974b..5115711562f5c90780aa3e99910f18de066a08f7 100755 (executable)
@@ -708,13 +708,22 @@ do
        # file with scheme
        for p in file
        do
-               test_expect_success "fetch-pack --diag-url $p://$h/$r" '
+               test_expect_success !MINGW "fetch-pack --diag-url $p://$h/$r" '
                        check_prot_path $p://$h/$r $p "/$r"
                '
+               test_expect_success MINGW "fetch-pack --diag-url $p://$h/$r" '
+                       check_prot_path $p://$h/$r $p "//$h/$r"
+               '
+               test_expect_success MINGW "fetch-pack --diag-url $p:///$r" '
+                       check_prot_path $p:///$r $p "/$r"
+               '
                # No "/~" -> "~" conversion for file
-               test_expect_success "fetch-pack --diag-url $p://$h/~$r" '
+               test_expect_success !MINGW "fetch-pack --diag-url $p://$h/~$r" '
                        check_prot_path $p://$h/~$r $p "/~$r"
                '
+               test_expect_success MINGW "fetch-pack --diag-url $p://$h/~$r" '
+                       check_prot_path $p://$h/~$r $p "//$h/~$r"
+               '
        done
        # file without scheme
        for h in nohost nohost:12 [::1] [::1]:23 [ [:aa