about summary refs log tree commit homepage
path: root/lib/PublicInbox/Inbox.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/PublicInbox/Inbox.pm')
-rw-r--r--lib/PublicInbox/Inbox.pm31
1 files changed, 11 insertions, 20 deletions
diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm
index a0d69f18..05d04530 100644
--- a/lib/PublicInbox/Inbox.pm
+++ b/lib/PublicInbox/Inbox.pm
@@ -6,6 +6,7 @@ package PublicInbox::Inbox;
 use strict;
 use warnings;
 use PublicInbox::Git;
+use PublicInbox::Config;
 use PublicInbox::MID qw(mid2path);
 use Devel::Peek qw(SvREFCNT);
 
@@ -102,21 +103,11 @@ sub search {
         };
 }
 
-sub try_cat {
-        my ($path) = @_;
-        my $rv = '';
-        if (open(my $fh, '<', $path)) {
-                local $/;
-                $rv = <$fh>;
-        }
-        $rv;
-}
-
 sub description {
         my ($self) = @_;
         my $desc = $self->{description};
         return $desc if defined $desc;
-        $desc = try_cat("$self->{mainrepo}/description");
+        $desc = PublicInbox::Config::try_cat("$self->{mainrepo}/description");
         local $/ = "\n";
         chomp $desc;
         $desc =~ s/\s+/ /smg;
@@ -128,7 +119,7 @@ sub cloneurl {
         my ($self) = @_;
         my $url = $self->{cloneurl};
         return $url if $url;
-        $url = try_cat("$self->{mainrepo}/cloneurl");
+        $url = PublicInbox::Config::try_cat("$self->{mainrepo}/cloneurl");
         my @url = split(/\s+/s, $url);
         local $/ = "\n";
         chomp @url;
@@ -211,16 +202,16 @@ sub nntp_usable {
         $ret;
 }
 
-sub msg_by_path ($$;$) {
+sub msg_by_path ($$) {
         my ($self, $path, $ref) = @_;
         # TODO: allow other refs:
-        my $str = git($self)->cat_file('HEAD:'.$path, $ref);
+        my $str = git($self)->cat_file('HEAD:'.$path);
         $$str =~ s/\A[\r\n]*From [^\r\n]*\r?\n//s if $str;
         $str;
 }
 
-sub msg_by_smsg ($$;$) {
-        my ($self, $smsg, $ref) = @_;
+sub msg_by_smsg ($$) {
+        my ($self, $smsg) = @_;
 
         return unless defined $smsg; # ghost
 
@@ -229,7 +220,7 @@ sub msg_by_smsg ($$;$) {
         defined(my $blob = $smsg->{blob}) or
                         return msg_by_mid($self, $smsg->mid);
 
-        my $str = git($self)->cat_file($blob, $ref);
+        my $str = git($self)->cat_file($blob);
         $$str =~ s/\A[\r\n]*From [^\r\n]*\r?\n//s if $str;
         $str;
 }
@@ -239,9 +230,9 @@ sub path_check {
         git($self)->check('HEAD:'.$path);
 }
 
-sub msg_by_mid ($$;$) {
-        my ($self, $mid, $ref) = @_;
-        msg_by_path($self, mid2path($mid), $ref);
+sub msg_by_mid ($$) {
+        my ($self, $mid) = @_;
+        msg_by_path($self, mid2path($mid));
 }
 
 1;