summaryrefslogtreecommitdiff
path: root/run-command.c
diff options
context:
space:
mode:
Diffstat (limited to 'run-command.c')
-rw-r--r--run-command.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/run-command.c b/run-command.c
index be6bc128cd..f329391154 100644
--- a/run-command.c
+++ b/run-command.c
@@ -11,9 +11,8 @@
void child_process_init(struct child_process *child)
{
- memset(child, 0, sizeof(*child));
- strvec_init(&child->args);
- strvec_init(&child->env_array);
+ struct child_process blank = CHILD_PROCESS_INIT;
+ memcpy(child, &blank, sizeof(*child));
}
void child_process_clear(struct child_process *child)
@@ -762,9 +761,7 @@ fail_pipe:
notify_pipe[0] = notify_pipe[1] = -1;
if (cmd->no_stdin || cmd->no_stdout || cmd->no_stderr) {
- null_fd = open("/dev/null", O_RDWR | O_CLOEXEC);
- if (null_fd < 0)
- die_errno(_("open /dev/null failed"));
+ null_fd = xopen("/dev/null", O_RDWR | O_CLOEXEC);
set_cloexec(null_fd);
}
@@ -1096,7 +1093,7 @@ static NORETURN void die_async(const char *err, va_list params)
static int async_die_is_recursing(void)
{
void *ret = pthread_getspecific(async_die_counter);
- pthread_setspecific(async_die_counter, (void *)1);
+ pthread_setspecific(async_die_counter, &async_die_counter); /* set to any non-NULL valid pointer */
return ret != NULL;
}
@@ -1892,3 +1889,15 @@ int run_auto_maintenance(int quiet)
return run_command(&maint);
}
+
+void prepare_other_repo_env(struct strvec *env_array, const char *new_git_dir)
+{
+ const char * const *var;
+
+ for (var = local_repo_env; *var; var++) {
+ if (strcmp(*var, CONFIG_DATA_ENVIRONMENT) &&
+ strcmp(*var, CONFIG_COUNT_ENVIRONMENT))
+ strvec_push(env_array, *var);
+ }
+ strvec_pushf(env_array, "%s=%s", GIT_DIR_ENVIRONMENT, new_git_dir);
+}