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

Re: [PATCH] use only the PATH for exec'ing git commands

From
Alex Riesen <raa.lkml@gmail.com>
Date
Oct 22, 2007, 19:01 UTC
Message-ID
<20071022190102.GA23714@steel.home>
In-Reply-To
<20071022170148.GB29642@srparish.net>
Scott R Parish, Mon, Oct 22, 2007 19:01:48 +0200:
Show 9 quoted lines
> +static void add_path(struct strbuf *out, const char *path)
> +{
> +	if (path && strlen(path)) {
> +		if (is_absolute_path(path))
> +			strbuf_addstr(out, path);
> +		else
> +			strbuf_addstr(out, make_absolute_path(path));
> +
> +		strbuf_addch(out, ':');
Shouldn't it break MingW32 native port?
Show 15 quoted lines
> +	}
> +}
> +
> +void setup_path(const char *cmd_path)
> +{
> +	const char *old_path = getenv("PATH");
> +	struct strbuf new_path;
> +
> +	strbuf_init(&new_path, 0);
> +
> +	add_path(&new_path, argv_exec_path);
> +	add_path(&new_path, getenv(EXEC_PATH_ENVIRONMENT));
> +	add_path(&new_path, builtin_exec_path);
> +	add_path(&new_path, cmd_path);
> +		
trailing space
> +	if (old_path)
> +		strbuf_addstr(&new_path, old_path);
> +	else 
> +		strbuf_addstr(&new_path, "/usr/local/bin:/usr/bin:/bin");

the default PATH is platform-dependent. Git is multi-platform. You should consider putting the path list somewhere in Makefile, config.mak or configure.

> +
> +	setenv("PATH", new_path.buf, 1);
Previous: Johannes SchindelinNext: Eric Merritt
Message 3 of 7 in “use only the PATH for exec'ing git commands”
  1. use only the PATH for exec'ing git commandsScott R Parish, Oct 22, 2007
  2. Johannes SchindelinOct 22, 2007
  3. Alex RiesenOct 22, 2007
  4. Eric MerrittOct 22, 2007
  5. use only the PATH for exec'ing git commandsScott Parish, Oct 23, 2007
  6. Alex RiesenOct 23, 2007
  7. Scott R ParishOct 23, 2007

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.