Skip to content

Commit

Permalink
connect.c: remove a few globals by using git_config callback data
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Erik Faye-Lund authored and Junio C Hamano committed Mar 11, 2009
1 parent c4994ce commit 15112c9
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,6 @@ static void git_tcp_connect(int fd[2], char *host, int flags)


static char *git_proxy_command;
static const char *rhost_name;
static int rhost_len;

static int git_proxy_command_options(const char *var, const char *value,
void *cb)
Expand All @@ -383,6 +381,8 @@ static int git_proxy_command_options(const char *var, const char *value,
const char *for_pos;
int matchlen = -1;
int hostlen;
const char *rhost_name = cb;
int rhost_len = strlen(rhost_name);

if (git_proxy_command)
return 0;
Expand Down Expand Up @@ -426,11 +426,8 @@ static int git_proxy_command_options(const char *var, const char *value,

static int git_use_proxy(const char *host)
{
rhost_name = host;
rhost_len = strlen(host);
git_proxy_command = getenv("GIT_PROXY_COMMAND");
git_config(git_proxy_command_options, NULL);
rhost_name = NULL;
git_config(git_proxy_command_options, (void*)host);
return (git_proxy_command && *git_proxy_command);
}

Expand Down

0 comments on commit 15112c9

Please sign in to comment.