mirror of
https://github.com/git/git.git
synced 2024-10-18 13:28:56 +02:00
Merge branch 'ew/cat-file-unbuffered-tests'
The output from "git cat-file --batch-check" and "--batch-command (info)" should not be unbuffered, for which some tests have been added. * ew/cat-file-unbuffered-tests: t1006: ensure cat-file info isn't buffered by default Git.pm: use array in command_bidi_pipe example
This commit is contained in:
commit
ae447ed130
@ -418,7 +418,7 @@ argument is required if you want to see the command name in the error message,
|
||||
and it is the fourth value returned by C<command_bidi_pipe()>. The call idiom
|
||||
is:
|
||||
|
||||
my ($pid, $in, $out, $ctx) = $r->command_bidi_pipe('cat-file --batch-check');
|
||||
my ($pid, $in, $out, $ctx) = $r->command_bidi_pipe(qw(cat-file --batch-check));
|
||||
print $out "000000000\n";
|
||||
while (<$in>) { ... }
|
||||
$r->command_close_bidi_pipe($pid, $in, $out, $ctx);
|
||||
@ -431,7 +431,7 @@ C<PIPE_IN> and C<PIPE_OUT> may be C<undef> if they have been closed prior to
|
||||
calling this function. This may be useful in a query-response type of
|
||||
commands where caller first writes a query and later reads response, eg:
|
||||
|
||||
my ($pid, $in, $out, $ctx) = $r->command_bidi_pipe('cat-file --batch-check');
|
||||
my ($pid, $in, $out, $ctx) = $r->command_bidi_pipe(qw(cat-file --batch-check));
|
||||
print $out "000000000\n";
|
||||
close $out;
|
||||
while (<$in>) { ... }
|
||||
|
@ -1294,4 +1294,34 @@ test_expect_success 'batch-command flush without --buffer' '
|
||||
grep "^fatal:.*flush is only for --buffer mode.*" err
|
||||
'
|
||||
|
||||
script='
|
||||
use warnings;
|
||||
use strict;
|
||||
use IPC::Open2;
|
||||
my ($opt, $oid, $expect, @pfx) = @ARGV;
|
||||
my @cmd = (qw(git cat-file), $opt);
|
||||
my $pid = open2(my $out, my $in, @cmd) or die "open2: @cmd";
|
||||
print $in @pfx, $oid, "\n" or die "print $!";
|
||||
my $rvec = "";
|
||||
vec($rvec, fileno($out), 1) = 1;
|
||||
select($rvec, undef, undef, 30) or die "no response to `@pfx $oid` from @cmd";
|
||||
my $info = <$out>;
|
||||
chop($info) eq "\n" or die "no LF";
|
||||
$info eq $expect or die "`$info` != `$expect`";
|
||||
close $in or die "close in $!";
|
||||
close $out or die "close out $!";
|
||||
waitpid $pid, 0;
|
||||
$? == 0 or die "\$?=$?";
|
||||
'
|
||||
|
||||
expect="$hello_oid blob $hello_size"
|
||||
|
||||
test_expect_success PERL '--batch-check is unbuffered by default' '
|
||||
perl -e "$script" -- --batch-check $hello_oid "$expect"
|
||||
'
|
||||
|
||||
test_expect_success PERL '--batch-command info is unbuffered by default' '
|
||||
perl -e "$script" -- --batch-command $hello_oid "$expect" "info "
|
||||
'
|
||||
|
||||
test_done
|
||||
|
Loading…
Reference in New Issue
Block a user