[PATCH 3/4] Teach builtin-add to pass multiple paths to git-add--interactive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx>
---
 builtin-add.c |   23 +++++++++++++----------
 commit.h      |    2 +-
 2 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/builtin-add.c b/builtin-add.c
index 278c02e..13f27e8 100644
--- a/builtin-add.c
+++ b/builtin-add.c
@@ -135,11 +135,17 @@ static void refresh(int verbose, const char **pathspec)
         free(seen);
 }
 
-int interactive_add(const char *path)
+int interactive_add(const char **argv, int argc)
 {
-	const char *argv[3] = { "add--interactive", path, NULL };
-
-	return run_command_v_opt(argv, RUN_GIT_CMD);
+	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;
+
+	status = run_command_v_opt(args, RUN_GIT_CMD);
+	free(args);
+	return status;
 }
 
 static struct lock_file lock_file;
@@ -170,13 +176,10 @@ int cmd_add(int argc, const char **argv, const char *prefix)
 	argc = parse_options(argc, argv, builtin_add_options,
 			  builtin_add_usage, 0);
 	if (add_interactive) {
-		if (argc > 1)
-			die("add --interactive may take only 1 optional "
-			    "parameter");
-		else if (argc == 1)
-			exit(interactive_add(argv[0]));
+		if (argc > 0)
+			exit(interactive_add(argv, argc));
 		else
-			exit(interactive_add(NULL));
+			exit(interactive_add(NULL, 0));
 	}
 
 	git_config(git_default_config);
diff --git a/commit.h b/commit.h
index 03a6ec5..3a398fc 100644
--- a/commit.h
+++ b/commit.h
@@ -113,7 +113,7 @@ extern struct commit_list *get_shallow_commits(struct object_array *heads,
 
 int in_merge_bases(struct commit *, struct commit **, int);
 
-extern int interactive_add(const char *path);
+extern int interactive_add(const char **argv, int argc);
 extern void add_files_to_cache(int verbose, const char *prefix, const char **files);
 extern int rerere(void);
 
-- 
1.5.3.6.867.g539b6-dirty

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux