Skip to content

Commit 88afab6

Browse files
kkhellerdscho
authored andcommitted
Allow add -p and add -i with a large number of files
This fixes msysgit#182. Inspired by Pull Request 218 using code from @PhilipDavis. [jes: simplified code quite a bit] Signed-off-by: Kelly Heller <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
1 parent d7764be commit 88afab6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

git-add--interactive.perl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,24 @@ sub run_cmd_pipe {
178178
die "$^O does not support: @invalid\n" if @invalid;
179179
my @args = map { m/ /o ? "\"$_\"": $_ } @_;
180180
return qx{@args};
181+
} elsif (($^O eq 'MSWin32' || $^O eq 'msys') && (scalar @_ > 200) &&
182+
grep $_ eq '--', @_) {
183+
use File::Temp qw(tempfile);
184+
my ($fhargs, $filename) =
185+
tempfile('git-args-XXXXXX', UNLINK => 1);
186+
187+
my $cmd = 'cat '.$filename.' | xargs -0 -s 20000 ';
188+
while ($_[0] ne '--') {
189+
$cmd = $cmd . shift(@_) . ' ';
190+
}
191+
192+
shift(@_);
193+
print $fhargs join("\0", @_);
194+
close($fhargs);
195+
196+
my $fh = undef;
197+
open($fh, '-|', $cmd) or die;
198+
return <$fh>;
181199
} else {
182200
my $fh = undef;
183201
open($fh, '-|', @_) or die;

0 commit comments

Comments
 (0)