Navigation Menu

Skip to content

Commit

Permalink
Allow add -p and add -i with a large number of files
Browse files Browse the repository at this point in the history
This fixes msysgit#182.

Inspired by Pull Request 218 using code from @PhilipDavis.

[jes: simplified code quite a bit]

Signed-off-by: Kelly Heller <kkheller@cedrus.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  • Loading branch information
kkheller authored and jamill committed Sep 10, 2018
1 parent 0d848d6 commit 5658f68
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions git-add--interactive.perl
Expand Up @@ -160,6 +160,24 @@ sub run_cmd_pipe {
die "$^O does not support: @invalid\n" if @invalid;
my @args = map { m/ /o ? "\"$_\"": $_ } @_;
return qx{@args};
} elsif (($^O eq 'MSWin32' || $^O eq 'msys') && (scalar @_ > 200) &&
grep $_ eq '--', @_) {
use File::Temp qw(tempfile);
my ($fhargs, $filename) =
tempfile('git-args-XXXXXX', UNLINK => 1);

my $cmd = 'cat '.$filename.' | xargs -0 -s 20000 ';
while ($_[0] ne '--') {
$cmd = $cmd . shift(@_) . ' ';
}

shift(@_);
print $fhargs join("\0", @_);
close($fhargs);

my $fh = undef;
open($fh, '-|', $cmd) or die;
return <$fh>;
} else {
my $fh = undef;
open($fh, '-|', @_) or die;
Expand Down

0 comments on commit 5658f68

Please sign in to comment.