summaryrefslogtreecommitdiff
path: root/merge-index.c
diff options
context:
space:
mode:
authorJohannes Sixt <j6t@kdbg.org>2009-06-08 20:34:29 (GMT)
committerJunio C Hamano <gitster@pobox.com>2009-06-09 07:15:57 (GMT)
commit0077138cd9d4f94636184553afd8b33b98d320a1 (patch)
treec2bca49295ed40948af4f7750986ffd71b61d111 /merge-index.c
parente169b974593c27ba7a0d7f63ec0ec40373cb64bb (diff)
downloadgit-0077138cd9d4f94636184553afd8b33b98d320a1.zip
git-0077138cd9d4f94636184553afd8b33b98d320a1.tar.gz
git-0077138cd9d4f94636184553afd8b33b98d320a1.tar.bz2
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>
Diffstat (limited to 'merge-index.c')
-rw-r--r--merge-index.c42
1 files changed, 13 insertions, 29 deletions
diff --git a/merge-index.c b/merge-index.c
index aa9cf23..19ddd03 100644
--- a/merge-index.c
+++ b/merge-index.c
@@ -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;
}