Re: [PATCH 2/4] Git.pm: Allow pipes to be closed prior to calling command_close_bidi_pipe

2013-02-06 Thread Junio C Hamano
Jeff King  writes:

> On Wed, Feb 06, 2013 at 09:47:04PM +0100, Michal Nazarewicz wrote:
>
>> From: Michal Nazarewicz 
>> 
>> The command_close_bidi_pipe() function will insist on closing both
>> input and output pipes returned by command_bidi_pipe().  With this
>> change it is possible to close one of the pipes in advance and
>> pass undef as an argument.
>> 
>> This allows for something like:
>> 
>>   my ($pid, $in, $out, $ctx) = command_bidi_pipe(...);
>>   print $out "write data";
>>   close $out;
>>   # ... do stuff with $in
>>   command_close_bidi_pipe($pid, $in, undef, $ctx);
>
> Should this part go into the documentation for command_close_bidi_pipe
> in Git.pm?

Yeah, it probably should.

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/4] Git.pm: Allow pipes to be closed prior to calling command_close_bidi_pipe

2013-02-06 Thread Jeff King
On Wed, Feb 06, 2013 at 09:47:04PM +0100, Michal Nazarewicz wrote:

> From: Michal Nazarewicz 
> 
> The command_close_bidi_pipe() function will insist on closing both
> input and output pipes returned by command_bidi_pipe().  With this
> change it is possible to close one of the pipes in advance and
> pass undef as an argument.
> 
> This allows for something like:
> 
>   my ($pid, $in, $out, $ctx) = command_bidi_pipe(...);
>   print $out "write data";
>   close $out;
>   # ... do stuff with $in
>   command_close_bidi_pipe($pid, $in, undef, $ctx);

Should this part go into the documentation for command_close_bidi_pipe
in Git.pm?

-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/4] Git.pm: Allow pipes to be closed prior to calling command_close_bidi_pipe

2013-02-06 Thread Michal Nazarewicz
From: Michal Nazarewicz 

The command_close_bidi_pipe() function will insist on closing both
input and output pipes returned by command_bidi_pipe().  With this
change it is possible to close one of the pipes in advance and
pass undef as an argument.

This allows for something like:

  my ($pid, $in, $out, $ctx) = command_bidi_pipe(...);
  print $out "write data";
  close $out;
  # ... do stuff with $in
  command_close_bidi_pipe($pid, $in, undef, $ctx);

Signed-off-by: Michal Nazarewicz 
---
 perl/Git.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/perl/Git.pm b/perl/Git.pm
index bbb753a..6a2d52d 100644
--- a/perl/Git.pm
+++ b/perl/Git.pm
@@ -432,7 +432,7 @@ sub command_close_bidi_pipe {
local $?;
my ($self, $pid, $in, $out, $ctx) = _maybe_self(@_);
foreach my $fh ($in, $out) {
-   unless (close $fh) {
+   if (defined $fh && !close $fh) {
if ($!) {
carp "error closing pipe: $!";
} elsif ($? >> 8) {
-- 
1.8.1.2.549.g4fa355e

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html