git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] local push/pull env cleanup
@ 2006-01-19 20:58 Matt Draisey
  2006-01-20  1:13 ` Junio C Hamano
  0 siblings, 1 reply; 2+ messages in thread
From: Matt Draisey @ 2006-01-19 20:58 UTC (permalink / raw
  To: git

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];

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] local push/pull env cleanup
  2006-01-19 20:58 [PATCH] local push/pull env cleanup Matt Draisey
@ 2006-01-20  1:13 ` Junio C Hamano
  0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2006-01-20  1:13 UTC (permalink / raw
  To: Matt Draisey; +Cc: git

Matt Draisey <matt@draisey.ca> writes:

> 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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-01-20  1:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-19 20:58 [PATCH] local push/pull env cleanup Matt Draisey
2006-01-20  1:13 ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).