X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FGit.pm;h=b2ae75c8ae312042562c35dc568047bc8af49a0e;hb=eefde9dd2265171e3ed267ff767df5db6d4644e6;hp=e634ca55fd1f75879d6f8dc15126c7444e21cb80;hpb=f64fdbc7cc19a34f471abaeada9195597bf7a282;p=public-inbox.git diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm index e634ca55..b2ae75c8 100644 --- a/lib/PublicInbox/Git.pm +++ b/lib/PublicInbox/Git.pm @@ -1,4 +1,4 @@ -# Copyright (C) 2014-2021 all contributors +# Copyright (C) all contributors # License: GPLv2 or later # # 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); @@ -442,13 +450,8 @@ sub packed_bytes { sub DESTROY { cleanup(@_) } sub local_nick ($) { - my ($self) = @_; - my $ret = '???'; # don't show full FS path, basename should be OK: - if ($self->{git_dir} =~ m!/([^/]+)(?:/*\.git/*)?\z!) { - $ret = "$1.git"; - } - wantarray ? ($ret) : $ret; + $_[0]->{git_dir} =~ m!/([^/]+?)(?:/*\.git/*)?\z! ? "$1.git" : '???'; } sub host_prefix_url ($$) { @@ -465,7 +468,7 @@ sub pub_urls { if (my $urls = $self->{cgit_url}) { return map { host_prefix_url($env, $_) } @$urls; } - local_nick($self); + (local_nick($self)); } sub cat_async_begin {