{"thread":{"id":"3104","subject":"[PATCH] local push/pull env cleanup","startedAt":"2006-01-19T20:58:03Z","lastAt":"2006-01-20T01:13:06Z","messageCount":2,"participants":["Matt Draisey","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"14917","messageId":"20060119205803.308.78669.stgit@della.draisey.ca","threadId":"3104","inReplyTo":null,"subject":"[PATCH] local push/pull env cleanup","fromName":"Matt Draisey","fromEmail":"matt@draisey.ca","sentAt":"2006-01-19T20:58:03Z","receivedAt":"2006-01-19T20:58:03Z","isPatch":true,"sender":{"key":"matt@draisey.ca","avatar":null},"body":"From: Matt Draisey <matt@draisey.ca>\n\nremove environment variables relating to the current repository\nbefore execing the 'remote' half of a local push or pull operation\n---\n\n connect.c |    7 ++++++-\n 1 files changed, 6 insertions(+), 1 deletions(-)\n\ndiff --git a/connect.c b/connect.c\nindex d6f4e4c..50cc879 100644\n--- a/connect.c\n+++ b/connect.c\n@@ -644,8 +644,13 @@ int git_connect(int fd[2], char *url, co\n \t\t\t\tssh_basename++;\n \t\t\texeclp(ssh, ssh_basename, host, command, NULL);\n \t\t}\n-\t\telse\n+\t\telse {\n+\t\t\tunsetenv(\"GIT_DIR\");\n+\t\t\tunsetenv(\"GIT_INDEX_FILE\");\n+\t\t\tunsetenv(\"GIT_OBJECT_DIRECTORY\");\n+\t\t\tunsetenv(\"GIT_ALTERNATE_OBJECT_DIRECTORIES\");\n \t\t\texeclp(\"sh\", \"sh\", \"-c\", command, NULL);\n+\t\t}\n \t\tdie(\"exec failed\");\n \t}\t\t\n \tfd[0] = pipefd[0][0];\n"},{"id":"14930","messageId":"7vhd7z8zx9.fsf@assigned-by-dhcp.cox.net","threadId":"3104","inReplyTo":"20060119205803.308.78669.stgit@della.draisey.ca","subject":"Re: [PATCH] local push/pull env cleanup","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-01-20T01:13:06Z","receivedAt":"2006-01-20T01:13:06Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matt Draisey <matt@draisey.ca> writes:\n\n> From: Matt Draisey <matt@draisey.ca>\n>\n> remove environment variables relating to the current repository\n> before execing the 'remote' half of a local push or pull operation\n> ---\n>\n>  connect.c |    7 ++++++-\n>  1 files changed, 6 insertions(+), 1 deletions(-)\n>\n> diff --git a/connect.c b/connect.c\n> index d6f4e4c..50cc879 100644\n> --- a/connect.c\n> +++ b/connect.c\n> @@ -644,8 +644,13 @@ int git_connect(int fd[2], char *url, co\n>  \t\t\t\tssh_basename++;\n>  \t\t\texeclp(ssh, ssh_basename, host, command, NULL);\n>  \t\t}\n> -\t\telse\n> +\t\telse {\n> +\t\t\tunsetenv(\"GIT_DIR\");\n> +\t\t\tunsetenv(\"GIT_INDEX_FILE\");\n> +\t\t\tunsetenv(\"GIT_OBJECT_DIRECTORY\");\n> +\t\t\tunsetenv(\"GIT_ALTERNATE_OBJECT_DIRECTORIES\");\n>  \t\t\texeclp(\"sh\", \"sh\", \"-c\", command, NULL);\n> +\t\t}\n>  \t\tdie(\"exec failed\");\n>  \t}\t\t\n>  \tfd[0] = pipefd[0][0];\n\nThere are platforms that lack unsetenv(3C), so you also need an\nemulation similar to what we do for setenv(3) in\ncompat/setenv.c.\n\nI suspect GIT_DIR is automatically set up by enter_repo on the\nother side when upload-pack (for fetch case) or receive-pack\n(for push case) is run, so that may not be necessary, but\ncleaning it along with others here sounds sane, even if only for\nconsistency's sake.\n"}]}