about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-01-10 09:14:17 +0000
committerEric Wong <e@yhbt.net>2020-01-11 06:32:08 +0000
commit0615eef4e17b642eca6978cf776834a9f0a31468 (patch)
treeba74ff95856da5889137d83dae5b1ef40d91d473
parent8f4720a57d9c5746dcf53fa6c612350c744c2cd1 (diff)
downloadpublic-inbox-0615eef4e17b642eca6978cf776834a9f0a31468.tar.gz
git: ->modified uses cat_async
While v1 inboxes are typically only a single branch, coderepos
will have many branches and being able to pipeline requests
to "git cat-file --batch" can help us mask seek times.
-rw-r--r--lib/PublicInbox/Git.pm16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm
index 2aaf1866..9d0f660b 100644
--- a/lib/PublicInbox/Git.pm
+++ b/lib/PublicInbox/Git.pm
@@ -339,6 +339,15 @@ sub commit_title ($$) {
         ($$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
 # of a grokmirror manifest
 sub modified ($) {
@@ -346,14 +355,13 @@ sub modified ($) {
         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;
 }