]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
repobrowse: show invalid type for tree views
authorEric Wong <e@80x24.org>
Thu, 7 Apr 2016 00:12:59 +0000 (00:12 +0000)
committerEric Wong <e@80x24.org>
Thu, 7 Apr 2016 00:12:59 +0000 (00:12 +0000)
Show some diagnostic information for non-(blob|tree) objects
to perhaps help users figure out what to do with other objects.

lib/PublicInbox/RepobrowseGitTree.pm

index b7dd101e0a0773cded47dcdfd8f7237eaab797bf..6e25200dfe6b270bab5ba59b61217aa7bde4ddc3 100644 (file)
@@ -30,10 +30,15 @@ sub git_tree_stream {
        my $obj = "$id:$req->{expath}";
        my ($hex, $type, $size) = $git->check($obj);
 
-       if (!defined($type) || ($type ne 'blob' && $type ne 'tree')) {
-               return $res->([404, ['Content-Type'=>'text/html'],
+       unless (defined($type)) {
+               return $res->([404, ['Content-Type'=>'text/plain'],
                         ['Not Found']]);
        }
+       if ($type ne 'blob' && $type ne 'tree') {
+               return $res->([404,
+                       ['Content-Type'=>'text/plain; charset=UTF-8'],
+                        ["Unrecognized type ($type) for $obj\n"]]);
+       }
 
        my $fh = $res->([200, ['Content-Type'=>'text/html; charset=UTF-8']]);
        my $opts = { nofollow => 1 };