Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>2021-11-26 01:52:24 +0300
committerJunio C Hamano <gitster@pobox.com>2021-11-26 09:15:08 +0300
commitc7c4bdeccf3e737e6e674cd9f0828922e629ab06 (patch)
tree941fea7dd2227732ade5722068ed141ab0cf8217 /run-command.h
parent26a15355d60a0a5be08250512c05e1447036dce3 (diff)
run-command API: remove "env" member, always use "env_array"
Remove the "env" member from "struct child_process" in favor of always using the "env_array". As with the preceding removal of "argv" in favor of "args" this gets rid of current and future oddities around memory management at the API boundary (see the amended API docs). For some of the conversions we can replace patterns like: child.env = env->v; With: strvec_pushv(&child.env_array, env->v); But for others we need to guard the strvec_pushv() with a NULL check, since we're not passing in the "v" member of a "struct strvec", e.g. in the case of tmp_objdir_env()'s return value. Ideally we'd rename the "env_array" member to simply "env" as a follow-up, since it and "args" are now inconsistent in not having an "_array" suffix, and seemingly without any good reason, unless we look at the history of how they came to be. But as we've currently got 122 in-tree hits for a "git grep env_array" let's leave that for now (and possibly forever). Doing that rename would be too disruptive. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'run-command.h')
-rw-r--r--run-command.h34
1 files changed, 17 insertions, 17 deletions
diff --git a/run-command.h b/run-command.h
index c0d1210cc6..2be5f5d642 100644
--- a/run-command.h
+++ b/run-command.h
@@ -56,6 +56,23 @@ struct child_process {
* `finish_command` (or during `start_command` when it is unsuccessful).
*/
struct strvec args;
+
+ /**
+ * Like .args the .env_array is a `struct strvec'.
+ *
+ * To modify the environment of the sub-process, specify an array of
+ * environment settings. Each string in the array manipulates the
+ * environment.
+ *
+ * - If the string is of the form "VAR=value", i.e. it contains '='
+ * the variable is added to the child process's environment.
+ *
+ * - If the string does not contain '=', it names an environment
+ * variable that will be removed from the child process's environment.
+ *
+ * The memory in .env_array will be cleaned up automatically during
+ * `finish_command` (or during `start_command` when it is unsuccessful).
+ */
struct strvec env_array;
pid_t pid;
@@ -92,23 +109,6 @@ struct child_process {
*/
const char *dir;
- /**
- * To modify the environment of the sub-process, specify an array of
- * string pointers (NULL terminated) in .env:
- *
- * - If the string is of the form "VAR=value", i.e. it contains '='
- * the variable is added to the child process's environment.
- *
- * - If the string does not contain '=', it names an environment
- * variable that will be removed from the child process's environment.
- *
- * If the .env member is NULL, `start_command` will point it at the
- * .env_array `strvec` (so you may use one or the other, but not both).
- * The memory in .env_array will be cleaned up automatically during
- * `finish_command` (or during `start_command` when it is unsuccessful).
- */
- const char *const *env;
-
unsigned no_stdin:1;
unsigned no_stdout:1;
unsigned no_stderr:1;