summaryrefslogtreecommitdiff
path: root/connect.c
diff options
context:
space:
mode:
authorTorsten Bögershausen <tboegi@web.de>2013-11-28 20:49:17 +0100
committerJunio C Hamano <gitster@pobox.com>2013-12-09 14:54:47 -0800
commit5610b7c0c6957cf0b236b6fac087c1f4dc209376 (patch)
tree1557e893eea7c730ff382ff1777af192c403ca67 /connect.c
parentcabc3c12e40f5556bb4de934ab783d53e908e401 (diff)
downloadgit-5610b7c0c6957cf0b236b6fac087c1f4dc209376.tar.gz
git fetch-pack: add --diag-url
The main purpose is to trace the URL parser called by git_connect() in connect.c The main features of the parser can be listed as this: - parse out host and path for URLs with a scheme (git:// file:// ssh://) - parse host names embedded by [] correctly - extract the port number, if present - separate URLs like "file" (which are local) from URLs like "host:repo" which should use ssh Add the new parameter "--diag-url" to "git fetch-pack", which prints the value for protocol, host and path to stderr and exits. Signed-off-by: Torsten Bögershausen <tboegi@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'connect.c')
-rw-r--r--connect.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/connect.c b/connect.c
index a6cf3454a2..a16bdaf0b7 100644
--- a/connect.c
+++ b/connect.c
@@ -236,6 +236,20 @@ enum protocol {
PROTO_GIT
};
+static const char *prot_name(enum protocol protocol)
+{
+ switch (protocol) {
+ case PROTO_LOCAL:
+ return "file";
+ case PROTO_SSH:
+ return "ssh";
+ case PROTO_GIT:
+ return "git";
+ default:
+ return "unkown protocol";
+ }
+}
+
static enum protocol get_protocol(const char *name)
{
if (!strcmp(name, "ssh"))
@@ -670,6 +684,20 @@ struct child_process *git_connect(int fd[2], const char *url,
signal(SIGCHLD, SIG_DFL);
protocol = parse_connect_url(url, &host, &port, &path);
+ if (flags & CONNECT_DIAG_URL) {
+ printf("Diag: url=%s\n", url ? url : "NULL");
+ printf("Diag: protocol=%s\n", prot_name(protocol));
+ printf("Diag: hostandport=%s", host ? host : "NULL");
+ if (port)
+ printf(":%s\n", port);
+ else
+ printf("\n");
+ printf("Diag: path=%s\n", path ? path : "NULL");
+ free(host);
+ free(port);
+ free(path);
+ return NULL;
+ }
if (protocol == PROTO_GIT) {
/* These underlying connection commands die() if they