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 <tali@xxxxxxxxxxxxxx> --- 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 - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html