Skip to content

Commit

Permalink
Add path-limiting to git-add--interactive
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Wincent Colaiuta authored and Junio C Hamano committed Nov 22, 2007
1 parent 7c0ab44 commit 4c84168
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions git-add--interactive.perl
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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);
Expand All @@ -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}) {
Expand Down

0 comments on commit 4c84168

Please sign in to comment.