summaryrefslogtreecommitdiff
path: root/builtin/merge.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2022-10-30 11:50:27 (GMT)
committerTaylor Blau <me@ttaylorr.com>2022-10-30 18:04:39 (GMT)
commit4120294cbf8e434c1de408434842d570eba0e25d (patch)
tree0def81e9ce1e3fea930a331fde52a8079368ec80 /builtin/merge.c
parent242aa33de0f18bf09dd147401af9b44cf961d532 (diff)
downloadgit-4120294cbf8e434c1de408434842d570eba0e25d.zip
git-4120294cbf8e434c1de408434842d570eba0e25d.tar.gz
git-4120294cbf8e434c1de408434842d570eba0e25d.tar.bz2
use child_process member "args" instead of string array variable
Use run_command() with a struct child_process variable and populate its "args" member directly instead of building a string array and passing it to run_command_v_opt(). This avoids the use of magic index numbers and makes simplifies the possible addition of more arguments in the future. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Taylor Blau <me@ttaylorr.com>
Diffstat (limited to 'builtin/merge.c')
-rw-r--r--builtin/merge.c32
1 files changed, 12 insertions, 20 deletions
diff --git a/builtin/merge.c b/builtin/merge.c
index 3bb49d8..3481577 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -347,33 +347,25 @@ out:
static void read_empty(const struct object_id *oid)
{
- int i = 0;
- const char *args[7];
-
- args[i++] = "read-tree";
- args[i++] = "-m";
- args[i++] = "-u";
- args[i++] = empty_tree_oid_hex();
- args[i++] = oid_to_hex(oid);
- args[i] = NULL;
+ struct child_process cmd = CHILD_PROCESS_INIT;
+
+ strvec_pushl(&cmd.args, "read-tree", "-m", "-u", empty_tree_oid_hex(),
+ oid_to_hex(oid), NULL);
+ cmd.git_cmd = 1;
- if (run_command_v_opt(args, RUN_GIT_CMD))
+ if (run_command(&cmd))
die(_("read-tree failed"));
}
static void reset_hard(const struct object_id *oid)
{
- int i = 0;
- const char *args[6];
-
- args[i++] = "read-tree";
- args[i++] = "-v";
- args[i++] = "--reset";
- args[i++] = "-u";
- args[i++] = oid_to_hex(oid);
- args[i] = NULL;
+ struct child_process cmd = CHILD_PROCESS_INIT;
+
+ strvec_pushl(&cmd.args, "read-tree", "-v", "--reset", "-u",
+ oid_to_hex(oid), NULL);
+ cmd.git_cmd = 1;
- if (run_command_v_opt(args, RUN_GIT_CMD))
+ if (run_command(&cmd))
die(_("read-tree failed"));
}