Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Git-Wrapper CPAN distribution.

Report information
The Basics
Id: 71632
Status: resolved
Priority: 0/
Queue: Git-Wrapper

People
Owner: GENEHACK [...] cpan.org
Requestors: KENTNL [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.017
Fixed in: (no value)



Subject: No way to obtain data sent from git via STDERR
I'm wanting some way to extract/report the output git writes to STDERR for some commands ( ie : git remote --verbose update ) , but it seems there's no way to get that data without having the command itself fail first.

If data is written to STDERR, its stuffed in @err, but if the command succeeds, @err then disappears and all you can get out is @out.

This effectively means 2 things.

1. Its not possible to get git itself to report things verbosely to the user via stderr ( as it is captured )
2. Its not possible for any consuming code to report things verbosely ( as the captured data is disposed of ).
 

I've long mused over the idea that perhaps Git::Wrapper should support alternative interfaces, eg:

 

my $command = $wrapper->remote('--verbose', 'update' , $remotename );  # wantarray scalar context =~ returns an object and doesn't do anything on its own.

while( my $line = $command->getline ) {  }  # makes the command run line-fed

my @out = $command->out();  # the same as  push @out, $_ while $_ = $command->getline

my @error = $command->error(); # gets data written to stderr

but this is just nice to have future stuff.

I'd be satisfied enough if it simply set some array on the wrapper instance itself at the end, ie:  $self->{err} = \@err;  

and then it was up to me to read that in a sensible way.

 

Thanks in advance.

 

 

 

I'm painfully aware of the issue; there are places where I'd like to be able to get at STDERR on success as well -- I just haven't come up with a non-gross way to accomplish it. I'll update the ticket when I come up with something...
On Wed Oct 12 14:03:57 2011, KENTNL wrote: Show quoted text
> I'm wanting some way to extract/report the output git writes to STDERR > for some > commands ( ie : git remote --verbose update ) , but it seems there's > no way to > get that data without having the command itself fail first. > > If data is written to STDERR, its stuffed in @err, but if the command > succeeds, > @err then disappears and all you can get out is @out. > > This effectively means 2 things. > > 1. Its not possible to get git itself to report things verbosely to > the user > via stderr ( as it is captured ) > 2. Its not possible for any consuming code to report things verbosely > ( as the > captured data is disposed of ). > > I've long mused over the idea that perhaps Git::Wrapper should support > alternative interfaces, eg: > > my $command = $wrapper->remote('--verbose', 'update' , $remotename ); > # > wantarray scalar context =~ returns an object and doesn't do anything > on its > own. > > while( my $line = $command->getline ) { } # makes the command run > line-fed > > my @out = $command->out(); # the same as push @out, $_ while $_ = > $command->getline > > my @error = $command->error(); # gets data written to stderr > > but this is just nice to have future stuff. > > I'd be satisfied enough if it simply set some array on the wrapper > instance > itself at the end, ie: $self->{err} = \@err; > > and then it was up to me to read that in a sensible way. >
Sorry it took so long to get to this, every time I would start to think about it I'd get stuck trying to do the perfect thing (which is impossible) and ignore the ugly-but-sufficient thing that was right there. So... Commit 38dbdd6 adds 'ERR' and 'OUT' methods to the wrapper, that return the STDERR and STDOUT, respectively, of the previously run command. I plan on doing a release later this afternoon, after I wrap up a few more outstanding bug reports. Thanks, and sorry again for the delay. j.