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

Re: [PATCH] Glean libexec path from argv[0] for git-upload-pack and git-receive-pack.

From
Steve Haslam <shaslam@lastminute.com>
Date
Jul 30, 2008, 16:15 UTC
Message-ID
<48909396.3080500@lastminute.com>
In-Reply-To
<alpine.LSU.1.00.0807301650060.3486@wbgn129.biozentrum.uni-wuerzburg.de>

[sorry, was intended to cc Johannes Sixt when I mailed the patch to the list... not doing well with the recipient etiquette]

[and then Icedove decided it was going to send mail as HTML. This is so embarassing.]
Johannes Schindelin wrote:
Show 15 quoted lines
>> diff --git a/upload-pack.c b/upload-pack.c
>> index c911e70..086eff6 100644
>> --- a/upload-pack.c
>> +++ b/upload-pack.c
>> @@ -616,6 +616,9 @@ int main(int argc, char **argv)
>>  	int i;
>>  	int strict = 0;
>>  
>> +	if (argv[0] && *argv[0])
>> +		git_extract_argv0_path(argv[0]);
>> +
>>     
>
> This is ugly.  The called function should already do it itself.
>   
Fair enough.
> Further, why not go the full nine yards and avoid the calculation 
> altogether, until it is necessary?  Then the change to add 
> lookup_program_in_path() would be nice and non-intrusive.

git.c will always need to do the calculation, to determine which command it is being invoked as, so is there much value in delaying until necessary?

If the code in git.c is left alone, then it needs to be eventually duplicated in upload-pack.c and receive-pack.c, or in exec_cmd.c. [I botched when sending out the patch originally and only sent it to Johannes and not the list, so it's my fault that the history of how this has evolved is unclear I'm afraid]

> IOW why not leave the function name as-is, and just enhance system_path() 
> to have a static variable "initialized", which does the whole calculation? 
> I.e. move the calculation from git.c to exec_cmd.c, but at the same time 
> do it only when needed.

Hmm, system_path and setup_path both use argv0_path; git.c would need to call an additional function in exec_cmd.c to get the "leafname" result of the calculation, though.

> And your change to set argv0_path from receive-pack and upload-pack would 
> be a second patch.
OK.
> And then the patch to add support to "glean" (did not know that word) the 
> path from the PATH (lookup_program_in_path()) could come as a third patch.

I think that once git-upload-pack.c et al get the argv[0] path over to setup_path() then there's nothing more to do; setup_path() already uses argv0_path in its list of paths to try. I'm confused to the reference to PATH, though: we're avoiding the PATH environment variable completely.

SRH
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 3 of 5 in “Glean libexec path from argv[0] for git-upload-pack and git-receive-pack.”
  1. Glean libexec path from argv[0] for git-upload-pack and git-receive-pack.Steve Haslam, Jul 30, 2008
  2. Johannes SchindelinJul 30, 2008
  3. Steve HaslamJul 30, 2008
  4. Johannes SchindelinJul 30, 2008
  5. Steve HaslamJul 30, 2008

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.