[PATCH] allow commands to be executed in submodules
From: Martin Waitz <hidden>
Date: 2016-06-15 22:43:11
Add an extra "submodule" field to struct child_process to be able to easily start commands which are to be executed in a submodule repository. Signed-off-by: Martin Waitz <redacted> --- run-command.c | 13 ++++++ run-command.h | 1 + 2 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/run-command.c b/run-command.c
index eff523e..c2475e4 100644
--- a/run-command.c
+++ b/run-command.c@@ -73,6 +73,19 @@ int start_command(struct child_process *cmd) close(cmd->out); } + if (cmd->submodule) { + int err = chdir(cmd->submodule); + if (err) { + die("cannot exec %s in %s.", + cmd->argv[0], cmd->submodule); + } + /* don't inherit supermodule environment */ + unsetenv(GIT_DIR_ENVIRONMENT); + unsetenv(DB_ENVIRONMENT); + unsetenv(INDEX_ENVIRONMENT); + unsetenv(GRAFT_ENVIRONMENT); + } + if (cmd->git_cmd) { execv_git_cmd(cmd->argv); } else {
diff --git a/run-command.h b/run-command.h
index 3680ef9..2940186 100644
--- a/run-command.h
+++ b/run-command.h@@ -16,6 +16,7 @@ struct child_process { pid_t pid; int in; int out; + const char *submodule; unsigned close_in:1; unsigned close_out:1; unsigned no_stdin:1;
--
1.5.2.2.g081e
--
Martin Waitz