{"thread":{"id":"8178","subject":"[PATCHv3] connect: display connection progress","startedAt":"2007-05-16T17:09:41Z","lastAt":"2007-05-16T18:00:03Z","messageCount":3,"participants":["Michael S. Tsirkin","Linus Torvalds","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"42318","messageId":"20070516170941.GA19449@mellanox.co.il","threadId":"8178","inReplyTo":null,"subject":"[PATCHv3] connect: display connection progress","fromName":"Michael S. Tsirkin","fromEmail":"mst@dev.mellanox.co.il","sentAt":"2007-05-16T17:09:41Z","receivedAt":"2007-05-16T17:09:41Z","isPatch":false,"sender":{"key":"mst@kernel.org","avatar":null},"body":"Make git notify the user about host resolution/connection attempts.\nThis is useful both as a progress indicator on slow links, and helps\nreassure the user there are no firewall problems.\n\nSigned-off-by: Michael S. Tsirkin <mst@dev.mellanox.co.il>\n\n---\n\nTried to incorporate most of the feedback on v2.\nOnce some commands get -vv flag, we'll be able to add\nCONNECT_EXTRA_VERBOSE and print out address information etc,\nbut this is outside the scope of this patch.\n\ndiff --git a/builtin-archive.c b/builtin-archive.c\nindex 7f4e409..187491b 100644\n--- a/builtin-archive.c\n+++ b/builtin-archive.c\n@@ -45,7 +45,7 @@ static int run_remote_archiver(const char *remote, int argc,\n \t}\n \n \turl = xstrdup(remote);\n-\tpid = git_connect(fd, url, exec);\n+\tpid = git_connect(fd, url, exec, 0);\n \tif (pid < 0)\n \t\treturn pid;\n \ndiff --git a/cache.h b/cache.h\nindex aaeb04a..206bbe4 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -463,7 +463,8 @@ struct ref {\n #define REF_HEADS\t(1u << 1)\n #define REF_TAGS\t(1u << 2)\n \n-extern pid_t git_connect(int fd[2], char *url, const char *prog);\n+#define CONNECT_VERBOSE       (1u << 0)\n+extern pid_t git_connect(int fd[2], char *url, const char *prog, int flags);\n extern int finish_connect(pid_t pid);\n extern int path_match(const char *path, int nr, char **match);\n extern int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,\ndiff --git a/connect.c b/connect.c\nindex da89c9c..2a26fdb 100644\n--- a/connect.c\n+++ b/connect.c\n@@ -394,7 +394,7 @@ static enum protocol get_protocol(const char *name)\n /*\n  * Returns a connected socket() fd, or else die()s.\n  */\n-static int git_tcp_connect_sock(char *host)\n+static int git_tcp_connect_sock(char *host, int flags)\n {\n \tint sockfd = -1, saved_errno = 0;\n \tchar *colon, *end;\n@@ -425,10 +425,16 @@ static int git_tcp_connect_sock(char *host)\n \thints.ai_socktype = SOCK_STREAM;\n \thints.ai_protocol = IPPROTO_TCP;\n \n+\tif (flags & CONNECT_VERBOSE)\n+\t\tfprintf(stderr, \"Looking up %s ... \", host);\n+\n \tgai = getaddrinfo(host, port, &hints, &ai);\n \tif (gai)\n \t\tdie(\"Unable to look up %s (port %s) (%s)\", host, port, gai_strerror(gai));\n \n+\tif (flags & CONNECT_VERBOSE)\n+\t\tfprintf(stderr, \"done.\\nConnecting to %s (port %s) ... \", host, port);\n+\n \tfor (ai0 = ai; ai; ai = ai->ai_next) {\n \t\tsockfd = socket(ai->ai_family,\n \t\t\t\tai->ai_socktype, ai->ai_protocol);\n@@ -450,6 +456,9 @@ static int git_tcp_connect_sock(char *host)\n \tif (sockfd < 0)\n \t\tdie(\"unable to connect a socket (%s)\", strerror(saved_errno));\n \n+\tif (flags & CONNECT_VERBOSE)\n+\t\tfprintf(stderr, \"done.\\n\");\n+\n \treturn sockfd;\n }\n \n@@ -458,7 +467,7 @@ static int git_tcp_connect_sock(char *host)\n /*\n  * Returns a connected socket() fd, or else die()s.\n  */\n-static int git_tcp_connect_sock(char *host)\n+static int git_tcp_connect_sock(char *host, int flags)\n {\n \tint sockfd = -1, saved_errno = 0;\n \tchar *colon, *end;\n@@ -485,6 +494,9 @@ static int git_tcp_connect_sock(char *host)\n \t\tport = colon + 1;\n \t}\n \n+\tif (flags & CONNECT_VERBOSE)\n+\t\tfprintf(stderr, \"Looking up %s ... \", host);\n+\n \the = gethostbyname(host);\n \tif (!he)\n \t\tdie(\"Unable to look up %s (%s)\", host, hstrerror(h_errno));\n@@ -497,6 +509,9 @@ static int git_tcp_connect_sock(char *host)\n \t\tnport = se->s_port;\n \t}\n \n+\tif (flags & CONNECT_VERBOSE)\n+\t\tfprintf(stderr, \"done.\\nConnecting to %s (port %s) ... \", host, port);\n+\n \tfor (ap = he->h_addr_list; *ap; ap++) {\n \t\tsockfd = socket(he->h_addrtype, SOCK_STREAM, 0);\n \t\tif (sockfd < 0) {\n@@ -521,15 +536,18 @@ static int git_tcp_connect_sock(char *host)\n \tif (sockfd < 0)\n \t\tdie(\"unable to connect a socket (%s)\", strerror(saved_errno));\n \n+\tif (flags & CONNECT_VERBOSE)\n+\t\tfprintf(stderr, \"done.\\n\");\n+\n \treturn sockfd;\n }\n \n #endif /* NO_IPV6 */\n \n \n-static void git_tcp_connect(int fd[2], char *host)\n+static void git_tcp_connect(int fd[2], char *host, int flags)\n {\n-\tint sockfd = git_tcp_connect_sock(host);\n+\tint sockfd = git_tcp_connect_sock(host, flags);\n \n \tfd[0] = sockfd;\n \tfd[1] = dup(sockfd);\n@@ -646,7 +664,7 @@ static void git_proxy_connect(int fd[2], char *host)\n  *\n  * Does not return a negative value on error; it just dies.\n  */\n-pid_t git_connect(int fd[2], char *url, const char *prog)\n+pid_t git_connect(int fd[2], char *url, const char *prog, int flags)\n {\n \tchar *host, *path = url;\n \tchar *end;\n@@ -719,7 +737,7 @@ pid_t git_connect(int fd[2], char *url, const char *prog)\n \t\tif (git_use_proxy(host))\n \t\t\tgit_proxy_connect(fd, host);\n \t\telse\n-\t\t\tgit_tcp_connect(fd, host);\n+\t\t\tgit_tcp_connect(fd, host, flags);\n \t\t/*\n \t\t * Separate original protocol components prog and path\n \t\t * from extended components with a NUL byte.\ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex 06f4aec..aa59043 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -733,7 +733,7 @@ int main(int argc, char **argv)\n \t}\n \tif (!dest)\n \t\tusage(fetch_pack_usage);\n-\tpid = git_connect(fd, dest, uploadpack);\n+\tpid = git_connect(fd, dest, uploadpack, verbose ? CONNECT_VERBOSE : 0);\n \tif (pid < 0)\n \t\treturn 1;\n \tif (heads && nr_heads)\ndiff --git a/peek-remote.c b/peek-remote.c\nindex 96bfac4..ceb7871 100644\n--- a/peek-remote.c\n+++ b/peek-remote.c\n@@ -64,7 +64,7 @@ int main(int argc, char **argv)\n \tif (!dest || i != argc - 1)\n \t\tusage(peek_remote_usage);\n \n-\tpid = git_connect(fd, dest, uploadpack);\n+\tpid = git_connect(fd, dest, uploadpack, 0);\n \tif (pid < 0)\n \t\treturn 1;\n \tret = peek_remote(fd, flags);\ndiff --git a/send-pack.c b/send-pack.c\nindex d5b5162..83ee87d 100644\n--- a/send-pack.c\n+++ b/send-pack.c\n@@ -393,7 +393,7 @@ int main(int argc, char **argv)\n \t\tusage(send_pack_usage);\n \tverify_remote_names(nr_heads, heads);\n \n-\tpid = git_connect(fd, dest, receivepack);\n+\tpid = git_connect(fd, dest, receivepack, verbose ? CONNECT_VERBOSE : 0);\n \tif (pid < 0)\n \t\treturn 1;\n \tret = send_pack(fd[0], fd[1], nr_heads, heads);\n-- \nMST\n"},{"id":"42319","messageId":"alpine.LFD.0.98.0705161019390.3890@woody.linux-foundation.org","threadId":"8178","inReplyTo":"20070516170941.GA19449@mellanox.co.il","subject":"Re: [PATCHv3] connect: display connection progress","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2007-05-16T17:19:58Z","receivedAt":"2007-05-16T17:19:58Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Wed, 16 May 2007, Michael S. Tsirkin wrote:\n>\n> Make git notify the user about host resolution/connection attempts.\n> This is useful both as a progress indicator on slow links, and helps\n> reassure the user there are no firewall problems.\n\nLooks fine to me. Ack.\n\n\t\tLinus\n"},{"id":"42321","messageId":"7vwsz8ejj0.fsf@assigned-by-dhcp.cox.net","threadId":"8178","inReplyTo":"20070516170941.GA19449@mellanox.co.il","subject":"Re: [PATCHv3] connect: display connection progress","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-05-16T18:00:03Z","receivedAt":"2007-05-16T18:00:03Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Michael S. Tsirkin\" <mst@dev.mellanox.co.il> writes:\n\n> Make git notify the user about host resolution/connection attempts.\n> This is useful both as a progress indicator on slow links, and helps\n> reassure the user there are no firewall problems.\n\nNicely done.  Thanks.\n"}]}