All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] Refactor list of environment variables to be sanitized
@ 2009-03-01  0:03 Junio C Hamano
  2009-03-01  0:03 ` [PATCH 2/4] git-init: inject some sanity to the option parser Junio C Hamano
  0 siblings, 1 reply; 43+ messages in thread
From: Junio C Hamano @ 2009-03-01  0:03 UTC (permalink / raw)
  To: git

When local process-to-process pipe transport spawns a subprocess,
it cleans up various git related variables to give the new process
a fresh environment.  The list of variables to cleanse is useful
in other places.
---
 cache.h   |    2 ++
 connect.c |   26 +++++++++++++++-----------
 2 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/cache.h b/cache.h
index 189151d..b72434f 100644
--- a/cache.h
+++ b/cache.h
@@ -389,6 +389,8 @@ extern void set_git_work_tree(const char *tree);
 
 #define ALTERNATE_DB_ENVIRONMENT "GIT_ALTERNATE_OBJECT_DIRECTORIES"
 
+extern const char *sanitize_git_env[];
+
 extern const char **get_pathspec(const char *prefix, const char **pathspec);
 extern void setup_work_tree(void);
 extern const char *setup_git_directory_gently(int *);
diff --git a/connect.c b/connect.c
index 2f23ab3..b4705ff 100644
--- a/connect.c
+++ b/connect.c
@@ -6,6 +6,20 @@
 #include "run-command.h"
 #include "remote.h"
 
+/*
+ * When spawning a subprocess in a fresh environment,
+ * these variables may need to be cleared
+ */
+const char *sanitize_git_env[] = {
+	ALTERNATE_DB_ENVIRONMENT,
+	DB_ENVIRONMENT,
+	GIT_DIR_ENVIRONMENT,
+	GIT_WORK_TREE_ENVIRONMENT,
+	GRAFT_ENVIRONMENT,
+	INDEX_ENVIRONMENT,
+	NULL
+};
+
 static char *server_capabilities;
 
 static int check_ref(const char *name, int len, unsigned int flags)
@@ -625,17 +639,7 @@ struct child_process *git_connect(int fd[2], const char *url_orig,
 		*arg++ = host;
 	}
 	else {
-		/* remove these from the environment */
-		const char *env[] = {
-			ALTERNATE_DB_ENVIRONMENT,
-			DB_ENVIRONMENT,
-			GIT_DIR_ENVIRONMENT,
-			GIT_WORK_TREE_ENVIRONMENT,
-			GRAFT_ENVIRONMENT,
-			INDEX_ENVIRONMENT,
-			NULL
-		};
-		conn->env = env;
+		conn->env = sanitize_git_env;
 		*arg++ = "sh";
 		*arg++ = "-c";
 	}
-- 
1.6.2.rc2.99.g9f3bb

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

end of thread, other threads:[~2009-03-06  1:41 UTC | newest]

Thread overview: 43+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-01  0:03 [PATCH 1/4] Refactor list of environment variables to be sanitized Junio C Hamano
2009-03-01  0:03 ` [PATCH 2/4] git-init: inject some sanity to the option parser Junio C Hamano
2009-03-01  0:03   ` [PATCH 3/4] Add init-serve, the remote side of "git init --remote=host:path" Junio C Hamano
2009-03-01  0:03     ` [PATCH 4/4] " Junio C Hamano
2009-03-01  3:16     ` [PATCH 3/4] Add init-serve, the remote side of " Jeff King
2009-03-01  5:54       ` Junio C Hamano
2009-03-01 10:00         ` Jeff King
2009-03-01 17:04           ` Shawn O. Pearce
2009-03-03  6:50             ` Subject: [PATCH] Push to create Junio C Hamano
2009-03-03  7:09               ` Jay Soffian
2009-03-03  7:09               ` Jeff King
2009-03-03  7:37                 ` Jay Soffian
2009-03-03  7:39                   ` Jay Soffian
2009-03-03  7:56                   ` Junio C Hamano
2009-03-03  8:02                     ` Jay Soffian
2009-03-03  8:04                       ` Junio C Hamano
2009-03-03  8:04                       ` Junio C Hamano
2009-03-03  8:16                         ` Jay Soffian
2009-03-03  8:23                     ` Jeff King
2009-03-03 19:57                       ` Jay Soffian
2009-03-04  5:42                         ` Jeff King
2009-03-04  6:35                           ` Junio C Hamano
2009-03-04 13:06                           ` Jay Soffian
2009-03-03  7:55                 ` Junio C Hamano
2009-03-03  8:06                   ` Jeff King
2009-03-03  8:22                     ` Junio C Hamano
2009-03-03  8:27                       ` Jeff King
2009-03-03  8:30                         ` Junio C Hamano
2009-03-03  8:41                           ` Jay Soffian
2009-03-03  9:23                           ` Theodore Tso
2009-03-03 10:39                             ` Johannes Schindelin
2009-03-04 17:58                               ` Theodore Tso
2009-03-06  1:37                                 ` Miles Bader
2009-03-03 18:41                             ` Shawn O. Pearce
2009-03-04  8:32                               ` [RFC/PATCH 1/2] improve missing repository error message Jeff King
2009-03-04  9:19                                 ` Matthieu Moy
2009-03-04 10:35                                   ` Jeff King
2009-03-04 18:57                                 ` Shawn O. Pearce
2009-03-05 10:36                                   ` Jeff King
2009-03-04  8:42                               ` [RFC/PATCH 2/2] make remote hangup warnings more friendly Jeff King
2009-03-04 19:04                                 ` Shawn O. Pearce
2009-03-05 10:45                                   ` Jeff King
2009-03-03 21:08                   ` Subject: [PATCH] Push to create Daniel Barkalow

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.