Skip to contentSkip to conversation

git fetch: support host:/~repo

PATCH Superseded Torsten Bögershausen 2 participants 2 messages Jun 15, 2016

v6 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

PATCH v6 10/10 git fetch: support host:/~repo

Since commit faea9ccb URLs host:~repo or ssh://host:/~repo reach the home directory.
In 356bece0 support for [] was introduced, and as a side effect, [host]:/~repo was the same as [host]:~repo.
The side effect was removed in c01049ae, "connect.c: Corner case for IPv6".

Re-reading the documentation (in urls.txt) we find that "ssh://host:/~repo",
"host:/~repo" or
"host:~repo"
specifiy the repository "repo" in the home directory at "host".

So make the handling of "host:/~repo" (or "[host]:/~repo") a feature, and revert the possible regression introduced in c01049ae.

---
 connect.c             |  3 +--
 t/t5500-fetch-pack.sh |  4 ++--
 t/t5601-clone.sh      | 12 ++++++++++--
 3 files changed, 13 insertions(+), 6 deletions(-)
connect.c +1 -2
index 95568ac..2cad296 100644
@@ -625,8 +625,7 @@ static enum protocol parse_connect_url(const char *url_orig, char **ret_host,
 	end = path; /* Need to \0 terminate host here */
 	if (separator == ':')
 		path++; /* path starts after ':' */
-	if ((protocol == PROTO_GIT) ||
-			(protocol == PROTO_SSH && separator == '/')) {
+	if (protocol == PROTO_GIT || protocol == PROTO_SSH) {
 		if (path[1] == '~')
 			path++;
 	}
t/t5500-fetch-pack.sh +2 -2
index 69a2110..7d9f18c 100755
@@ -601,9 +601,9 @@ do
 		test_expect_success "fetch-pack --diag-url $h:$r" '
 			check_prot_path $h:$r $p "$r"
 		'
-		# No "/~" -> "~" conversion
+		# Do the "/~" -> "~" conversion
 		test_expect_success "fetch-pack --diag-url $h:/~$r" '
-			check_prot_host_path $h:/~$r $p "$h" "/~$r"
+			check_prot_host_path $h:/~$r $p "$h" "~$r"
 		'
 	done
 done
t/t5601-clone.sh +10 -2
index bd1bfd3..62fbd7e 100755
@@ -348,7 +348,7 @@ test_expect_success MINGW 'clone c:temp is dos drive' '
 '
 
 #ip v4
-for repo in rep rep/home/project /~proj 123
+for repo in rep rep/home/project 123
 do
 	test_expect_success "clone host:$repo" '
 		test_clone_url host:$repo host $repo
@@ -356,12 +356,20 @@ do
 done
 
 #ipv6
-for repo in rep rep/home/project 123 /~proj
+for repo in rep rep/home/project 123
 do
 	test_expect_success "clone [::1]:$repo" '
 		test_clone_url [::1]:$repo ::1 $repo
 	'
 done
+#home directory
+test_expect_success "clone host:/~repo" '
+	test_clone_url host:/~repo host "~repo"
+'
+
+test_expect_success "clone [::1]:/~repo" '
+	test_clone_url [::1]:/~repo ::1 "~repo"
+'
 
 # Corner cases
 for url in foo/bar:baz [foo]bar/baz:qux [foo/bar]:baz
Signature · 1 line
1.8.4.457.g424cb08
#1 lore raw
Quoted 6 lines · Torsten Bögershausen

Since commit faea9ccb URLs host:~repo or ssh://host:/~repo reach the home directory.
In 356bece0 support for [] was introduced, and as a side effect, [host]:/~repo was the same as [host]:~repo.
The side effect was removed in c01049ae, "connect.c: Corner case for IPv6".

Quoted 8 lines

Re-reading the documentation (in urls.txt) we find that "ssh://host:/~repo",
"host:/~repo" or
"host:~repo"
specifiy the repository "repo" in the home directory at "host".

So make the handling of "host:/~repo" (or "[host]:/~repo") a feature, and revert the possible regression introduced in c01049ae.

Isn't c01049ae a private copy in your repository, a part of this series? Perhaps the series needs to be (re)structured to avoid introducing a "possible regression" in the first place?

Confused...

Quoted 71 lines
---
 connect.c             |  3 +--
 t/t5500-fetch-pack.sh |  4 ++--
 t/t5601-clone.sh      | 12 ++++++++++--
 3 files changed, 13 insertions(+), 6 deletions(-)
connect.c +1 -2
index 95568ac..2cad296 100644
@@ -625,8 +625,7 @@ static enum protocol parse_connect_url(const char *url_orig, char **ret_host,
 	end = path; /* Need to \0 terminate host here */
 	if (separator == ':')
 		path++; /* path starts after ':' */
-	if ((protocol == PROTO_GIT) ||
-			(protocol == PROTO_SSH && separator == '/')) {
+	if (protocol == PROTO_GIT || protocol == PROTO_SSH) {
 		if (path[1] == '~')
 			path++;
 	}
t/t5500-fetch-pack.sh +2 -2
index 69a2110..7d9f18c 100755
@@ -601,9 +601,9 @@ do
 		test_expect_success "fetch-pack --diag-url $h:$r" '
 			check_prot_path $h:$r $p "$r"
 		'
-		# No "/~" -> "~" conversion
+		# Do the "/~" -> "~" conversion
 		test_expect_success "fetch-pack --diag-url $h:/~$r" '
-			check_prot_host_path $h:/~$r $p "$h" "/~$r"
+			check_prot_host_path $h:/~$r $p "$h" "~$r"
 		'
 	done
 done
t/t5601-clone.sh +10 -2
index bd1bfd3..62fbd7e 100755
@@ -348,7 +348,7 @@ test_expect_success MINGW 'clone c:temp is dos drive' '
 '
 
 #ip v4
-for repo in rep rep/home/project /~proj 123
+for repo in rep rep/home/project 123
 do
 	test_expect_success "clone host:$repo" '
 		test_clone_url host:$repo host $repo
@@ -356,12 +356,20 @@ do
 done
 
 #ipv6
-for repo in rep rep/home/project 123 /~proj
+for repo in rep rep/home/project 123
 do
 	test_expect_success "clone [::1]:$repo" '
 		test_clone_url [::1]:$repo ::1 $repo
 	'
 done
+#home directory
+test_expect_success "clone host:/~repo" '
+	test_clone_url host:/~repo host "~repo"
+'
+
+test_expect_success "clone [::1]:/~repo" '
+	test_clone_url [::1]:/~repo ::1 "~repo"
+'
 
 # Corner cases
 for url in foo/bar:baz [foo]bar/baz:qux [foo/bar]:baz