]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Git.pm
imap+nntp: share COMPRESS implementation
[public-inbox.git] / lib / PublicInbox / Git.pm
index 374a3b4dd71d9849aea7a1c7dee2e8d2e2d8d1f6..b2ae75c8ae312042562c35dc568047bc8af49a0e 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2014-2021 all contributors <meta@public-inbox.org>
+# Copyright (C) all contributors <meta@public-inbox.org>
 # License: GPLv2 or later <https://www.gnu.org/licenses/gpl-2.0.txt>
 #
 # Used to read files from a git repository without excessive forking.
@@ -71,7 +71,7 @@ sub new {
 
 sub git_path ($$) {
        my ($self, $path) = @_;
-       $self->{-git_path}->{$path} ||= do {
+       $self->{-git_path}->{$path} //= do {
                local $/ = "\n";
                chomp(my $str = $self->qx(qw(rev-parse --git-path), $path));
 
@@ -94,6 +94,13 @@ sub alternates_changed {
        $self->{alt_st} = $st; # always a true value
 }
 
+sub object_format {
+       $_[0]->{object_format} //= do {
+               my $fmt = $_[0]->qx(qw(config extensions.objectformat));
+               $fmt eq "sha256\n" ? \'sha256' : \undef;
+       }
+}
+
 sub last_check_err {
        my ($self) = @_;
        my $fh = $self->{err_c} or return;
@@ -158,7 +165,8 @@ sub my_read ($$$) {
                        return; # unrecoverable error
                }
        }
-       \substr($$rbuf, 0, $len, '');
+       my $no_pad = substr($$rbuf, 0, $len, '');
+       \$no_pad;
 }
 
 sub my_readline ($$) {
@@ -341,7 +349,7 @@ sub async_abort ($) {
        while (scalar(@{$self->{inflight_c} // []}) ||
                        scalar(@{$self->{inflight} // []})) {
                for my $c ('', '_c') {
-                       my $q = $self->{"inflight$c"};
+                       my $q = $self->{"inflight$c"} or next;
                        while (@$q) {
                                my ($req, $cb, $arg) = splice(@$q, 0, 3);
                                $req = $$req if ref($req);