From: Eric Wong Date: Tue, 10 Jan 2023 11:49:19 +0000 (+0000) Subject: www_coderepo: show tree root as "(root)" X-Git-Url: http://www.git.stargrave.org/?p=public-inbox.git;a=commitdiff_plain;h=3e29a9a80e6f940e8b8f7f6b92318793d5d30b90 www_coderepo: show tree root as "(root)" 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. --- 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)\n parent $P->[0]}; my $zfh = $ctx->zfh; print $zfh < commit $H$x - tree $T + tree $T author $au committer $co @@ -362,9 +362,13 @@ sub show_tree_result ($$) { my $pfx = $qp->{b}; $$bref = "
tree $ctx->{tree_oid}";
 	if (defined $pfx) {
-		my $x = ascii_html($pfx);
-		$pfx .= '/';
-		$$bref .= qq(  path: $x\n);
+		if ($pfx eq '') {
+			$$bref .= "  (root)\n";
+		} else {
+			my $x = ascii_html($pfx);
+			$pfx .= '/';
+			$$bref .= qq(  path: $x\n);
+		}
 	} else {
 		$pfx = '';
 		$$bref .= qq[  (path unknown)\n];