]> Lady’s Gitweb - Gitweb/commitdiff
gitweb: Improve git_print_page_path
authorJakub Narebski <redacted>
Sat, 21 Oct 2006 15:53:55 +0000 (17:53 +0200)
committerLady <redacted>
Mon, 6 Apr 2026 04:07:10 +0000 (00:07 -0400)
Add link to "tree root" (root directory) also for not defined name,
for example for "tree" action without defined "file_name" which means
"tree root".

Add " / " at the end of path when $type eq "tree".

Signed-off-by: Jakub Narebski <redacted>
Signed-off-by: Junio C Hamano <redacted>
gitweb.perl

index 0b82e92bc3b9b5a4f0542a02b794d37e0ab5d56fda70a39296f6f9de5c745dd5..e3c030a3025f4f4dc9e191b3dbb7ce8ee611eae22aaf0b4837c458e6bcda52ef 100755 (executable)
@@ -1681,17 +1681,16 @@ sub git_print_page_path {
        my $type = shift;
        my $hb = shift;
 
-       if (!defined $name) {
-               print "<div class=\"page_path\">/</div>\n";
-       } else {
+
+       print "<div class=\"page_path\">";
+       print $cgi->a({-href => href(action=>"tree", hash_base=>$hb),
+                     -title => 'tree root'}, "[$project]");
+       print " / ";
+       if (defined $name) {
                my @dirname = split '/', $name;
                my $basename = pop @dirname;
                my $fullname = '';
 
-               print "<div class=\"page_path\">";
-               print $cgi->a({-href => href(action=>"tree", hash_base=>$hb),
-                             -title => 'tree root'}, "[$project]");
-               print " / ";
                foreach my $dir (@dirname) {
                        $fullname .= ($fullname ? '/' : '') . $dir;
                        print $cgi->a({-href => href(action=>"tree", file_name=>$fullname,
@@ -1707,11 +1706,12 @@ sub git_print_page_path {
                        print $cgi->a({-href => href(action=>"tree", file_name=>$file_name,
                                                     hash_base=>$hb),
                                      -title => $name}, esc_html($basename));
+                       print " / ";
                } else {
                        print esc_html($basename);
                }
-               print "<br/></div>\n";
        }
+       print "<br/></div>\n";
 }
 
 # sub git_print_log (\@;%) {
This page took 0.347447 seconds and 4 git commands to generate.