git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wincent Colaiuta <win@wincent.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, peff@peff.net, Wincent Colaiuta <win@wincent.com>
Subject: [PATCH 3/4] Teach builtin-add to pass multiple paths to git-add--interactive
Date: Thu, 22 Nov 2007 01:02:52 +0100	[thread overview]
Message-ID: <1195689773-28601-4-git-send-email-win@wincent.com> (raw)
In-Reply-To: <1195689773-28601-3-git-send-email-win@wincent.com>

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>
---
 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

  reply	other threads:[~2007-11-22  0:04 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-21 12:36 [PATCH] teaching git-add--interactive to accept a file param Wincent Colaiuta
2007-11-21 12:36 ` [PATCH 1/4] Refactor patch_update_cmd Wincent Colaiuta
2007-11-21 12:36   ` [PATCH 2/4] Teach git-add--interactive to accept a file path to patch Wincent Colaiuta
2007-11-21 12:36     ` [PATCH 3/4] Teach builtin-add to pass a path argument to git-add--interactive Wincent Colaiuta
2007-11-21 12:36       ` [PATCH 4/4] Document optional file parameter " Wincent Colaiuta
2007-11-21 15:21     ` [PATCH 2/4] Teach git-add--interactive to accept a file path to patch Jeff King
2007-11-21 16:15       ` Wincent Colaiuta
2007-11-21 20:40       ` Junio C Hamano
2007-11-21 22:44         ` Wincent Colaiuta
2007-11-22  0:02           ` Updates: teaching git-add--interactive to accept a file param Wincent Colaiuta
2007-11-22  0:02             ` [PATCH 1/4] Suppress spurious linefeeds in git-add--interactive Wincent Colaiuta
2007-11-22  0:02               ` [PATCH 2/4] Teach git-add--interactive to accept multiple file params Wincent Colaiuta
2007-11-22  0:02                 ` Wincent Colaiuta [this message]
2007-11-22  0:02                   ` [PATCH 4/4] Update git-add documentation for multiple interactive paths Wincent Colaiuta
2007-11-22  9:08                   ` [PATCH 3/4] Teach builtin-add to pass multiple paths to git-add--interactive Jeff King
2007-11-22 10:28                     ` Wincent Colaiuta
2007-11-22 10:33                       ` Jeff King
2007-11-22 11:02                         ` Wincent Colaiuta
2007-11-22 11:37                           ` Jeff King
2007-11-22  8:59               ` [PATCH 1/4] Suppress spurious linefeeds in git-add--interactive Jeff King
2007-11-22 10:18                 ` Wincent Colaiuta
2007-11-22 10:38                   ` Junio C Hamano
2007-11-22  0:18           ` [PATCH 2/4] Teach git-add--interactive to accept a file path to patch Junio C Hamano
2007-11-22  1:36             ` [PATCH] Add path-limiting to git-add--interactive Wincent Colaiuta
2007-11-22  9:13               ` Junio C Hamano
2007-11-22  9:45                 ` Junio C Hamano
2007-11-22 11:35                   ` Wincent Colaiuta
2007-11-22 11:14                 ` Wincent Colaiuta
2007-11-22  1:41             ` [PATCH 2/4] Teach git-add--interactive to accept a file path to patch Wincent Colaiuta
2007-11-22  9:13             ` Jeff King
2007-11-22  9:50               ` Junio C Hamano
2007-11-22  9:57                 ` Jeff King
2007-11-22 10:44                 ` Wincent Colaiuta
2007-11-22 11:24                   ` Jeff King
2007-11-22 11:29                   ` Junio C Hamano
2007-11-22 11:36                     ` Jeff King
2007-11-22 13:34                     ` Wincent Colaiuta
2007-11-22 19:29                       ` Junio C Hamano
2007-11-22 21:55                         ` Wincent Colaiuta

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1195689773-28601-4-git-send-email-win@wincent.com \
    --to=win@wincent.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).