Skip to content

Commit f3e9069

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 fd6f15b commit f3e9069

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

0 commit comments

Comments
 (0)