summaryrefslogtreecommitdiff
path: root/run-command.c
diff options
context:
space:
mode:
Diffstat (limited to 'run-command.c')
-rw-r--r--run-command.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/run-command.c b/run-command.c
index be6bc12..04a07e6 100644
--- a/run-command.c
+++ b/run-command.c
@@ -8,12 +8,12 @@
#include "string-list.h"
#include "quote.h"
#include "config.h"
+#include "packfile.h"
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)
@@ -211,9 +211,9 @@ static char *locate_in_PATH(const char *file)
return NULL;
}
-static int exists_in_PATH(const char *file)
+int exists_in_PATH(const char *command)
{
- char *r = locate_in_PATH(file);
+ char *r = locate_in_PATH(command);
int found = r != NULL;
free(r);
return found;
@@ -741,6 +741,9 @@ fail_pipe:
fflush(NULL);
+ if (cmd->close_object_store)
+ close_object_store(the_repository->objects);
+
#ifndef GIT_WINDOWS_NATIVE
{
int notify_pipe[2];
@@ -762,9 +765,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);
}
@@ -1045,6 +1046,7 @@ int run_command_v_opt_cd_env_tr2(const char **argv, int opt, const char *dir,
cmd.use_shell = opt & RUN_USING_SHELL ? 1 : 0;
cmd.clean_on_exit = opt & RUN_CLEAN_ON_EXIT ? 1 : 0;
cmd.wait_after_clean = opt & RUN_WAIT_AFTER_CLEAN ? 1 : 0;
+ cmd.close_object_store = opt & RUN_CLOSE_OBJECT_STORE ? 1 : 0;
cmd.dir = dir;
cmd.env = env;
cmd.trace2_child_class = tr2_class;
@@ -1337,7 +1339,7 @@ const char *find_hook(const char *name)
err = errno;
#endif
- if (err == EACCES && advice_ignored_hook) {
+ if (err == EACCES && advice_enabled(ADVICE_IGNORED_HOOK)) {
static struct string_list advise_given = STRING_LIST_INIT_DUP;
if (!string_list_lookup(&advise_given, name)) {
@@ -1887,8 +1889,21 @@ int run_auto_maintenance(int quiet)
return 0;
maint.git_cmd = 1;
+ maint.close_object_store = 1;
strvec_pushl(&maint.args, "maintenance", "run", "--auto", NULL);
strvec_push(&maint.args, quiet ? "--quiet" : "--no-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);
+}