@matheusbsbs / matheus-bagliano / commits / 15112c9599
Fork 0

connect.c: remove a few globals by using git_config callback data

Since ef90d6d (Provide git_config with a callback-data parameter, 2008-05-14), git_config() takes a callback data pointer that can be used to pass extra parameters to the parsing function. The codepath to parse configuration variables related to git proxy predates this facility and used a pair of file scope static variables instead. This patch removes the need for these global variables by passing the name of the host we are trying to access as the callback data. Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Erik Faye-Lund committed Mar 11, 2009 at 02:38 UTC 15112c9599f99487211855db7a7a347f20ad9ed5
1 file changed +3 -6
connect.c
+3 -6
@@ -373,8 +373,6 @@ static void git_tcp_connect(int fd[2], char *host, int flags)
373
374
375 static char *git_proxy_command;
376 -static const char *rhost_name;
377 -static int rhost_len;
376
377 static int git_proxy_command_options(const char *var, const char *value,
378 void *cb)
@@ -383,6 +381,8 @@ static int git_proxy_command_options(const char *var, const char *value,
381 const char *for_pos;
382 int matchlen = -1;
383 int hostlen;
384 + const char *rhost_name = cb;
385 + int rhost_len = strlen(rhost_name);
386
387 if (git_proxy_command)
388 return 0;
@@ -426,11 +426,8 @@ static int git_proxy_command_options(const char *var, const char *value,
426
427 static int git_use_proxy(const char *host)
428 {
429 - rhost_name = host;
430 - rhost_len = strlen(host);
429 git_proxy_command = getenv("GIT_PROXY_COMMAND");
432 - git_config(git_proxy_command_options, NULL);
433 - rhost_name = NULL;
430 + git_config(git_proxy_command_options, (void*)host);
431 return (git_proxy_command && *git_proxy_command);
432 }
433