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 5/7] Teach builtin-add to pass path arguments to git-add--interactive
Date: Fri, 23 Nov 2007 20:20:48 +0100 [thread overview]
Message-ID: <1195845650-85962-6-git-send-email-win@wincent.com> (raw)
In-Reply-To: <1195845650-85962-5-git-send-email-win@wincent.com>
The previous patches in the series taught git-add--interactive to handle
optional path arguments. This patch teaches builtin-add to pass
these arguments through to the script.
Signed-off-by: Wincent Colaiuta <win@wincent.com>
---
Documentation/git-add.txt | 4 +++-
builtin-add.c | 23 +++++++++++++----------
commit.h | 2 +-
3 files changed, 17 insertions(+), 12 deletions(-)
diff --git a/Documentation/git-add.txt b/Documentation/git-add.txt
index 63829d9..0b0ab1d 100644
--- a/Documentation/git-add.txt
+++ b/Documentation/git-add.txt
@@ -61,7 +61,9 @@ OPTIONS
-i, \--interactive::
Add modified contents in the working tree interactively to
- the index.
+ the index. Optional path arguments may be supplied to limit
+ operation to a subset of the files in the working tree.
+ See ``Interactive mode'' for details.
-u::
Update only files that git already knows about. This is similar
diff --git a/builtin-add.c b/builtin-add.c
index cf815a0..3646a45 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(void)
+int interactive_add(int argc, const char **argv)
{
- const char *argv[2] = { "add--interactive", 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;
@@ -163,17 +169,14 @@ static struct option builtin_add_options[] = {
int cmd_add(int argc, const char **argv, const char *prefix)
{
- int i, newfd, orig_argc = argc;
+ int i, newfd = argc;
const char **pathspec;
struct dir_struct dir;
argc = parse_options(argc, argv, builtin_add_options,
builtin_add_usage, 0);
- if (add_interactive) {
- if (add_interactive != 1 || orig_argc != 2)
- die("add --interactive does not take any parameters");
- exit(interactive_add());
- }
+ if (add_interactive)
+ exit(interactive_add(argc, argv));
git_config(git_default_config);
diff --git a/commit.h b/commit.h
index aa67986..d82b8bc 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(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 int rerere(void);
--
1.5.3.6.886.g3364
next prev parent reply other threads:[~2007-11-23 19:22 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-23 19:20 [PATCH v2] git-add--interactive pathspec and patch additions Wincent Colaiuta
2007-11-23 19:20 ` [PATCH 1/7] Add -q/--quiet switch to git-ls-files Wincent Colaiuta
2007-11-23 19:20 ` [PATCH 2/7] Rename patch_update_file function to patch_update_pathspec Wincent Colaiuta
2007-11-23 19:20 ` [PATCH 3/7] Add path-limiting to git-add--interactive Wincent Colaiuta
2007-11-23 19:20 ` [PATCH 4/7] Bail if user supplies an invalid pathspec Wincent Colaiuta
2007-11-23 19:20 ` Wincent Colaiuta [this message]
2007-11-23 19:20 ` [PATCH 6/7] Add "--patch" option to git-add--interactive Wincent Colaiuta
2007-11-23 19:20 ` [PATCH 7/7] Teach builtin-add to handle "--patch" option Wincent Colaiuta
2007-11-23 19:25 ` [PATCH 1/7] Add -q/--quiet switch to git-ls-files Wincent Colaiuta
2007-11-23 21:07 ` [PATCH v2] git-add--interactive pathspec and patch additions Junio C Hamano
2007-11-23 22:20 ` Wincent Colaiuta
2007-11-24 12:55 ` [PATCH 0/3] Updates to git-add--interactive Wincent Colaiuta
2007-11-24 12:55 ` [PATCH 1/3] Rename patch_update_file function to patch_update_pathspec Wincent Colaiuta
2007-11-24 12:55 ` [PATCH 2/3] Move pathspec validation into interactive_add Wincent Colaiuta
2007-11-24 12:55 ` [PATCH 3/3] Add "--patch" option to git-add--interactive Wincent Colaiuta
2007-11-24 19:15 ` [PATCH 2/3] Move pathspec validation into interactive_add Junio C Hamano
2007-11-24 21:50 ` Wincent Colaiuta
2007-11-24 22:34 ` Junio C Hamano
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=1195845650-85962-6-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).