Fix showing of path in tree view
authorPetr Baudis <pasky@ucw.cz>
Thu, 21 Sep 2006 00:05:50 +0000 (02:05 +0200)
committerJunio C Hamano <junkio@cox.net>
Thu, 21 Sep 2006 08:16:45 +0000 (01:16 -0700)
This patch fixes two things - links to all path elements except the last
one were broken since gitweb does not like the trailing slash in them, and
the root tree was not reachable from the subdirectory view.

To compensate for the one more slash in the front, the trailing slash is
not there anymore. ;-) I don't care if it stays there though.

Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
gitweb/gitweb.perl

index ea5771737e77a06d90a1f07d61c0769c743e4dac..fb8d37eb7b2a40a2f092f580456aaf4eec1699b5 100755 (executable)
@@ -1514,12 +1514,15 @@ sub git_print_page_path {
                my $fullname = '';
 
                print "<div class=\"page_path\">";
+               print $cgi->a({-href => href(action=>"tree", hash_base=>$hb),
+                             -title => '/'}, '/');
+               print " ";
                foreach my $dir (@dirname) {
-                       $fullname .= $dir . '/';
+                       $fullname .= ($fullname ? '/' : '') . $dir;
                        print $cgi->a({-href => href(action=>"tree", file_name=>$fullname,
                                                     hash_base=>$hb),
-                                     -title => $fullname}, esc_html($dir));
-                       print "/";
+                                     -title => $fullname}, esc_html($dir . '/'));
+                       print " ";
                }
                if (defined $type && $type eq 'blob') {
                        print $cgi->a({-href => href(action=>"blob_plain", file_name=>$file_name,
@@ -1528,8 +1531,7 @@ sub git_print_page_path {
                } elsif (defined $type && $type eq 'tree') {
                        print $cgi->a({-href => href(action=>"tree", file_name=>$file_name,
                                                     hash_base=>$hb),
-                                     -title => $name}, esc_html($basename));
-                       print "/";
+                                     -title => $name}, esc_html($basename . '/'));
                } else {
                        print esc_html($basename);
                }