зеркало из https://github.com/microsoft/git.git
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:
Родитель
e169b97459
Коммит
0077138cd9
|
@ -192,7 +192,6 @@ static int run_receive_hook(const char *hook_name)
|
||||||
static int run_update_hook(struct command *cmd)
|
static int run_update_hook(struct command *cmd)
|
||||||
{
|
{
|
||||||
static const char update_hook[] = "hooks/update";
|
static const char update_hook[] = "hooks/update";
|
||||||
struct child_process proc;
|
|
||||||
const char *argv[5];
|
const char *argv[5];
|
||||||
|
|
||||||
if (access(update_hook, X_OK) < 0)
|
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[3] = sha1_to_hex(cmd->new_sha1);
|
||||||
argv[4] = NULL;
|
argv[4] = NULL;
|
||||||
|
|
||||||
memset(&proc, 0, sizeof(proc));
|
return hook_status(run_command_v_opt(argv, RUN_COMMAND_NO_STDIN |
|
||||||
proc.argv = argv;
|
RUN_COMMAND_STDOUT_TO_STDERR),
|
||||||
proc.no_stdin = 1;
|
update_hook);
|
||||||
proc.stdout_to_stderr = 1;
|
|
||||||
|
|
||||||
return hook_status(run_command(&proc), update_hook);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int is_ref_checked_out(const char *ref)
|
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] },
|
{ "B", temp[2] },
|
||||||
{ NULL }
|
{ NULL }
|
||||||
};
|
};
|
||||||
struct child_process child;
|
const char *args[] = { "sh", "-c", NULL, NULL };
|
||||||
const char *args[20];
|
|
||||||
int status, fd, i;
|
int status, fd, i;
|
||||||
struct stat st;
|
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);
|
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[2] = cmd.buf;
|
||||||
args[3] = NULL;
|
status = run_command_v_opt(args, 0);
|
||||||
|
|
||||||
status = run_command(&child);
|
|
||||||
if (status < -ERR_RUN_COMMAND_FORK)
|
if (status < -ERR_RUN_COMMAND_FORK)
|
||||||
; /* failure in run-command */
|
; /* failure in run-command */
|
||||||
else
|
else
|
||||||
|
|
|
@ -3,45 +3,20 @@
|
||||||
#include "exec_cmd.h"
|
#include "exec_cmd.h"
|
||||||
|
|
||||||
static const char *pgm;
|
static const char *pgm;
|
||||||
static const char *arguments[9];
|
|
||||||
static int one_shot, quiet;
|
static int one_shot, quiet;
|
||||||
static int err;
|
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)
|
static int merge_entry(int pos, const char *path)
|
||||||
{
|
{
|
||||||
int found;
|
int found;
|
||||||
|
const char *arguments[] = { pgm, "", "", "", path, "", "", "", NULL };
|
||||||
|
char hexbuf[4][60];
|
||||||
|
char ownbuf[4][60];
|
||||||
|
|
||||||
if (pos >= active_nr)
|
if (pos >= active_nr)
|
||||||
die("git merge-index: %s not in the cache", path);
|
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;
|
found = 0;
|
||||||
do {
|
do {
|
||||||
static char hexbuf[4][60];
|
|
||||||
static char ownbuf[4][60];
|
|
||||||
struct cache_entry *ce = active_cache[pos];
|
struct cache_entry *ce = active_cache[pos];
|
||||||
int stage = ce_stage(ce);
|
int stage = ce_stage(ce);
|
||||||
|
|
||||||
|
@ -55,7 +30,16 @@ static int merge_entry(int pos, const char *path)
|
||||||
} while (++pos < active_nr);
|
} while (++pos < active_nr);
|
||||||
if (!found)
|
if (!found)
|
||||||
die("git merge-index: %s not in the cache", path);
|
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;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче