From: Nazri Ramliy <ayiehere@gmail.com>
To: git@vger.kernel.org
Cc: Nazri Ramliy <ayiehere@gmail.com>
Subject: [PATCH 2/6] Teach --id to "git add"
Date: Wed, 5 Aug 2009 17:51:42 +0800 [thread overview]
Message-ID: <1249465906-3940-3-git-send-email-ayiehere@gmail.com> (raw)
In-Reply-To: <1249465906-3940-2-git-send-email-ayiehere@gmail.com>
---
builtin-add.c | 19 ++++++++++++++-----
1 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/builtin-add.c b/builtin-add.c
index 581a2a1..1ed95d5 100644
--- a/builtin-add.c
+++ b/builtin-add.c
@@ -212,6 +212,7 @@ static const char ignore_error[] =
static int verbose = 0, show_only = 0, ignored_too = 0, refresh_only = 0;
static int ignore_add_errors, addremove, intent_to_add;
+static const char *file_id;
static struct option builtin_add_options[] = {
OPT__DRY_RUN(&show_only),
@@ -226,6 +227,7 @@ static struct option builtin_add_options[] = {
OPT_BOOLEAN('A', "all", &addremove, "add all, noticing removal of tracked files"),
OPT_BOOLEAN( 0 , "refresh", &refresh_only, "don't add, only refresh the index"),
OPT_BOOLEAN( 0 , "ignore-errors", &ignore_add_errors, "just skip files which cannot be added because of errors"),
+ OPT_STRING('d', "id", &file_id, "FILE_ID", "file id"),
OPT_END(),
};
@@ -268,27 +270,34 @@ int cmd_add(int argc, const char **argv, const char *prefix)
int flags;
int add_new_files;
int require_pathspec;
+ char **new_argv;
git_config(add_config, NULL);
argc = parse_options(argc, argv, prefix, builtin_add_options,
builtin_add_usage, PARSE_OPT_KEEP_ARGV0);
+
+ if (file_id)
+ new_argv = (char **) expand_file_ids(file_id, &argc, (char **) argv);
+ else
+ new_argv = (char **) argv;
+
if (patch_interactive)
add_interactive = 1;
if (add_interactive)
- exit(interactive_add(argc - 1, argv + 1, prefix));
+ exit(interactive_add(argc - 1, (const char **) (new_argv + 1), prefix));
if (edit_interactive)
- return(edit_patch(argc, argv, prefix));
+ return(edit_patch(argc, (const char **) new_argv, prefix));
argc--;
- argv++;
+ new_argv++;
if (addremove && take_worktree_changes)
die("-A and -u are mutually incompatible");
if ((addremove || take_worktree_changes) && !argc) {
static const char *here[2] = { ".", NULL };
argc = 1;
- argv = here;
+ new_argv = (char **) here;
}
add_new_files = !take_worktree_changes && !refresh_only;
@@ -308,7 +317,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
fprintf(stderr, "Maybe you wanted to say 'git add .'?\n");
return 0;
}
- pathspec = validate_pathspec(argc, argv, prefix);
+ pathspec = validate_pathspec(argc, (const char **) new_argv, prefix);
if (read_cache() < 0)
die("index file corrupt");
--
1.6.4.13.ge6580
next prev parent reply other threads:[~2009-08-05 9:55 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-05 9:51 [PATCH] RFC - Say goodbye to the rodent Nazri Ramliy
2009-08-05 9:51 ` [PATCH 1/6] Teach --id/-d to "git status" Nazri Ramliy
2009-08-05 9:51 ` Nazri Ramliy [this message]
2009-08-05 9:51 ` [PATCH 3/6] Teach --id to "git checkout" Nazri Ramliy
2009-08-05 9:51 ` [PATCH 4/6] Teach --d to "git commit" Nazri Ramliy
2009-08-05 9:51 ` [PATCH 5/6] Teach --id to "git rm" Nazri Ramliy
2009-08-05 9:51 ` [PATCH 6/6] Teach --id to "git reset" Nazri Ramliy
2009-08-05 18:11 ` [PATCH 1/6] Teach --id/-d to "git status" Alex Riesen
2009-08-05 18:25 ` Sverre Rabbelier
2009-08-05 18:27 ` Junio C Hamano
2009-08-05 18:30 ` Sverre Rabbelier
2009-08-05 18:33 ` Alex Riesen
2009-08-05 18:35 ` Sverre Rabbelier
2009-08-05 10:04 ` [PATCH] RFC - Say goodbye to the rodent Andreas Ericsson
2009-08-05 11:54 ` Matthieu Moy
2009-08-05 19:02 ` Jeff King
2009-08-05 20:01 ` Nicolas Pitre
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=1249465906-3940-3-git-send-email-ayiehere@gmail.com \
--to=ayiehere@gmail.com \
--cc=git@vger.kernel.org \
/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).