From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.1 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 9383F1FA29 for ; Tue, 10 Jan 2023 11:49:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1673351361; bh=P4RAw0R53s3JOe2pf69+KisfpKCdT2261YU+bleebLY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=LWJAKUrHqu/PkCX7q6uAU9HHZf8RMj8p5X66ORXWp9Pcrrr7OPd9AYf0VdgNG4SS/ ZJaNhqtYdmRIq1svi/AsjUKUngjTtRysHSCGR8e1uNWqX9d72hllCSZvymvfEJ8qYg eICylkRgSTHtEULuuKpblb5Z8MEX7lz47xCRWgLw= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 2/4] www_coderepo: show tree root as "(root)" Date: Tue, 10 Jan 2023 11:49:19 +0000 Message-Id: <20230110114921.2668377-3-e@80x24.org> In-Reply-To: <20230110114921.2668377-1-e@80x24.org> References: <20230110114921.2668377-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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 | 12 ++++++++---- 1 file 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)\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];