Skip to content

Commit

Permalink
gitweb: Add '..' (up directory) to tree view if applicable
Browse files Browse the repository at this point in the history
Adds '..' (up directory) link at the top of "tree" view listing,
if both $hash_base and $file_name are provided, and $file_name
is not empty string.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Jakub Narebski authored and Junio C Hamano committed Oct 23, 2006
1 parent 4df118e commit b6b7fc7
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions gitweb/gitweb.perl
Original file line number Diff line number Diff line change
Expand Up @@ -2871,6 +2871,30 @@ sub git_tree {
print "<div class=\"page_body\">\n";
print "<table cellspacing=\"0\">\n";
my $alternate = 1;
# '..' (top directory) link if possible
if (defined $hash_base &&
defined $file_name && $file_name =~ m![^/]+$!) {
if ($alternate) {
print "<tr class=\"dark\">\n";
} else {
print "<tr class=\"light\">\n";
}
$alternate ^= 1;

my $up = $file_name;
$up =~ s!/?[^/]+$!!;
undef $up unless $up;
# based on git_print_tree_entry
print '<td class="mode">' . mode_str('040000') . "</td>\n";
print '<td class="list">';
print $cgi->a({-href => href(action=>"tree", hash_base=>$hash_base,
file_name=>$up)},
"..");
print "</td>\n";
print "<td class=\"link\"></td>\n";

print "</tr>\n";
}
foreach my $line (@entries) {
my %t = parse_ls_tree_line($line, -z => 1);

Expand Down

0 comments on commit b6b7fc7

Please sign in to comment.