Add path-limiting to git-add--interactive
Implement Junio's suggestion that git-add--interactive should reproduce the path-limiting semantics of non-interactive git-add. In otherwords, if "git add -i" (unrestricted) shows paths from a set A, "git add -i paths..." should show paths from a subset of the set A and that subset should be defined with the existing ls-files pathspec semantics. Signed-off-by: Wincent Colaiuta <win@wincent.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Wincent Colaiuta committed
Nov 22, 2007 at 02:36 UTC
4c8416847aa48e2bd60fa26585e32940a1a9c61c
1 file changed
+11
-3
git-add--interactive.perl
+11
-3
@@ -37,7 +37,7 @@ sub list_untracked {
37
chomp $_;
38
$_;
39
}
40
- run_cmd_pipe(qw(git ls-files --others --exclude-standard --), @_);
40
+ run_cmd_pipe(qw(git ls-files --others --exclude-standard --), @ARGV);
41
}
42
43
my $status_fmt = '%12s %12s %s';
@@ -56,9 +56,17 @@ sub list_modified {
56
my ($only) = @_;
57
my (%data, @return);
58
my ($add, $del, $adddel, $file);
59
+ my @tracked = ();
60
+
61
+ if (@ARGV) {
62
+ @tracked = map {
63
+ chomp $_; $_;
64
+ } run_cmd_pipe(qw(git ls-files --exclude-standard --), @ARGV);
65
+ return if (!@tracked);
66
+ }
67
68
for (run_cmd_pipe(qw(git diff-index --cached
61
- --numstat --summary HEAD))) {
69
+ --numstat --summary HEAD --), @tracked)) {
70
if (($add, $del, $file) =
71
/^([-\d]+) ([-\d]+) (.*)/) {
72
my ($change, $bin);
@@ -81,7 +89,7 @@ sub list_modified {
89
}
90
}
91
84
- for (run_cmd_pipe(qw(git diff-files --numstat --summary))) {
92
+ for (run_cmd_pipe(qw(git diff-files --numstat --summary --), @tracked)) {
93
if (($add, $del, $file) =
94
/^([-\d]+) ([-\d]+) (.*)/) {
95
if (!exists $data{$file}) {