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

Re: [PATCH] local push/pull env cleanup

From
Junio C Hamano <junkio@cox.net>
Date
Jan 20, 2006, 01:13 UTC
Message-ID
<7vhd7z8zx9.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20060119205803.308.78669.stgit@della.draisey.ca>
Matt Draisey <matt@draisey.ca> writes:
Show 28 quoted lines
> From: Matt Draisey <matt@draisey.ca>
>
> remove environment variables relating to the current repository
> before execing the 'remote' half of a local push or pull operation
> ---
>
>  connect.c |    7 ++++++-
>  1 files changed, 6 insertions(+), 1 deletions(-)
>
> diff --git a/connect.c b/connect.c
> index d6f4e4c..50cc879 100644
> --- a/connect.c
> +++ b/connect.c
> @@ -644,8 +644,13 @@ int git_connect(int fd[2], char *url, co
>  				ssh_basename++;
>  			execlp(ssh, ssh_basename, host, command, NULL);
>  		}
> -		else
> +		else {
> +			unsetenv("GIT_DIR");
> +			unsetenv("GIT_INDEX_FILE");
> +			unsetenv("GIT_OBJECT_DIRECTORY");
> +			unsetenv("GIT_ALTERNATE_OBJECT_DIRECTORIES");
>  			execlp("sh", "sh", "-c", command, NULL);
> +		}
>  		die("exec failed");
>  	}		
>  	fd[0] = pipefd[0][0];

There are platforms that lack unsetenv(3C), so you also need an emulation similar to what we do for setenv(3) in compat/setenv.c.

I suspect GIT_DIR is automatically set up by enter_repo on the other side when upload-pack (for fetch case) or receive-pack (for push case) is run, so that may not be necessary, but cleaning it along with others here sounds sane, even if only for consistency's sake.

Previous: Matt Draisey
Message 2 of 2 in “local push/pull env cleanup”
  1. local push/pull env cleanupMatt Draisey, Jan 19, 2006
  2. Junio C HamanoJan 20, 2006

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.