Skip to content

Commit 9b93fae

Browse files
kkhellerGit for Windows Build Agent
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 6079bc0 commit 9b93fae

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

0 commit comments

Comments
 (0)