mirror of
https://github.com/git/git.git
synced 2026-01-18 06:34:21 +00:00
Merge pull request #305 from dscho/msysgit_issues_182
Allow `add -p` and `add -i` with a large number of files
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -639,4 +639,25 @@ test_expect_success 'add -p patch editing works with pathological context lines'
|
||||
test_cmp expected-2 actual
|
||||
'
|
||||
|
||||
test_expect_success EXPENSIVE 'add -i with a lot of files' '
|
||||
git reset --hard &&
|
||||
x160=0123456789012345678901234567890123456789 &&
|
||||
x160=$x160$x160$x160$x160 &&
|
||||
y= &&
|
||||
i=0 &&
|
||||
while test $i -le 200
|
||||
do
|
||||
name=$(printf "%s%03d" $x160 $i) &&
|
||||
echo $name >$name &&
|
||||
git add -N $name &&
|
||||
y="${y}y$LF" &&
|
||||
i=$(($i+1)) ||
|
||||
break
|
||||
done &&
|
||||
echo "$y" | git add -p -- . &&
|
||||
git diff --cached >staged &&
|
||||
test_line_count = 1407 staged &&
|
||||
git reset --hard
|
||||
'
|
||||
|
||||
test_done
|
||||
|
||||
Reference in New Issue
Block a user