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>
Wincent Colaiuta committed
Nov 22, 2007 at 01:02 UTC
7c0ab4458994aa895855abc4a504cf693ecc0cf1
2 files changed
+14
-11
builtin-add.c
+13
-10
@@ -135,11 +135,17 @@ static void refresh(int verbose, const char **pathspec)
135
free(seen);
136
}
137
138
-int interactive_add(void)
138
+int interactive_add(int argc, const char **argv)
139
{
140
- const char *argv[2] = { "add--interactive", NULL };
141
-
142
- return run_command_v_opt(argv, RUN_GIT_CMD);
140
+ int status;
141
+ const char **args = xmalloc(sizeof(const char *) * (argc + 1));
142
+ args[0] = "add--interactive";
143
+ memcpy((void *)args + sizeof(const char *), argv, sizeof(const char *) * argc);
144
+ args[argc + 1] = NULL;
145
+
146
+ status = run_command_v_opt(args, RUN_GIT_CMD);
147
+ free(args);
148
+ return status;
149
}
150
151
static struct lock_file lock_file;
@@ -163,17 +169,14 @@ static struct option builtin_add_options[] = {
169
170
int cmd_add(int argc, const char **argv, const char *prefix)
171
{
166
- int i, newfd, orig_argc = argc;
172
+ int i, newfd;
173
const char **pathspec;
174
struct dir_struct dir;
175
176
argc = parse_options(argc, argv, builtin_add_options,
177
builtin_add_usage, 0);
172
- if (add_interactive) {
173
- if (add_interactive != 1 || orig_argc != 2)
174
- die("add --interactive does not take any parameters");
175
- exit(interactive_add());
176
- }
178
+ if (add_interactive)
179
+ exit(interactive_add(argc, argv));
180
181
git_config(git_default_config);
182
commit.h
+1
-1
@@ -113,7 +113,7 @@ extern struct commit_list *get_shallow_commits(struct object_array *heads,
113
114
int in_merge_bases(struct commit *, struct commit **, int);
115
116
-extern int interactive_add(void);
116
+extern int interactive_add(int argc, const char **argv);
117
extern void add_files_to_cache(int verbose, const char *prefix, const char **files);
118
extern int rerere(void);
119