gitweb: Separate printing of git_tree row into git_print_tree_entry
This is preparation for "tree blame" (similar to what ViewVC shows) output, i.e. for each entry give commit where it was changed. Signed-off-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
Jakub Narebski committed
Aug 31, 2006 at 00:35 UTC
fa702003e4f63ecdc71d16b51efc02f33fe7931f
1 file changed
+59
-44
gitweb/gitweb.perl
+59
-44
@@ -1475,6 +1475,62 @@ sub git_print_simplified_log {
1475
-remove_title => $remove_title);
1476
}
1477
1478
+# print tree entry (row of git_tree), but without encompassing <tr> element
1479
+sub git_print_tree_entry {
1480
+ my ($t, $basedir, $hash_base, $have_blame) = @_;
1481
+
1482
+ my %base_key = ();
1483
+ $base_key{hash_base} = $hash_base if defined $hash_base;
1484
+
1485
+ print "<td class=\"mode\">" . mode_str($t->{'mode'}) . "</td>\n";
1486
+ if ($t->{'type'} eq "blob") {
1487
+ print "<td class=\"list\">" .
1488
+ $cgi->a({-href => href(action=>"blob", hash=>$t->{'hash'},
1489
+ file_name=>"$basedir$t->{'name'}", %base_key),
1490
+ -class => "list"}, esc_html($t->{'name'})) .
1491
+ "</td>\n" .
1492
+ "<td class=\"link\">" .
1493
+ $cgi->a({-href => href(action=>"blob", hash=>$t->{'hash'},
1494
+ file_name=>"$basedir$t->{'name'}", %base_key)},
1495
+ "blob");
1496
+ if ($have_blame) {
1497
+ print " | " .
1498
+ $cgi->a({-href => href(action=>"blame", hash=>$t->{'hash'},
1499
+ file_name=>"$basedir$t->{'name'}", %base_key)},
1500
+ "blame");
1501
+ }
1502
+ if (defined $hash_base) {
1503
+ print " | " .
1504
+ $cgi->a({-href => href(action=>"history", hash_base=>$hash_base,
1505
+ hash=>$t->{'hash'}, file_name=>"$basedir$t->{'name'}")},
1506
+ "history");
1507
+ }
1508
+ print " | " .
1509
+ $cgi->a({-href => href(action=>"blob_plain",
1510
+ hash=>$t->{'hash'}, file_name=>"$basedir$t->{'name'}")},
1511
+ "raw") .
1512
+ "</td>\n";
1513
+
1514
+ } elsif ($t->{'type'} eq "tree") {
1515
+ print "<td class=\"list\">" .
1516
+ $cgi->a({-href => href(action=>"tree", hash=>$t->{'hash'},
1517
+ file_name=>"$basedir$t->{'name'}", %base_key)},
1518
+ esc_html($t->{'name'})) .
1519
+ "</td>\n" .
1520
+ "<td class=\"link\">" .
1521
+ $cgi->a({-href => href(action=>"tree", hash=>$t->{'hash'},
1522
+ file_name=>"$basedir$t->{'name'}", %base_key)},
1523
+ "tree");
1524
+ if (defined $hash_base) {
1525
+ print " | " .
1526
+ $cgi->a({-href => href(action=>"history", hash_base=>$hash_base,
1527
+ file_name=>"$basedir$t->{'name'}")},
1528
+ "history");
1529
+ }
1530
+ print "</td>\n";
1531
+ }
1532
+}
1533
+
1534
## ......................................................................
1535
## functions printing large fragments of HTML
1536
@@ -2513,14 +2569,13 @@ sub git_tree {
2569
my $refs = git_get_references();
2570
my $ref = format_ref_marker($refs, $hash_base);
2571
git_header_html();
2516
- my %base_key = ();
2572
my $base = "";
2573
my $have_blame = gitweb_check_feature('blame');
2574
if (defined $hash_base && (my %co = parse_commit($hash_base))) {
2520
- $base_key{hash_base} = $hash_base;
2575
git_print_page_nav('tree','', $hash_base);
2576
git_print_header_div('commit', esc_html($co{'title'}) . $ref, $hash_base);
2577
} else {
2578
+ undef $hash_base;
2579
print "<div class=\"page_nav\">\n";
2580
print "<br/><br/></div>\n";
2581
print "<div class=\"title\">$hash</div>\n";
@@ -2542,48 +2597,8 @@ sub git_tree {
2597
}
2598
$alternate ^= 1;
2599
2545
- print "<td class=\"mode\">" . mode_str($t{'mode'}) . "</td>\n";
2546
- if ($t{'type'} eq "blob") {
2547
- print "<td class=\"list\">" .
2548
- $cgi->a({-href => href(action=>"blob", hash=>$t{'hash'},
2549
- file_name=>"$base$t{'name'}", %base_key),
2550
- -class => "list"}, esc_html($t{'name'})) .
2551
- "</td>\n" .
2552
- "<td class=\"link\">" .
2553
- $cgi->a({-href => href(action=>"blob", hash=>$t{'hash'},
2554
- file_name=>"$base$t{'name'}", %base_key)},
2555
- "blob");
2556
- if ($have_blame) {
2557
- print " | " .
2558
- $cgi->a({-href => href(action=>"blame", hash=>$t{'hash'},
2559
- file_name=>"$base$t{'name'}", %base_key)},
2560
- "blame");
2561
- }
2562
- print " | " .
2563
- $cgi->a({-href => href(action=>"history", hash_base=>$hash_base,
2564
- hash=>$t{'hash'}, file_name=>"$base$t{'name'}")},
2565
- "history") .
2566
- " | " .
2567
- $cgi->a({-href => href(action=>"blob_plain",
2568
- hash=>$t{'hash'}, file_name=>"$base$t{'name'}")},
2569
- "raw") .
2570
- "</td>\n";
2571
- } elsif ($t{'type'} eq "tree") {
2572
- print "<td class=\"list\">" .
2573
- $cgi->a({-href => href(action=>"tree", hash=>$t{'hash'},
2574
- file_name=>"$base$t{'name'}", %base_key)},
2575
- esc_html($t{'name'})) .
2576
- "</td>\n" .
2577
- "<td class=\"link\">" .
2578
- $cgi->a({-href => href(action=>"tree", hash=>$t{'hash'},
2579
- file_name=>"$base$t{'name'}", %base_key)},
2580
- "tree") .
2581
- " | " .
2582
- $cgi->a({-href => href(action=>"history", hash_base=>$hash_base,
2583
- file_name=>"$base$t{'name'}")},
2584
- "history") .
2585
- "</td>\n";
2586
- }
2600
+ git_print_tree_entry(\%t, $base, $hash_base, $have_blame);
2601
+
2602
print "</tr>\n";
2603
}
2604
print "</table>\n" .