On Tue, Mar 29, 2011 at 04:21:22PM +0200, Philippe Bruhat (BooK) wrote:
Show quoted text> >
> > I trying use Git::Repository for git command: git shortlog -ens and
> > doesn't have any result. Script just waiting something.
> >
> > run and command methods have a same results.
> >
> I confirm that I can reproduce the bug. Will investigate.
>
> I have not a clue yet.
>
git shortlog actually detects that it's not attached to a terminal,
so it expects to parse some git log output sent on stdin.
# hangs
$ perl -MGit::Repository -le 'print scalar Git::Repository->run( qw( shortlog -5 ) )'
# does not hang
$ perl -MGit::Repository -le 'print scalar Git::Repository->run( qw( shortlog -5 ), input => "" )'
The first version hangs because git shortlog expects some git log output
on stdin, which is not provided. So it's not Git::Repository that is hanging,
but git shortlog itself.
The second version returns no output, because we just closed stdin.
Here's a version that works on a small log output:
perl -MGit::Repository -le 'print scalar Git::Repository->run( "shortlog", { input => scalar Git::Repository->run( qw( log -5 ) ) } )'
Which larger ouput, you'll want to use Git::Repository::Command objects
to avoid storing the whole log output in memory:
use strict;
use warnings;
use Git::Repository;
my $log = Git::Repository->command('log')->stdout;
my $cmd = Git::Repository->command( shortlog => -ens );
my $in = $cmd->stdin;
print {$in} $_ while <$log>;
close $in;
print $cmd->stdout->getlines;
This works as expected.
My conclusion is that it is an issue with how git shortlog works
when not connected to a tty, and not an issue with Git::Repository.
Regards,
--
Philippe Bruhat (BooK)
Freedom is not an individual effort. Yours comes only when you grant others
theirs. (Moral from Groo The Wanderer #5 (Epic))