diff options
author | René Scharfe <l.s.r@web.de> | 2022-10-30 11:50:27 (GMT) |
---|---|---|
committer | Taylor Blau <me@ttaylorr.com> | 2022-10-30 18:04:39 (GMT) |
commit | 4120294cbf8e434c1de408434842d570eba0e25d (patch) | |
tree | 0def81e9ce1e3fea930a331fde52a8079368ec80 /builtin/merge.c | |
parent | 242aa33de0f18bf09dd147401af9b44cf961d532 (diff) | |
download | git-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.c | 32 |
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")); } |