local push/pull env cleanup
PATCH 1/1 local push/pull env cleanup
From: Matt Draisey <[email protected]>
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(-)
connect.c +6 -1
@@ -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 ];
Quoted 18 lines · Matt Draisey
From: Matt Draisey <[email protected]>
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(-)connect.c +0
-1@@ -644,8 +644,13 @@ int git_connect(int fd[2], char *url, co ssh_basename++;execlp (ssh, ssh_basename, host, command,NULL ); } -else
connect.c int git_connect(int fd[2], char *url, co · line 656
Quoted 10 lines
connect.c +6
-0+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.