Teach builtin-add to pass multiple paths to git-add--interactive

Instead of just accepting a single file parameter, git-add now accepts
any number of path parameters, fowarding them to git-add--interactive.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Wincent Colaiuta 2007-11-22 01:02:52 +01:00 committed by Junio C Hamano
parent a7d9da6c97
commit 7c0ab44589
2 changed files with 13 additions and 10 deletions

View File

@ -135,11 +135,17 @@ static void refresh(int verbose, const char **pathspec)
free(seen); free(seen);
} }


int interactive_add(void) int interactive_add(int argc, const char **argv)
{ {
const char *argv[2] = { "add--interactive", NULL }; int status;
const char **args = xmalloc(sizeof(const char *) * (argc + 1));
args[0] = "add--interactive";
memcpy((void *)args + sizeof(const char *), argv, sizeof(const char *) * argc);
args[argc + 1] = NULL;


return run_command_v_opt(argv, RUN_GIT_CMD); status = run_command_v_opt(args, RUN_GIT_CMD);
free(args);
return status;
} }


static struct lock_file lock_file; static struct lock_file lock_file;
@ -163,17 +169,14 @@ static struct option builtin_add_options[] = {


int cmd_add(int argc, const char **argv, const char *prefix) int cmd_add(int argc, const char **argv, const char *prefix)
{ {
int i, newfd, orig_argc = argc; int i, newfd;
const char **pathspec; const char **pathspec;
struct dir_struct dir; struct dir_struct dir;


argc = parse_options(argc, argv, builtin_add_options, argc = parse_options(argc, argv, builtin_add_options,
builtin_add_usage, 0); builtin_add_usage, 0);
if (add_interactive) { if (add_interactive)
if (add_interactive != 1 || orig_argc != 2) exit(interactive_add(argc, argv));
die("add --interactive does not take any parameters");
exit(interactive_add());
}


git_config(git_default_config); git_config(git_default_config);



View File

@ -113,7 +113,7 @@ extern struct commit_list *get_shallow_commits(struct object_array *heads,


int in_merge_bases(struct commit *, struct commit **, int); int in_merge_bases(struct commit *, struct commit **, int);


extern int interactive_add(void); extern int interactive_add(int argc, const char **argv);
extern void add_files_to_cache(int verbose, const char *prefix, const char **files); extern void add_files_to_cache(int verbose, const char *prefix, const char **files);
extern int rerere(void); extern int rerere(void);