mirror of
https://github.com/git/git
synced 2024-08-27 11:39:22 +00:00
Merge branch 'fr/add-interactive-argv-array'
* fr/add-interactive-argv-array: add: use struct argv_array in run_add_interactive()
This commit is contained in:
commit
c301a23ff8
|
@ -15,6 +15,7 @@
|
||||||
#include "diffcore.h"
|
#include "diffcore.h"
|
||||||
#include "revision.h"
|
#include "revision.h"
|
||||||
#include "bulk-checkin.h"
|
#include "bulk-checkin.h"
|
||||||
|
#include "argv-array.h"
|
||||||
|
|
||||||
static const char * const builtin_add_usage[] = {
|
static const char * const builtin_add_usage[] = {
|
||||||
N_("git add [options] [--] <pathspec>..."),
|
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,
|
int run_add_interactive(const char *revision, const char *patch_mode,
|
||||||
const struct pathspec *pathspec)
|
const struct pathspec *pathspec)
|
||||||
{
|
{
|
||||||
int status, ac, i;
|
int status, i;
|
||||||
const char **args;
|
struct argv_array argv = ARGV_ARRAY_INIT;
|
||||||
|
|
||||||
args = xcalloc(sizeof(const char *), (pathspec->nr + 6));
|
argv_array_push(&argv, "add--interactive");
|
||||||
ac = 0;
|
|
||||||
args[ac++] = "add--interactive";
|
|
||||||
if (patch_mode)
|
if (patch_mode)
|
||||||
args[ac++] = patch_mode;
|
argv_array_push(&argv, patch_mode);
|
||||||
if (revision)
|
if (revision)
|
||||||
args[ac++] = revision;
|
argv_array_push(&argv, revision);
|
||||||
args[ac++] = "--";
|
argv_array_push(&argv, "--");
|
||||||
for (i = 0; i < pathspec->nr; i++)
|
for (i = 0; i < pathspec->nr; i++)
|
||||||
/* pass original pathspec, to be re-parsed */
|
/* 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);
|
status = run_command_v_opt(argv.argv, RUN_GIT_CMD);
|
||||||
free(args);
|
argv_array_clear(&argv);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue