]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
repobrowse: remove unused "blob" endpoint
authorEric Wong <e@80x24.org>
Fri, 3 Mar 2017 01:14:07 +0000 (01:14 +0000)
committerEric Wong <e@80x24.org>
Fri, 3 Mar 2017 01:14:35 +0000 (01:14 +0000)
This is redundant with the "raw" endpoint.

MANIFEST
lib/PublicInbox/RepoGitBlob.pm [deleted file]
lib/PublicInbox/RepoGitRaw.pm
lib/PublicInbox/Repobrowse.pm

index d49b45ceaf3d37d524303295a7de497aea2b3d57..f0a0b0fefc9d85d3e911989133324e39fe86241b 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -85,7 +85,6 @@ lib/PublicInbox/RepoBase.pm
 lib/PublicInbox/RepoConfig.pm
 lib/PublicInbox/RepoGit.pm
 lib/PublicInbox/RepoGitAtom.pm
-lib/PublicInbox/RepoGitBlob.pm
 lib/PublicInbox/RepoGitCommit.pm
 lib/PublicInbox/RepoGitDiff.pm
 lib/PublicInbox/RepoGitDiffCommon.pm
diff --git a/lib/PublicInbox/RepoGitBlob.pm b/lib/PublicInbox/RepoGitBlob.pm
deleted file mode 100644 (file)
index 84f48c6..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-# Copyright (C) 2015-2016 all contributors <meta@public-inbox.org>
-# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
-
-# Show a blob as-is
-package PublicInbox::RepoGitBlob;
-use strict;
-use warnings;
-use base qw(PublicInbox::RepoBase);
-use base qw(Exporter);
-our @EXPORT = qw(git_blob_mime_type git_blob_stream_response);
-
-sub call_git_blob {
-       my ($self, $req) = @_;
-       my $repo = $req->{-repo};
-       my $git = $repo->{git};
-       my $id = $repo->tip . ':' . $req->{expath};
-
-       my ($cat, $hex, $type, $size) = $git->cat_file_begin($id);
-       return unless defined $cat;
-
-       my ($r, $buf);
-       my $left = $size;
-       if ($type eq 'blob') {
-               $type = git_blob_mime_type($self, $req, $cat, \$buf, \$left);
-       } elsif ($type eq 'commit' || $type eq 'tag') {
-               $type = 'text/plain; charset=UTF-8';
-       } else {
-               $type = 'application/octet-stream';
-       }
-       git_blob_stream_response($git, $cat, $size, $type, $buf, $left);
-}
-
-sub git_blob_mime_type {
-       my ($self, $req, $cat, $buf, $left) = @_;
-       my $base = $req->{extra}->[-1];
-       my $type = $self->mime_type($base) if defined $base;
-       return $type if $type;
-
-       my $to_read = 8000; # git uses this size to detect binary files
-       $to_read = $$left if $to_read > $$left;
-       my $r = read($cat, $$buf, $to_read);
-       if (!defined $r || $r <= 0) {
-               my $git = $req->{-repo}->{git};
-               $git->cat_file_finish($$left);
-               return;
-       }
-       $$left -= $r;
-       (index($buf, "\0") < 0) ? 'text/plain; charset=UTF-8'
-                               : 'application/octet-stream';
-}
-
-sub git_blob_stream_response {
-       my ($git, $cat, $size, $type, $buf, $left) = @_;
-
-       sub {
-               my ($res) = @_;
-               my $to_read = 8192;
-               eval {
-                       my $fh = $res->([ 200, ['Content-Length', $size,
-                                               'Content-Type', $type]]);
-                       $fh->write($buf) if defined $buf;
-                       while ($left > 0) {
-                               $to_read = $left if $to_read > $left;
-                               my $r = read($cat, $buf, $to_read);
-                               last if (!defined $r || $r <= 0);
-                               $left -= $r;
-                               $fh->write($buf);
-                       }
-                       $fh->close;
-               };
-               $git->cat_file_finish($left);
-       }
-}
-
-1;
index 7d2c0d22edcd32d09100492f27cc5f8f9aca629e..b990c7e7ba133eb2709090c060dc492a2c448c86 100644 (file)
@@ -4,7 +4,6 @@ package PublicInbox::RepoGitRaw;
 use strict;
 use warnings;
 use base qw(PublicInbox::RepoBase);
-use PublicInbox::RepoGitBlob;
 use PublicInbox::Hval qw(utf8_html);
 use PublicInbox::Qspawn;
 
@@ -91,4 +90,47 @@ sub git_tree_raw {
        });
 }
 
+sub git_blob_mime_type {
+       my ($self, $req, $cat, $buf, $left) = @_;
+       my $base = $req->{extra}->[-1];
+       my $type = $self->mime_type($base) if defined $base;
+       return $type if $type;
+
+       my $to_read = 8000; # git uses this size to detect binary files
+       $to_read = $$left if $to_read > $$left;
+       my $r = read($cat, $$buf, $to_read);
+       if (!defined $r || $r <= 0) {
+               my $git = $req->{-repo}->{git};
+               $git->cat_file_finish($$left);
+               return;
+       }
+       $$left -= $r;
+       (index($buf, "\0") < 0) ? 'text/plain; charset=UTF-8'
+                               : 'application/octet-stream';
+}
+
+sub git_blob_stream_response {
+       my ($git, $cat, $size, $type, $buf, $left) = @_;
+
+       sub {
+               my ($res) = @_;
+               my $to_read = 8192;
+               eval {
+                       my $fh = $res->([ 200, ['Content-Length', $size,
+                                               'Content-Type', $type]]);
+                       $fh->write($buf) if defined $buf;
+                       while ($left > 0) {
+                               $to_read = $left if $to_read > $left;
+                               my $r = read($cat, $buf, $to_read);
+                               last if (!defined $r || $r <= 0);
+                               $left -= $r;
+                               $fh->write($buf);
+                       }
+                       $fh->close;
+               };
+               $git->cat_file_finish($left);
+       }
+}
+
+
 1;
index 5ef9e59a71eb49e964563131a1b0880d26cb819c..03960e2b63b4f9e8163ad1b8b6bfdc9c08c34961 100644 (file)
@@ -22,7 +22,7 @@ use strict;
 use warnings;
 use PublicInbox::RepoConfig;
 
-my %CMD = map { lc($_) => $_ } qw(Log Commit Src Patch Blob Raw Tag Atom
+my %CMD = map { lc($_) => $_ } qw(Log Commit Src Patch Raw Tag Atom
        Diff Snapshot);
 my %VCS = (git => 'Git');
 my %LOADED;
@@ -93,7 +93,7 @@ sub call {
        }
 
        # URL syntax: / repo [ / cmd [ / head [ / path ] ] ]
-       # cmd: log | commit | diff | src | view | blob | snapshot
+       # cmd: log | commit | diff | src | raw | snapshot
        # repo and path (@extra) may both contain '/'
        my $path_info = $env->{PATH_INFO};
        my (undef, $repo_path, @extra) = split(m{/+}, $path_info, -1);