summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--builtin-add.c23
-rw-r--r--builtin-commit.c12
-rw-r--r--commit.h2
-rwxr-xr-xgit-add--interactive.perl28
4 files changed, 38 insertions, 27 deletions
diff --git a/builtin-add.c b/builtin-add.c
index 03508d3dcb..dd895dfb1d 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;
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/builtin-commit.c b/builtin-commit.c
index 4de316a366..5d27102a62 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -157,7 +157,7 @@ static void add_remove_files(struct path_list *list)
}
}
-static char *prepare_index(const char **files, const char *prefix)
+static char *prepare_index(int argc, const char **argv, const char *prefix)
{
int fd;
struct tree *tree;
@@ -165,7 +165,7 @@ static char *prepare_index(const char **files, const char *prefix)
const char **pathspec = NULL;
if (interactive) {
- interactive_add();
+ interactive_add(argc, argv);
commit_style = COMMIT_AS_IS;
return get_index_file();
}
@@ -173,8 +173,8 @@ static char *prepare_index(const char **files, const char *prefix)
if (read_cache() < 0)
die("index file corrupt");
- if (*files)
- pathspec = get_pathspec(prefix, files);
+ if (*argv)
+ pathspec = get_pathspec(prefix, argv);
/*
* Non partial, non as-is commit.
@@ -578,7 +578,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
argc = parse_and_validate_options(argc, argv);
- index_file = prepare_index(argv, prefix);
+ index_file = prepare_index(argc, argv, prefix);
commitable = run_status(stdout, index_file, prefix);
@@ -670,7 +670,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
argc = parse_and_validate_options(argc, argv);
- index_file = prepare_index(argv, prefix);
+ index_file = prepare_index(argc, argv, prefix);
if (!no_verify && run_hook(index_file, "pre-commit", NULL)) {
rollback_index_files();
diff --git a/commit.h b/commit.h
index f450aae8aa..9f0765bd9c 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 int rerere(void);
static inline int single_parent(struct commit *commit)
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index fb1e92a766..e347216550 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -37,7 +37,7 @@ sub list_untracked {
chomp $_;
$_;
}
- run_cmd_pipe(qw(git ls-files --others --exclude-standard --), @_);
+ run_cmd_pipe(qw(git ls-files --others --exclude-standard --), @ARGV);
}
my $status_fmt = '%12s %12s %s';
@@ -56,9 +56,17 @@ sub list_modified {
my ($only) = @_;
my (%data, @return);
my ($add, $del, $adddel, $file);
+ my @tracked = ();
+
+ if (@ARGV) {
+ @tracked = map {
+ chomp $_; $_;
+ } run_cmd_pipe(qw(git ls-files --exclude-standard --), @ARGV);
+ return if (!@tracked);
+ }
for (run_cmd_pipe(qw(git diff-index --cached
- --numstat --summary HEAD))) {
+ --numstat --summary HEAD --), @tracked)) {
if (($add, $del, $file) =
/^([-\d]+) ([-\d]+) (.*)/) {
my ($change, $bin);
@@ -81,7 +89,7 @@ sub list_modified {
}
}
- for (run_cmd_pipe(qw(git diff-files --numstat --summary))) {
+ for (run_cmd_pipe(qw(git diff-files --numstat --summary --), @tracked)) {
if (($add, $del, $file) =
/^([-\d]+) ([-\d]+) (.*)/) {
if (!exists $data{$file}) {
@@ -252,7 +260,7 @@ sub list_and_choose {
$chosen[$i] = $choose;
}
}
- last if ($opts->{IMMEDIATE});
+ last if ($opts->{IMMEDIATE} || $line eq '*');
}
for ($i = 0; $i < @stuff; $i++) {
if ($chosen[$i]) {
@@ -559,12 +567,12 @@ sub patch_update_cmd {
@mods = grep { !($_->{BINARY}) } @mods;
return if (!@mods);
- my ($it) = list_and_choose({ PROMPT => 'Patch update',
- SINGLETON => 1,
- IMMEDIATE => 1,
- HEADER => $status_head, },
- @mods);
- patch_update_file($it->{VALUE}) if ($it);
+ my (@them) = list_and_choose({ PROMPT => 'Patch update',
+ HEADER => $status_head, },
+ @mods);
+ for (@them) {
+ patch_update_file($_->{VALUE});
+ }
}
sub patch_update_file {