about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-01-10 11:49:19 +0000
committerEric Wong <e@80x24.org>2023-01-11 04:41:16 +0000
commit3e29a9a80e6f940e8b8f7f6b92318793d5d30b90 (patch)
treef2eb8670fe57786578cab72e73ec7fb79a252956
parent801fa47f85990ee8c9cd68dc3ebedc7f55cd486a (diff)
downloadpublic-inbox-3e29a9a80e6f940e8b8f7f6b92318793d5d30b90.tar.gz
We'll use the `b=' parameter as a hint.  I originally considered
`b=/', but a singular slash `/' isn't used in git for paths.
$refname:$path resolution where $path is an empty string,
`git cat-file -t $refname:' resolves to the tree, so it seems
special-casing the empty string is fine in the web UI, too.
-rw-r--r--lib/PublicInbox/ViewVCS.pm12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/PublicInbox/ViewVCS.pm b/lib/PublicInbox/ViewVCS.pm
index 99ee2c11..d8f6742f 100644
--- a/lib/PublicInbox/ViewVCS.pm
+++ b/lib/PublicInbox/ViewVCS.pm
@@ -212,7 +212,7 @@ href="$f.patch">patch</a>)\n   <a href=#parent>parent</a> $P->[0]};
         my $zfh = $ctx->zfh;
         print $zfh <<EOM;
 <pre>   <a href=#commit>commit</a> $H$x
-     <a href=#tree>tree</a> <a href="$upfx$T/s/">$T</a>
+     <a href=#tree>tree</a> <a href="$upfx$T/s/?b=">$T</a>
    author $au
 committer $co
 
@@ -362,9 +362,13 @@ sub show_tree_result ($$) {
         my $pfx = $qp->{b};
         $$bref = "<pre><a href=#tree>tree</a> $ctx->{tree_oid}";
         if (defined $pfx) {
-                my $x = ascii_html($pfx);
-                $pfx .= '/';
-                $$bref .= qq(  <a href=#path>path</a>: $x</a>\n);
+                if ($pfx eq '') {
+                        $$bref .= "  (root)\n";
+                } else {
+                        my $x = ascii_html($pfx);
+                        $pfx .= '/';
+                        $$bref .= qq(  <a href=#path>path</a>: $x</a>\n);
+                }
         } else {
                 $pfx = '';
                 $$bref .= qq[  (<a href=#path>path</a> unknown)\n];