summaryrefslogtreecommitdiff
path: root/builtin/add.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2014-03-28 13:51:04 -0700
committerJunio C Hamano <gitster@pobox.com>2014-03-28 13:51:05 -0700
commitc301a23ff8701ae2a50c62c00c400f87e6585511 (patch)
treecd1213d0b7473ec050bcb7cd3a2addeaf049b4ba /builtin/add.c
parentfe2a4f1591db57473b296a004a7b1c74449aa53b (diff)
parentc45a18e88f47fc9b23f8e8e7b14a030434917a66 (diff)
downloadgit-c301a23ff8701ae2a50c62c00c400f87e6585511.tar.gz
Merge branch 'fr/add-interactive-argv-array'
* fr/add-interactive-argv-array: add: use struct argv_array in run_add_interactive()
Diffstat (limited to 'builtin/add.c')
-rw-r--r--builtin/add.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/builtin/add.c b/builtin/add.c
index 4b045bace1..459208a326 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -15,6 +15,7 @@
#include "diffcore.h"
#include "revision.h"
#include "bulk-checkin.h"
+#include "argv-array.h"
static const char * const builtin_add_usage[] = {
N_("git add [options] [--] <pathspec>..."),
@@ -141,23 +142,21 @@ static void refresh(int verbose, const struct pathspec *pathspec)
int run_add_interactive(const char *revision, const char *patch_mode,
const struct pathspec *pathspec)
{
- int status, ac, i;
- const char **args;
+ int status, i;
+ struct argv_array argv = ARGV_ARRAY_INIT;
- args = xcalloc(sizeof(const char *), (pathspec->nr + 6));
- ac = 0;
- args[ac++] = "add--interactive";
+ argv_array_push(&argv, "add--interactive");
if (patch_mode)
- args[ac++] = patch_mode;
+ argv_array_push(&argv, patch_mode);
if (revision)
- args[ac++] = revision;
- args[ac++] = "--";
+ argv_array_push(&argv, revision);
+ argv_array_push(&argv, "--");
for (i = 0; i < pathspec->nr; i++)
/* pass original pathspec, to be re-parsed */
- args[ac++] = pathspec->items[i].original;
+ argv_array_push(&argv, pathspec->items[i].original);
- status = run_command_v_opt(args, RUN_GIT_CMD);
- free(args);
+ status = run_command_v_opt(argv.argv, RUN_GIT_CMD);
+ argv_array_clear(&argv);
return status;
}