git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] connect.c: remove a few globals by using git_config callback data

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Mar 11, 2009, 11:52 UTC
Message-ID
<alpine.DEB.1.00.0903111251160.10279@pacific.mpi-cbg.de>
In-Reply-To
<1236739092-8280-1-git-send-email-kusmabite@gmail.com>
Hi,
On Wed, 11 Mar 2009, Erik Faye-Lund wrote:
Show 10 quoted lines
> 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>
Thanks!
Show 6 quoted lines
> @@ -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);

I see that you still calculate the length everytime git_proxy_command_options() is called -- which is for every config variable.

Show 10 quoted lines
> @@ -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);
The (void *) should not be needed.

Thanks, Dscho

Previous: Erik Faye-LundNext: Erik Faye-Lund
Message 2 of 4 in “connect.c: remove a few globals by using git_config callback data”
  1. connect.c: remove a few globals by using git_config callback dataErik Faye-Lund, Mar 11, 2009
  2. Johannes SchindelinMar 11, 2009
  3. Erik Faye-LundMar 11, 2009
  4. Johannes SchindelinMar 11, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.