Skip to contentSkip to conversation

mingw: support UNC as file://server/share/repo

PATCH In review Johannes Schindelin via GitGitGadget 2 participants 3 messages Aug 24, 2019 – Aug 26, 2019

lore
Share & tools
lore
#0 lore raw

cover mingw: support UNC as file://server/share/repo

Windows users might think that the common file:/// protocol also works for network shares. This patch makes it so.

Torsten Bögershausen (1):
mingw: support UNC in git clone file://server/share/repo

 connect.c             |  4 ++++
 t/t5500-fetch-pack.sh | 13 +++++++++++--
 2 files changed, 15 insertions(+), 2 deletions(-)

base-commit: 5d826e972970a784bd7a7bdf587512510097b8c7
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-93%2Fdscho%2Ffile-url-to-unc-path-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-93/dscho/file-url-to-unc-path-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/93

Signature · 1 line
gitgitgadget
#1 lore raw

PATCH 1/1 mingw: support UNC in git clone file://server/share/repo

From: =?UTF-8?q?Torsten=20B=C3=B6gershausen?= <[email protected]>

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.

---
 connect.c             |  4 ++++
 t/t5500-fetch-pack.sh | 13 +++++++++++--
 2 files changed, 15 insertions(+), 2 deletions(-)
connect.c +4 -0
index 24281b6082..d72772a36d 100644
@@ -918,6 +918,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
t/t5500-fetch-pack.sh +11 -2
index 086f2c40f6..f021db44b1 100755
@@ -698,13 +698,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
Signature · 1 line
gitgitgadget
#2 lore raw
In reply to Johannes Schindelin via GitGitGadget

"Johannes Schindelin via GitGitGadget" <[email protected]>

Quoted 2 lines · writes:

Windows users might think that the common file:/// protocol also works for network shares. This patch makes it so.

Thanks, both.

Quoted 13 lines

Torsten Bögershausen (1):
mingw: support UNC in git clone file://server/share/repo

 connect.c             |  4 ++++
 t/t5500-fetch-pack.sh | 13 +++++++++++--
 2 files changed, 15 insertions(+), 2 deletions(-)

base-commit: 5d826e972970a784bd7a7bdf587512510097b8c7
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-93%2Fdscho%2Ffile-url-to-unc-path-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-93/dscho/file-url-to-unc-path-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/93