Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRohit Ashiwal <rohit.ashiwal265@gmail.com>2019-07-02 12:11:27 +0300
committerJunio C Hamano <gitster@pobox.com>2019-07-02 22:08:08 +0300
commit265ab48f2646605b27e1343ac50efa9763690f04 (patch)
treecec22311a71d6565b0b3078a38a473bc3a100036 /sequencer.c
parent918d1e6ed89738afad63a5cfc92668ac77a7be95 (diff)
sequencer: use argv_array in reset_merge
Avoid using magic numbers for array size and index under `reset_merge` function. Use `argv_array` instead. This will make code shorter and easier to extend. Signed-off-by: Rohit Ashiwal <rohit.ashiwal265@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sequencer.c')
-rw-r--r--sequencer.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/sequencer.c b/sequencer.c
index e8779c7cc5..0b858ca8e0 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -2734,13 +2734,18 @@ static int rollback_is_safe(void)
static int reset_merge(const struct object_id *oid)
{
- const char *argv[4]; /* reset --merge <arg> + NULL */
+ int ret;
+ struct argv_array argv = ARGV_ARRAY_INIT;
- argv[0] = "reset";
- argv[1] = "--merge";
- argv[2] = oid_to_hex(oid);
- argv[3] = NULL;
- return run_command_v_opt(argv, RUN_GIT_CMD);
+ argv_array_pushl(&argv, "reset", "--merge", NULL);
+
+ if (!is_null_oid(oid))
+ argv_array_push(&argv, oid_to_hex(oid));
+
+ ret = run_command_v_opt(argv.argv, RUN_GIT_CMD);
+ argv_array_clear(&argv);
+
+ return ret;
}
static int rollback_single_pick(struct repository *r)