]> Sergey Matveev's repositories - public-inbox.git/commitdiff
www_coderepo: show tree root as "(root)"
authorEric Wong <e@80x24.org>
Tue, 10 Jan 2023 11:49:19 +0000 (11:49 +0000)
committerEric Wong <e@80x24.org>
Wed, 11 Jan 2023 04:41:16 +0000 (04:41 +0000)
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.

lib/PublicInbox/ViewVCS.pm

index 99ee2c116a4eabac80fa87c085dbe6041dd9df51..d8f6742f01b7f284897a6ae6efcd3d773465ddd1 100644 (file)
@@ -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];