From: Erik Faye-Lund <kusmabite@gmail.com>
To: git@vger.kernel.org
Cc: Johannes.Schindelin@gmx.de, Erik Faye-Lund <kusmabite@gmail.com>
Subject: [PATCH] Removed unnecessary use of global variables.
Date: Wed, 11 Mar 2009 00:09:28 +0000 [thread overview]
Message-ID: <1236730168-7164-1-git-send-email-kusmabite@gmail.com> (raw)
git_config() now takes a third data-parameter that is passed back
to the callback-function. At the time this code was written, that
parameter did not exist, so a somewhat nasty (but by all means
correct) use of global variables was introduced. In commit
ef90d6d4208a5130185b04f06e5f90a5f9959fe3 Johannes Schindelin
<Johannes.Schindelin@gmx.de> introduced a parameter for similar
purposes.
I've changed the code to utilize this parameter to pass the
string. In addition, I've made the function calculate the string
length on usage instead, to reduce the parameters needed to what
the callback-interface supplies.
Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
---
connect.c | 16 ++++++----------
1 files changed, 6 insertions(+), 10 deletions(-)
diff --git a/connect.c b/connect.c
index 2f23ab3..98fbaea 100644
--- a/connect.c
+++ b/connect.c
@@ -371,14 +371,13 @@ static void git_tcp_connect(int fd[2], char *host, int flags)
fd[1] = dup(sockfd);
}
-
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)
+ void *data)
{
+ const char *rhost_name = data;
+ const size_t rhost_len = strlen(rhost_name);
+
if (!strcmp(var, "core.gitproxy")) {
const char *for_pos;
int matchlen = -1;
@@ -421,16 +420,13 @@ static int git_proxy_command_options(const char *var, const char *value,
return 0;
}
- return git_default_config(var, value, cb);
+ return git_default_config(var, value, data);
}
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
next reply other threads:[~2009-03-11 1:11 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-11 0:09 Erik Faye-Lund [this message]
2009-03-11 1:19 ` Removed unnecessary use of global variables Erik Faye-Lund
2009-03-11 10:31 ` Johannes Schindelin
2009-03-11 10:30 ` [PATCH] " Johannes Schindelin
2009-03-11 21:42 ` Nanako Shiraishi
2009-03-11 22:00 ` Junio C Hamano
-- strict thread matches above, loose matches on Subject: below --
2009-03-11 1:05 Erik Faye-Lund
2009-03-11 1:52 ` Junio C Hamano
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=1236730168-7164-1-git-send-email-kusmabite@gmail.com \
--to=kusmabite@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--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;
as well as URLs for NNTP newsgroup(s).