git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] Client side of user-relative paths, take two.
@ 2005-11-01 22:59 Andreas Ericsson
  2005-11-02  0:14 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Ericsson @ 2005-11-01 22:59 UTC (permalink / raw)


See this discussion, "[RFC] GIT paths", on the git-list:
http://www.gelato.unsw.edu.au/archives/git/0510/10924.html

In particular, the client side now passes identical paths for these two:
	ssh://host.xz/~junio/repo
	host.xz:~junio/repo

A friendly error message is produced if no path is specified.

Signed-off-by: Andreas Ericsson <ae@op5.se>

---

 connect.c |   53 ++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 34 insertions(+), 19 deletions(-)

applies-to: e39c96179f2cc5064a0255057b8e8a8863594536
22ca6db517baf2bb4824a971408543d9bd956209
diff --git a/connect.c b/connect.c
index c2badc7..9150ad2 100644
--- a/connect.c
+++ b/connect.c
@@ -460,26 +460,41 @@ int git_connect(int fd[2], char *url, co
 	pid_t pid;
 	enum protocol protocol;
 
-	host = NULL;
-	path = url;
-	colon = strchr(url, ':');
-	protocol = PROTO_LOCAL;
-	if (colon) {
-		*colon = 0;
+	protocol = PROTO_SSH;
+	host = strstr(url, "://");
+	if(host) {
+		*host = '\0';
+		protocol = get_protocol(url);
+		host += 3;
+	}
+	else
 		host = url;
-		path = colon+1;
-		protocol = PROTO_SSH;
-		if (!memcmp(path, "//", 2)) {
-			char *slash = strchr(path + 2, '/');
-			if (slash) {
-				int nr = slash - path - 2;
-				memmove(path, path+2, nr);
-				path[nr] = 0;
-				protocol = get_protocol(url);
-				host = path;
-				path = slash;
-			}
-		}
+
+	path = strchr(host, '/');
+	colon = strchr(host, ':');
+
+	/* We keep server-side code simple by handling the difference
+	 * between these two on the client side:
+	 *    ssh://host.xz/~user/repo
+	 *    host.xz:~repo
+	 */
+	if (protocol == PROTO_SSH && colon && (!path || colon < path)) {
+		*colon = 0;
+		path = colon + 1;
+	}
+
+	if(!path || !*path)
+		die("No path specified. Try '%s%s/path/to/repo'", url, colon ? ":" : "");
+
+	/* null-terminate host part and point path to ~ for URL's like this:
+	 *    ssh://host.xz/~user/repo
+	 */
+	if(!colon && *(path + 1) == '~')
+		*path++ = '\0';
+	else {
+		colon = path;
+		path = strdup(path);
+		*colon = '\0';
 	}
 
 	if (protocol == PROTO_GIT)
---
0.99.9.GIT

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-11-02  8:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-01 22:59 [PATCH 1/4] Client side of user-relative paths, take two Andreas Ericsson
2005-11-02  0:14 ` Junio C Hamano
2005-11-02  8:19   ` Andreas Ericsson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).