mirror of
https://github.com/git/git.git
synced 2024-11-23 18:05:29 +08:00
Simplify some instances of run_command() by using run_command_v_opt().
Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
e169b97459
commit
0077138cd9
@ -192,7 +192,6 @@ static int run_receive_hook(const char *hook_name)
|
||||
static int run_update_hook(struct command *cmd)
|
||||
{
|
||||
static const char update_hook[] = "hooks/update";
|
||||
struct child_process proc;
|
||||
const char *argv[5];
|
||||
|
||||
if (access(update_hook, X_OK) < 0)
|
||||
@ -204,12 +203,9 @@ static int run_update_hook(struct command *cmd)
|
||||
argv[3] = sha1_to_hex(cmd->new_sha1);
|
||||
argv[4] = NULL;
|
||||
|
||||
memset(&proc, 0, sizeof(proc));
|
||||
proc.argv = argv;
|
||||
proc.no_stdin = 1;
|
||||
proc.stdout_to_stderr = 1;
|
||||
|
||||
return hook_status(run_command(&proc), update_hook);
|
||||
return hook_status(run_command_v_opt(argv, RUN_COMMAND_NO_STDIN |
|
||||
RUN_COMMAND_STDOUT_TO_STDERR),
|
||||
update_hook);
|
||||
}
|
||||
|
||||
static int is_ref_checked_out(const char *ref)
|
||||
|
11
ll-merge.c
11
ll-merge.c
@ -175,8 +175,7 @@ static int ll_ext_merge(const struct ll_merge_driver *fn,
|
||||
{ "B", temp[2] },
|
||||
{ NULL }
|
||||
};
|
||||
struct child_process child;
|
||||
const char *args[20];
|
||||
const char *args[] = { "sh", "-c", NULL, NULL };
|
||||
int status, fd, i;
|
||||
struct stat st;
|
||||
|
||||
@ -191,14 +190,8 @@ static int ll_ext_merge(const struct ll_merge_driver *fn,
|
||||
|
||||
strbuf_expand(&cmd, fn->cmdline, strbuf_expand_dict_cb, &dict);
|
||||
|
||||
memset(&child, 0, sizeof(child));
|
||||
child.argv = args;
|
||||
args[0] = "sh";
|
||||
args[1] = "-c";
|
||||
args[2] = cmd.buf;
|
||||
args[3] = NULL;
|
||||
|
||||
status = run_command(&child);
|
||||
status = run_command_v_opt(args, 0);
|
||||
if (status < -ERR_RUN_COMMAND_FORK)
|
||||
; /* failure in run-command */
|
||||
else
|
||||
|
@ -3,45 +3,20 @@
|
||||
#include "exec_cmd.h"
|
||||
|
||||
static const char *pgm;
|
||||
static const char *arguments[9];
|
||||
static int one_shot, quiet;
|
||||
static int err;
|
||||
|
||||
static void run_program(void)
|
||||
{
|
||||
struct child_process child;
|
||||
memset(&child, 0, sizeof(child));
|
||||
child.argv = arguments;
|
||||
if (run_command(&child)) {
|
||||
if (one_shot) {
|
||||
err++;
|
||||
} else {
|
||||
if (!quiet)
|
||||
die("merge program failed");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int merge_entry(int pos, const char *path)
|
||||
{
|
||||
int found;
|
||||
const char *arguments[] = { pgm, "", "", "", path, "", "", "", NULL };
|
||||
char hexbuf[4][60];
|
||||
char ownbuf[4][60];
|
||||
|
||||
if (pos >= active_nr)
|
||||
die("git merge-index: %s not in the cache", path);
|
||||
arguments[0] = pgm;
|
||||
arguments[1] = "";
|
||||
arguments[2] = "";
|
||||
arguments[3] = "";
|
||||
arguments[4] = path;
|
||||
arguments[5] = "";
|
||||
arguments[6] = "";
|
||||
arguments[7] = "";
|
||||
arguments[8] = NULL;
|
||||
found = 0;
|
||||
do {
|
||||
static char hexbuf[4][60];
|
||||
static char ownbuf[4][60];
|
||||
struct cache_entry *ce = active_cache[pos];
|
||||
int stage = ce_stage(ce);
|
||||
|
||||
@ -55,7 +30,16 @@ static int merge_entry(int pos, const char *path)
|
||||
} while (++pos < active_nr);
|
||||
if (!found)
|
||||
die("git merge-index: %s not in the cache", path);
|
||||
run_program();
|
||||
|
||||
if (run_command_v_opt(arguments, 0)) {
|
||||
if (one_shot)
|
||||
err++;
|
||||
else {
|
||||
if (!quiet)
|
||||
die("merge program failed");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user