X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FGit.pm;h=8ee04e17b511ca1b7c470aa05ea7ce30f26ac033;hb=9f5a583694396f84;hp=2aaf1866b5965169e4abcec87f1fdaed9b6fb47c;hpb=8f4720a57d9c5746dcf53fa6c612350c744c2cd1;p=public-inbox.git diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm index 2aaf1866..8ee04e17 100644 --- a/lib/PublicInbox/Git.pm +++ b/lib/PublicInbox/Git.pm @@ -122,7 +122,6 @@ sub _bidi_pipe { $redir->{2} = $fh; } my $p = spawn(\@cmd, undef, $redir); - defined $p or fail($self, "spawn failed: $!"); $self->{$pid} = $p; $out_w->autoflush(1); $self->{$out} = $out_w; @@ -256,7 +255,6 @@ sub popen { sub qx { my ($self, @cmd) = @_; my $fh = $self->popen(@cmd); - defined $fh or return; local $/ = "\n"; return <$fh> if wantarray; local $/; @@ -332,11 +330,13 @@ sub cat_async ($$$;$) { push(@$inflight, [ $cb, $arg ]); } -sub commit_title ($$) { - my ($self, $oid) = @_; # PublicInbox::Git, $sha1hex - my $buf = cat_file($self, $oid) or return; - utf8::decode($$buf); - ($$buf =~ /\r?\n\r?\n([^\r\n]+)\r?\n?/)[0] +sub extract_cmt_time { + my ($bref, undef, undef, undef, $modified) = @_; + + if ($$bref =~ /^committer .*?> ([0-9]+) [\+\-]?[0-9]+/sm) { + my $cmt_time = $1 + 0; + $$modified = $cmt_time if $cmt_time > $$modified; + } } # returns the modified time of a git repo, same as the "modified" field @@ -345,15 +345,13 @@ sub modified ($) { my ($self) = @_; my $modified = 0; my $fh = popen($self, qw(rev-parse --branches)); - defined $fh or return $modified; + cat_async_begin($self); local $/ = "\n"; foreach my $oid (<$fh>) { chomp $oid; - my $buf = cat_file($self, $oid) or next; - $$buf =~ /^committer .*?> ([0-9]+) [\+\-]?[0-9]+/sm or next; - my $cmt_time = $1 + 0; - $modified = $cmt_time if $cmt_time > $modified; + cat_async($self, $oid, \&extract_cmt_time, \$modified); } + cat_async_wait($self); $modified || time; }