Git development
 help / color / mirror / Atom feed
From: Erik Faye-Lund <kusmabite@gmail.com>
To: git@vger.kernel.org
Cc: Erik Faye-Lund <kusmabite@gmail.com>
Subject: [PATCH v2] connect.c: remove a few globals by using git_config callback data
Date: Wed, 11 Mar 2009 02:38:12 +0000	[thread overview]
Message-ID: <1236739092-8280-1-git-send-email-kusmabite@gmail.com> (raw)

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>
---
 connect.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/connect.c b/connect.c
index 2f23ab3..0a35cc1 100644
--- a/connect.c
+++ b/connect.c
@@ -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)
@@ -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;
@@ -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);
 }
 
-- 
1.6.2.GIT

             reply	other threads:[~2009-03-11  2:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-11  2:38 Erik Faye-Lund [this message]
2009-03-11 11:52 ` [PATCH v2] connect.c: remove a few globals by using git_config callback data Johannes Schindelin
2009-03-11 13:17   ` Erik Faye-Lund
2009-03-11 13:28     ` Johannes Schindelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1236739092-8280-1-git-send-email-kusmabite@gmail.com \
    --to=kusmabite@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox