threads / patch / 51721

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

Subject: [PATCH 0/1] mingw: support UNC as file://server/share/repo

## tl;dr

3 messages between Aug 24, 2019 and Aug 26, 2019. Diffs are folded; open one to read it.

replies: 2people: 3as markdown or json

Johannes Schindelin via GitGitGadget· Aug 24, 2019, 22:07 UTC · lore

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
-- 
gitgitgadget
Torsten Bögershausen via GitGitGadget· Aug 24, 2019, 22:07 UTC · re: Johannes Schindelin via GitGitGadget · lore

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

From: =?UTF-8?q?Torsten=20B=C3=B6gershausen?= <tboegi@web.de>

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>
---
 connect.c             |  4 ++++
 t/t5500-fetch-pack.sh | 13 +++++++++++--
 2 files changed, 15 insertions(+), 2 deletions(-)
Show changes to 2 files +15 −2

connect.c, t/t5500-fetch-pack.sh

diff --git a/connect.c b/connect.c
index 24281b6082..d72772a36d 100644
--- a/connect.c
+++ b/connect.c
@@ -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
diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh
index 086f2c40f6..f021db44b1 100755
--- a/t/t5500-fetch-pack.sh
+++ b/t/t5500-fetch-pack.sh
@@ -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
-- 
gitgitgadget
Junio C Hamano· Aug 26, 2019, 17:06 UTC · re: Johannes Schindelin via GitGitGadget · lore

Re: [PATCH 0/1] mingw: support UNC as file://server/share/repo

"Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com> writes:

> Windows users might think that the common file:/// protocol also works for
> network shares. This patch makes it so.
Thanks, both.
Show 13 quoted 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

← back to recent threads