diff options
Diffstat (limited to 'libbb/run-command.c')
-rw-r--r-- | libbb/run-command.c | 51 |
1 files changed, 4 insertions, 47 deletions
diff --git a/libbb/run-command.c b/libbb/run-command.c index b05c734d0..d4d78e9bc 100644 --- a/libbb/run-command.c +++ b/libbb/run-command.c | |||
@@ -1,6 +1,6 @@ | |||
1 | #include "cache.h" | 1 | #include "libbb.h" |
2 | #include "run-command.h" | 2 | #include "run-command.h" |
3 | #include "exec_cmd.h" | 3 | #include "git.h" |
4 | 4 | ||
5 | static inline void close_pair(int fd[2]) | 5 | static inline void close_pair(int fd[2]) |
6 | { | 6 | { |
@@ -168,9 +168,11 @@ int start_command(struct child_process *cmd) | |||
168 | env = env_setenv(env, *cmd->env); | 168 | env = env_setenv(env, *cmd->env); |
169 | } | 169 | } |
170 | 170 | ||
171 | #if 0 | ||
171 | if (cmd->git_cmd) { | 172 | if (cmd->git_cmd) { |
172 | cmd->argv = prepare_git_cmd(cmd->argv); | 173 | cmd->argv = prepare_git_cmd(cmd->argv); |
173 | } | 174 | } |
175 | #endif | ||
174 | 176 | ||
175 | cmd->pid = mingw_spawnvpe(cmd->argv[0], cmd->argv, env); | 177 | cmd->pid = mingw_spawnvpe(cmd->argv[0], cmd->argv, env); |
176 | 178 | ||
@@ -352,48 +354,3 @@ int finish_async(struct async *async) | |||
352 | #endif | 354 | #endif |
353 | return ret; | 355 | return ret; |
354 | } | 356 | } |
355 | |||
356 | int run_hook(const char *index_file, const char *name, ...) | ||
357 | { | ||
358 | struct child_process hook; | ||
359 | const char **argv = NULL, *env[2]; | ||
360 | char index[PATH_MAX]; | ||
361 | va_list args; | ||
362 | int ret; | ||
363 | size_t i = 0, alloc = 0; | ||
364 | |||
365 | if (access(git_path("hooks/%s", name), X_OK) < 0) | ||
366 | return 0; | ||
367 | |||
368 | va_start(args, name); | ||
369 | ALLOC_GROW(argv, i + 1, alloc); | ||
370 | argv[i++] = git_path("hooks/%s", name); | ||
371 | while (argv[i-1]) { | ||
372 | ALLOC_GROW(argv, i + 1, alloc); | ||
373 | argv[i++] = va_arg(args, const char *); | ||
374 | } | ||
375 | va_end(args); | ||
376 | |||
377 | memset(&hook, 0, sizeof(hook)); | ||
378 | hook.argv = argv; | ||
379 | hook.no_stdin = 1; | ||
380 | hook.stdout_to_stderr = 1; | ||
381 | if (index_file) { | ||
382 | snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", index_file); | ||
383 | env[0] = index; | ||
384 | env[1] = NULL; | ||
385 | hook.env = env; | ||
386 | } | ||
387 | |||
388 | ret = start_command(&hook); | ||
389 | free(argv); | ||
390 | if (ret) { | ||
391 | warning("Could not spawn %s", argv[0]); | ||
392 | return ret; | ||
393 | } | ||
394 | ret = finish_command(&hook); | ||
395 | if (ret == -ERR_RUN_COMMAND_WAITPID_SIGNAL) | ||
396 | warning("%s exited due to uncaught signal", argv[0]); | ||
397 | |||
398 | return ret; | ||
399 | } | ||