summaryrefslogtreecommitdiff
path: root/git-add--interactive.perl
diff options
context:
space:
mode:
authorWincent Colaiuta <win@wincent.com>2007-11-22 01:36:24 (GMT)
committerJunio C Hamano <gitster@pobox.com>2007-11-22 10:53:40 (GMT)
commit4c8416847aa48e2bd60fa26585e32940a1a9c61c (patch)
tree0385de75506e2df2ae517a2ac337c12dfba73c68 /git-add--interactive.perl
parent7c0ab4458994aa895855abc4a504cf693ecc0cf1 (diff)
downloadgit-4c8416847aa48e2bd60fa26585e32940a1a9c61c.zip
git-4c8416847aa48e2bd60fa26585e32940a1a9c61c.tar.gz
git-4c8416847aa48e2bd60fa26585e32940a1a9c61c.tar.bz2
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>
Diffstat (limited to 'git-add--interactive.perl')
-rwxr-xr-xgit-add--interactive.perl14
1 files changed, 11 insertions, 3 deletions
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index fb1e92a..a0e480e 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}) {