diff options
Diffstat (limited to 'run-command.c')
-rw-r--r-- | run-command.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/run-command.c b/run-command.c index a47699966c..aad03ab705 100644 --- a/run-command.c +++ b/run-command.c @@ -4,10 +4,6 @@ #include "sigchain.h" #include "argv-array.h" -#ifndef SHELL_PATH -# define SHELL_PATH "/bin/sh" -#endif - void child_process_init(struct child_process *child) { memset(child, 0, sizeof(*child)); @@ -561,7 +557,12 @@ int finish_command(struct child_process *cmd) int run_command(struct child_process *cmd) { - int code = start_command(cmd); + int code; + + if (cmd->out < 0 || cmd->err < 0) + die("BUG: run_command with a pipe can cause deadlock"); + + code = start_command(cmd); if (code) return code; return finish_command(cmd); @@ -834,19 +835,18 @@ int run_hook_le(const char *const *env, const char *name, ...) return ret; } -int run_hook_with_custom_index(const char *index_file, const char *name, ...) +int capture_command(struct child_process *cmd, struct strbuf *buf, size_t hint) { - const char *hook_env[3] = { NULL }; - char index[PATH_MAX]; - va_list args; - int ret; - - snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", index_file); - hook_env[0] = index; + cmd->out = -1; + if (start_command(cmd) < 0) + return -1; - va_start(args, name); - ret = run_hook_ve(hook_env, name, args); - va_end(args); + if (strbuf_read(buf, cmd->out, hint) < 0) { + close(cmd->out); + finish_command(cmd); /* throw away exit code */ + return -1; + } - return ret; + close(cmd->out); + return finish_command(cmd); } |