v157
[gitweb.git] / gitweb.cgi
index b6fa5ec6711f7a92a26070d05c27ceaa3b66e8d0..09ea9998311b7e35054e24ea02f1f2b371907d60 100755 (executable)
 use strict;
 use warnings;
 use CGI qw(:standard :escapeHTML);
+use CGI::Util qw(unescape);
 use CGI::Carp qw(fatalsToBrowser);
 use Fcntl ':mode';
 
 my $cgi = new CGI;
-my $version =          "143";
+my $version =          "157";
 my $my_url =           $cgi->url();
 my $my_uri =           $cgi->url(-absolute => 1);
 my $rss_link = "";
@@ -36,7 +37,7 @@ my $home_text =               "indextext.html";
 
 # source of projects list
 #my $projects_list = $projectroot;
-my $projects_list = "index/index.txt";
+my $projects_list = "index/index.aux";
 
 # input validation and dispatch
 my $action = $cgi->param('a');
@@ -120,6 +121,9 @@ if (defined $time_back) {
 if ($action eq "summary") {
        git_summary();
        exit;
+} elsif ($action eq "branches") {
+       git_branches();
+       exit;
 } elsif ($action eq "tags") {
        git_tags();
        exit;
@@ -192,22 +196,17 @@ div.title, a.title {
 a.title:hover { background-color: #d9d8d1; }
 div.title_text { padding:6px 8px; border: solid #d9d8d1; border-width:0px 0px 1px; }
 div.log_body { padding:8px 8px 8px 150px; }
-span.log_age { position:relative; float:left; width:142px; font-style:italic; }
+span.age { position:relative; float:left; width:142px; font-style:italic; }
 div.log_link {
        font-size:10px; font-family:sans-serif; font-style:normal;
        position:relative; float:left; width:142px;
 }
-div.list { display:block; padding:4px 8px 2px; }
 div.list_head {
        display:block; padding:6px 6px 4px; border:solid #d9d8d1;
-       border-width:0px 0px 1px; font-style:italic;
-}
-div.list a { text-decoration:none; color:#000000; }
-div.list a:hover { color:#880000; }
-div.list_link {
-       padding:4px 8px 6px; border:solid #d9d8d1; border-width:0px 0px 1px;
-       font-family:sans-serif; font-size:10px;
+       border-width:1px 0px 0px; font-style:italic;
 }
+a.list { text-decoration:none; color:#000000; }
+a.list:hover { color:#880000; }
 td { padding:5px 15px 0px 0px; font-size:12px; }
 th { padding-right:10px; font-size:12px; text-align:left; }
 td.link { font-family:sans-serif; font-size:10px; }
@@ -355,7 +354,7 @@ sub git_read_commit {
        $co{'parent'} = $parents[0];
        my (@comment) = map { chomp; $_ } <$fd>;
        $co{'comment'} = \@comment;
-       $comment[0] =~ m/^(.{0,60}[^ ]*)/;
+       $comment[0] =~ m/^(.{0,50}[^ \/\-_:\.]{0,10})/;
        $co{'title'} = $1;
        if ($comment[0] ne $co{'title'}) {
                $co{'title'} .= " ...";
@@ -381,10 +380,10 @@ sub git_read_commit {
                $co{'age_string'} .= " hours ago";
        } elsif ($age > 60*2) {
                $co{'age_string'} = int $age/60;
-               $co{'age_string'} .= " minutes ago";
+               $co{'age_string'} .= " min ago";
        } elsif ($age > 2) {
                $co{'age_string'} = int $age;
-               $co{'age_string'} .= " seconds ago";
+               $co{'age_string'} .= " sec ago";
        } else {
                $co{'age_string'} .= " right now";
        }
@@ -563,7 +562,9 @@ sub git_project_list {
                open my $fd , $projects_list || return undef;
                while (my $line = <$fd>) {
                        chomp $line;
-                       my ($path, $owner) = split ':', $line;
+                       my ($path, $owner) = split ' ', $line;
+                       $path = unescape($path);
+                       $owner = unescape($owner);
                        if (!defined $path) {
                                next;
                        }
@@ -618,7 +619,7 @@ sub git_project_list {
                        $proj{'owner'} = get_file_owner("$projectroot/$proj{'path'}") || "";
                }
                print "<tr>\n" .
-                     "<td>" . $cgi->a({-href => "$my_uri?p=" . $proj{'path'} . ";a=summary"}, escapeHTML($proj{'path'})) . "</td>\n" .
+                     "<td>" . $cgi->a({-href => "$my_uri?p=$proj{'path'};a=summary", -class => "list"}, escapeHTML($proj{'path'})) . "</td>\n" .
                      "<td>$descr</td>\n" .
                      "<td><i>$proj{'owner'}</i></td>\n";
                my $colored_age;
@@ -633,7 +634,6 @@ sub git_project_list {
                      "<td class=\"link\">" .
                      $cgi->a({-href => "$my_uri?p=$proj{'path'};a=summary"}, "summary") .
                      " | " . $cgi->a({-href => "$my_uri?p=$proj{'path'};a=log"}, "log") .
-                     " | " . $cgi->a({-href => "$my_uri?p=$proj{'path'};a=tree"}, "tree") .
                      "</td>\n" .
                      "</tr>\n";
        }
@@ -643,39 +643,41 @@ sub git_project_list {
        git_footer_html();
 }
 
-sub git_read_tags {
-       my @taglist;
+sub git_read_refs {
+       my $ref_dir = shift;
+       my @reflist;
 
-       opendir my $dh, "$projectroot/$project/refs/tags";
-       my @tags = grep !m/^\./, readdir $dh;
+       opendir my $dh, "$projectroot/$project/$ref_dir";
+       my @refs = grep !m/^\./, readdir $dh;
        closedir($dh);
-       foreach my $tag_file (@tags) {
-               my $tag_id = git_read_hash("$project/refs/tags/$tag_file");
-               my $type = git_get_type($tag_id) || next;
-               my %tag_item;
+       foreach my $ref_file (@refs) {
+               my $ref_id = git_read_hash("$project/$ref_dir/$ref_file");
+               my $type = git_get_type($ref_id) || next;
+               my %ref_item;
                my %co;
                if ($type eq "tag") {
-                       my %tag = git_read_tag($tag_id);
+                       my %tag = git_read_tag($ref_id);
                        if ($tag{'type'} eq "commit") {
                                %co = git_read_commit($tag{'object'});
                        }
-                       $tag_item{'type'} = $tag{'type'};
-                       $tag_item{'name'} = $tag{'name'};
-                       $tag_item{'id'} = $tag{'object'};
+                       $ref_item{'type'} = $tag{'type'};
+                       $ref_item{'name'} = $tag{'name'};
+                       $ref_item{'id'} = $tag{'object'};
                } elsif ($type eq "commit"){
-                       %co = git_read_commit($tag_id);
-                       $tag_item{'type'} = "commit";
-                       $tag_item{'name'} = $tag_file;
-                       $tag_item{'id'} = $tag_id;
+                       %co = git_read_commit($ref_id);
+                       $ref_item{'type'} = "commit";
+                       $ref_item{'name'} = $ref_file;
+                       $ref_item{'title'} = $co{'title'};
+                       $ref_item{'id'} = $ref_id;
                }
-               $tag_item{'epoch'} = $co{'author_epoch'} || 0;
-               $tag_item{'age'} = $co{'age_string'} || "unknown";
+               $ref_item{'epoch'} = $co{'committer_epoch'} || 0;
+               $ref_item{'age'} = $co{'age_string'} || "unknown";
 
-               push @taglist, \%tag_item;
+               push @reflist, \%ref_item;
        }
        # sort tags by age
-       @taglist = sort {$b->{'epoch'} <=> $a->{'epoch'}} @taglist;
-       return \@taglist;
+       @reflist = sort {$b->{'epoch'} <=> $a->{'epoch'}} @reflist;
+       return \@reflist;
 }
 
 sub git_summary {
@@ -691,7 +693,9 @@ sub git_summary {
                open (my $fd , $projects_list);
                while (my $line = <$fd>) {
                        chomp $line;
-                       my ($pr, $ow) = split ':', $line;
+                       my ($pr, $ow) = split ' ', $line;
+                       $pr = unescape($pr);
+                       $ow = unescape($ow);
                        if ($pr eq $project) {
                                $owner = $ow;
                                last;
@@ -706,7 +710,7 @@ sub git_summary {
        git_header_html();
        print "<div class=\"page_nav\">\n" .
              $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") .
-             " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;hb=$head"}, "latest tree") .
+             " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree"}, "tree") .
              "<br/><br/>\n" .
              "</div>\n";
        print "<div class=\"title\">project</div>\n";
@@ -721,41 +725,83 @@ sub git_summary {
        my (@revlist) = map { chomp; $_ } <$fd>;
        close $fd;
        print "<div>\n" .
-             $cgi->a({-href => "$my_uri?p=$project;a=log", -class => "title"}, "recent commits") .
+             $cgi->a({-href => "$my_uri?p=$project;a=log", -class => "title"}, "commits") .
              "</div>\n";
        my $i = 10;
+       print  "<div class=\"page_body\">\n" .
+              "<table cellspacing=\"0\">\n";
        foreach my $commit (@revlist) {
                my %co = git_read_commit($commit);
                my %ad = date_str($co{'author_epoch'});
-               print "<div class=\"list\">\n" .
-                     $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"},
-                     "<span class=\"log_age\">" . $co{'age_string'} . "</span>" . escapeHTML($co{'title'})) . "\n" .
-                     "</div>\n";
-               if (--$i == 0) {
-                       print "<div class=\"list\">" . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "...") . "</div>\n";
+               print "<tr>\n";
+               if (--$i > 0) {
+                       print "<td><i>$co{'age_string'}</i></td>\n" .
+                             "<td><i>$co{'author_name'}</i></td>\n" .
+                             "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list"}, "<b>" . escapeHTML($co{'title'}) . "</b>") . "</td>\n" .
+                             "<td class=\"link\">" .
+                             $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") .
+                             " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "commitdiff") .
+                             "</td>\n" .
+                             "</tr>";
+               } else {
+                       print "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "...") . "</td>\n" .
+                       "</tr>";
                        last;
                }
        }
-       print "<div class=\"list\"><br/></div>\n";
+       print "</table\n>" .
+             "</div>\n";
 
-       my $taglist = git_read_tags();
+       my $taglist = git_read_refs("refs/tags");
        if (defined @$taglist) {
                print "<div>\n" .
-                     $cgi->a({-href => "$my_uri?p=$project;a=tags", -class => "title"}, "recent tags") .
+                     $cgi->a({-href => "$my_uri?p=$project;a=tags", -class => "title"}, "tags") .
                      "</div>\n";
                my $i = 10;
+               print  "<div class=\"page_body\">\n" .
+                      "<table cellspacing=\"0\">\n";
                foreach my $entry (@$taglist) {
                        my %tag = %$entry;
-                       print "<div class=\"list\">\n" .
-                             $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'id'}"},
-                             "<span class=\"log_age\">$tag{'age'}</span>" .  escapeHTML($tag{'name'})) . "\n" .
-                             "</div>\n";
-                       if (--$i == 0) {
-                               print "<div class=\"list\">" . $cgi->a({-href => "$my_uri?p=$project;a=tags"}, "...") . "</div>\n";
+                       print "<tr>\n";
+                       if (--$i > 0) {
+                               print "<td><i>$tag{'age'}</i></td>\n" .
+                                     "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'id'}", -class => "list"}, "<b>" . escapeHTML($tag{'name'}) . "</b>") . "</td>\n" .
+                                     "<td class=\"link\">" . $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'id'}"}, $tag{'type'}) . "</td>\n" .
+                                     "</tr>";
+                       } else {
+                               print "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=tags"}, "...") . "</td>\n" .
+                               "</tr>";
                                last;
                        }
                }
-               print "<div class=\"list\"><br/></div>\n";
+               print "</table\n>" .
+                     "</div>\n";
+       }
+
+       my $branchlist = git_read_refs("refs/heads");
+       if (defined @$branchlist) {
+               print "<div>\n" .
+                     $cgi->a({-href => "$my_uri?p=$project;a=branches", -class => "title"}, "branches") .
+                     "</div>\n";
+               my $i = 10;
+               print  "<div class=\"page_body\">\n" .
+                      "<table cellspacing=\"0\">\n";
+               foreach my $entry (@$branchlist) {
+                       my %tag = %$entry;
+                       print "<tr>\n";
+                       if (--$i > 0) {
+                               print "<td><i>$tag{'age'}</i></td>\n" .
+                                     "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}", -class => "list"}, "<b>" . escapeHTML($tag{'name'}) . "</b>") . "</td>\n" .
+                                     "<td class=\"link\">" . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}"}, "log") . "</td>\n" .
+                                     "</tr>";
+                       } else {
+                               print "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=branches"}, "...") . "</td>\n" .
+                               "</tr>";
+                               last;
+                       }
+               }
+               print "</table\n>" .
+                     "</div>\n";
        }
        git_footer_html();
 }
@@ -769,20 +815,54 @@ sub git_tags {
              " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree"}, "tree") .
              "<br/><br/>\n" .
              "</div>\n";
-       my $taglist = git_read_tags();
+       my $taglist = git_read_refs("refs/tags");
        print "<div>\n" .
              $cgi->a({-href => "$my_uri?p=$project;a=summary", -class => "title"}, "tags") .
              "</div>\n";
+       print  "<div class=\"page_body\">\n" .
+              "<table cellspacing=\"0\">\n";
        if (defined @$taglist) {
                foreach my $entry (@$taglist) {
                        my %tag = %$entry;
-                       print "<div class=\"list\">\n" .
-                             $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'id'}"},
-                             "<span class=\"log_age\">$tag{'age'}</span>" .  escapeHTML($tag{'name'})) . "\n" .
-                             "</div>\n";
+                       print "<tr>\n" .
+                             "<td><i>$tag{'age'}</i></td>\n" .
+                             "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}", -class => "list"}, "<b>" . escapeHTML($tag{'name'}) . "</b>") . "</td>\n" .
+                             "<td class=\"link\">" . $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'id'}"}, $tag{'type'}) . "</td>\n" .
+                             "</tr>";
                }
        }
-       print "<div class=\"list\"><br/></div>\n";
+       print "</table\n>" .
+             "</div>\n";
+       git_footer_html();
+}
+
+sub git_branches {
+       my $head = git_read_hash("$project/HEAD");
+       git_header_html();
+       print "<div class=\"page_nav\">\n" .
+             $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") .
+             " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$head"}, "commit") .
+             " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree"}, "tree") .
+             "<br/><br/>\n" .
+             "</div>\n";
+       my $taglist = git_read_refs("refs/heads");
+       print "<div>\n" .
+             $cgi->a({-href => "$my_uri?p=$project;a=summary", -class => "title"}, "branches") .
+             "</div>\n";
+       print  "<div class=\"page_body\">\n" .
+              "<table cellspacing=\"0\">\n";
+       if (defined @$taglist) {
+               foreach my $entry (@$taglist) {
+                       my %tag = %$entry;
+                       print "<tr>\n" .
+                             "<td><i>$tag{'age'}</i></td>\n" .
+                             "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}", -class => "list"}, "<b>" . escapeHTML($tag{'name'}) . "</b>") . "</td>\n" .
+                             "<td class=\"link\">" . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}"}, "log") . "</td>\n" .
+                             "</tr>";
+               }
+       }
+       print "</table\n>" .
+             "</div>\n";
        git_footer_html();
 }
 
@@ -828,7 +908,7 @@ sub git_blob {
                print "<div class=\"page_nav\">\n" .
                      $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") .
                      " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "commitdiff") .
-                     " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash_base"}, "tree");
+                     " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash_base"}, "tree");
                if (defined $file_name) {
                        print " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash_base;f=$file_name"}, "history");
                }
@@ -866,6 +946,9 @@ sub git_tree {
                        my $base = $hash_base || git_read_hash("$project/HEAD");
                        $hash = git_get_hash_by_path($base, $file_name, "tree");
                }
+               if (!defined $hash_base) {
+                       $hash_base = git_read_hash("$project/HEAD");
+               }
        }
        open my $fd, "-|", "$gitbin/git-ls-tree $hash" || die_error(undef, "Open git-ls-tree failed.");
        my (@entries) = map { chomp; $_ } <$fd>;
@@ -909,15 +992,17 @@ sub git_tree {
                my $t_name = $4;
                $file_key = ";f=$base$t_name";
                print "<tr>\n" .
-                     "<td class=\"pre\">" . mode_str($t_mode) . "</td>\n";
+                     "<td style=\"font-family:monospace\">" . mode_str($t_mode) . "</td>\n";
                if ($t_type eq "blob") {
-                       print "<td class=\"pre\">$t_name</td>\n";
+                       print "<td class=\"list\">" .
+                       $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash" . $base_key . $file_key, -class => "list"}, $t_name) .
+                       "</td>\n";
                        print "<td class=\"link\">" .
                              $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash" . $base_key . $file_key}, "blob") .
                              " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash_base" . $file_key}, "history") .
                              "</td>\n";
                } elsif ($t_type eq "tree") {
-                       print "<td class=\"pre\">" .
+                       print "<td class=\"list\">" .
                              $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$t_hash" . $base_key . $file_key}, $t_name) .
                              "</td>\n";
                }
@@ -938,7 +1023,7 @@ sub git_rss {
              "<rss version=\"0.91\">\n";
        print "<channel>\n";
        print "<title>$project</title>\n".
-             "<link> " . $my_url . "/$project/log</link>\n".
+             "<link> $my_url/$project/log</link>\n".
              "<description>$project log</description>\n".
              "<language>en</language>\n";
 
@@ -947,7 +1032,7 @@ sub git_rss {
                my %ad = date_str($co{'author_epoch'});
                print "<item>\n" .
                      "\t<title>" . sprintf("%d %s %02d:%02d", $ad{'mday'}, $ad{'month'}, $ad{'hour'}, $ad{'minute'}) . " - " . escapeHTML($co{'title'}) . "</title>\n" .
-                     "\t<link> " . $my_url . "?p=$project;a=commit;h=$commit</link>\n" .
+                     "\t<link> $my_url?p=$project;a=commit;h=$commit</link>\n" .
                      "\t<description>";
                my $comment = $co{'comment'};
                foreach my $line (@$comment) {
@@ -960,7 +1045,9 @@ sub git_rss {
 }
 
 sub git_log {
-       my $head = git_read_hash("$project/HEAD");
+       if (!defined $hash) {
+               $hash = git_read_hash("$project/HEAD");
+       }
        my $limit_option = "";
        if (!defined $time_back) {
                $limit_option = "--max-count=10";
@@ -968,7 +1055,7 @@ sub git_log {
                my $date = time - $time_back*24*60*60;
                $limit_option = "--max-age=$date";
        }
-       open my $fd, "-|", "$gitbin/git-rev-list $limit_option $head" || die_error(undef, "Open failed.");
+       open my $fd, "-|", "$gitbin/git-rev-list $limit_option $hash" || die_error(undef, "Open failed.");
        my (@revlist) = map { chomp; $_ } <$fd>;
        close $fd || die_error(undef, "Reading rev-list failed.");
 
@@ -984,8 +1071,8 @@ sub git_log {
              "</div>\n";
 
        if (!@revlist) {
-               my %co = git_read_commit($head);
-               print "<div class=\"page_body\"> Last change " . $co{'age_string'} . ".<br/><br/></div>\n";
+               my %co = git_read_commit($hash);
+               print "<div class=\"page_body\"> Last change $co{'age_string'}.<br/><br/></div>\n";
        }
 
        foreach my $commit (@revlist) {
@@ -994,7 +1081,7 @@ sub git_log {
                my %ad = date_str($co{'author_epoch'});
                print "<div>\n" .
                      $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "title"},
-                     "<span class=\"log_age\">" . $co{'age_string'} . "</span>" . escapeHTML($co{'title'})) . "\n" .
+                     "<span class=\"age\">$co{'age_string'}</span>" . escapeHTML($co{'title'})) . "\n" .
                      "</div>\n";
                print "<div class=\"title_text\">\n" .
                      "<div class=\"log_link\">\n" .
@@ -1002,13 +1089,13 @@ sub git_log {
                      " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "commitdiff") .
                      "<br/>\n" .
                      "</div>\n" .
-                     "<i>" . escapeHTML($co{'author_name'}) .  " [" . $ad{'rfc2822'} . "]</i><br/>\n" .
+                     "<i>" . escapeHTML($co{'author_name'}) .  " [$ad{'rfc2822'}]</i><br/>\n" .
                      "</div>\n" .
                      "<div class=\"log_body\">\n";
                my $comment = $co{'comment'};
                my $empty = 0;
                foreach my $line (@$comment) {
-                       if ($line =~ m/^(signed[ \-]off[\-]by[ :]|acked[\-]by[ \:]|cc[ :])/i) {
+                       if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
                                next;
                        }
                        if ($line eq "") {
@@ -1039,7 +1126,7 @@ sub git_commit {
 
        my @difftree;
        if (defined $co{'parent'}) {
-               open my $fd, "-|", "$gitbin/git-diff-tree -r " . $co{'parent'} . " $hash" || die_error(undef, "Open failed.");
+               open my $fd, "-|", "$gitbin/git-diff-tree -r $co{'parent'} $hash" || die_error(undef, "Open failed.");
                @difftree = map { chomp; $_ } <$fd>;
                close $fd || die_error(undef, "Reading diff-tree failed.");
        } else {
@@ -1055,7 +1142,7 @@ sub git_commit {
        if (defined $co{'parent'}) {
                print " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff");
        }
-       print " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash"}, "tree") . "\n" .
+       print " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, "tree") . "\n" .
              "<br/><br/></div>\n";
        if (defined $co{'parent'}) {
                print "<div>\n" .
@@ -1063,13 +1150,13 @@ sub git_commit {
                      "</div>\n";
        } else {
                print "<div>\n" .
-                     $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" .
+                     $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" .
                      "</div>\n";
        }
        print "<div class=\"title_text\">\n" .
              "<table cellspacing=\"0\">\n";
        print "<tr><td>author</td><td>" . escapeHTML($co{'author'}) . "</td></tr>\n".
-             "<tr><td></td><td> " . $ad{'rfc2822'};
+             "<tr><td></td><td> $ad{'rfc2822'}";
        if ($ad{'hour_local'} < 6) {
                printf(" (<span style=\"color: #cc0000;\">%02d:%02d</span> %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
        } else {
@@ -1077,13 +1164,13 @@ sub git_commit {
        }
        print "</td></tr>\n";
        print "<tr><td>committer</td><td>" . escapeHTML($co{'committer'}) . "</td></tr>\n";
-       print "<tr><td></td><td> " . $cd{'rfc2822'} . sprintf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}) . "</td></tr>\n";
-       print "<tr><td>commit</td><td style=\"font-family: monospace;\">$hash</td></tr>\n";
-       print "<tr><td>tree</td><td style=\"font-family: monospace;\">" .
-             $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=" . $hash}, $co{'tree'}) . "</td></tr>\n";
+       print "<tr><td></td><td> $cd{'rfc2822'}" . sprintf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}) . "</td></tr>\n";
+       print "<tr><td>commit</td><td style=\"font-family:monospace\">$hash</td></tr>\n";
+       print "<tr><td>tree</td><td style=\"font-family:monospace\">" .
+             $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, $co{'tree'}) . "</td></tr>\n";
        my $parents  = $co{'parents'};
        foreach my $par (@$parents) {
-               print "<tr><td>parent</td><td style=\"font-family: monospace;\">" .
+               print "<tr><td>parent</td><td style=\"font-family:monospace\">" .
                      $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$par"}, $par) . "</td></tr>\n";
        }
        print "</table>". 
@@ -1102,7 +1189,7 @@ sub git_commit {
                } else {
                        $empty = 0;
                }
-               if ($line =~ m/^(signed[ \-]off[\-]by[ :]|acked[\-]by[ \:]|cc[ :])/i) {
+               if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
                        $signed = 1;
                        print "<span style=\"color: #888888\">" . escapeHTML($line) . "</span><br/>\n";
                } else {
@@ -1116,6 +1203,8 @@ sub git_commit {
                print(($#difftree + 1) . " files changed:\n");
        }
        print "</div>\n";
+       print "<div class=\"page_body\">\n" .
+             "<table cellspacing=\"0\">\n";
        foreach my $line (@difftree) {
                # '*100644->100644      blob    9f91a116d91926df3ba936a80f020a6ab1084d2b->bb90a0c3a91eb52020d0db0e8b4f94d30e02d596      net/ipv4/route.c'
                # '+100644      blob    4a83ab6cd565d21ab0385bac6643826b83c2fcd4        arch/arm/lib/bitops.h'
@@ -1127,70 +1216,69 @@ sub git_commit {
                my $type = $3;
                my $id = $4;
                my $file = $5;
-               if ($type eq "blob") {
-                       if ($op eq "+") {
-                               my $mode_chng = "";
-                               if (S_ISREG(oct $mode)) {
-                                       $mode_chng = sprintf(" with mode: %04o", (oct $mode) & 0777);
+               if ($type ne "blob") {
+                       next;
+               }
+               print "<tr>\n";
+               if ($op eq "+") {
+                       my $mode_chng = "";
+                       if (S_ISREG(oct $mode)) {
+                               $mode_chng = sprintf(" with mode: %04o", (oct $mode) & 0777);
+                       }
+                       print "<td>" .
+                             $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hp=$hash;f=$file", -class => "list"}, escapeHTML($file)) . "</td>\n" .
+                             "<td><span style=\"color: #008000;\">[new " . file_type($mode) . "$mode_chng]</span></td>\n" .
+                             "<td class=\"link\">" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, "blob") . "</td>\n";
+               } elsif ($op eq "-") {
+                       print "<td>" .
+                             $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file", -class => "list"}, escapeHTML($file)) . "</td>\n" .
+                             "<td><span style=\"color: #c00000;\">[deleted " . file_type($mode). "]</span></td>\n" .
+                             "<td class=\"link\">" .
+                             $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, "blob") .
+                             " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") .
+                             "</td>\n"
+               } elsif ($op eq "*") {
+                       $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/;
+                       my $from_id = $1;
+                       my $to_id = $2;
+                       $mode =~ m/^([0-7]{6})->([0-7]{6})$/;
+                       my $from_mode = $1;
+                       my $to_mode = $2;
+                       my $mode_chnge = "";
+                       if ($from_mode != $to_mode) {
+                               $mode_chnge = " <span style=\"color: #777777;\">[changed";
+                               if (((oct $from_mode) & S_IFMT) != ((oct $to_mode) & S_IFMT)) {
+                                       $mode_chnge .= " from " . file_type($from_mode) . " to " . file_type($to_mode);
                                }
-                               print "<div class=\"list\">\n" .
-                                     $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"},
-                                     escapeHTML($file) . " <span style=\"color: #008000;\">[new " . file_type($mode) . $mode_chng . "]</span>") . "\n" .
-                                     "</div>\n";
-                               print "<div class=\"list_link\">\n" .
-                                     $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, "blob") . "\n" .
-                                     "</div>\n";
-                       } elsif ($op eq "-") {
-                               print "<div class=\"list\">\n" .
-                                     $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"},
-                                     escapeHTML($file) .  " <span style=\"color: #c00000;\">[deleted " . file_type($mode) . "]</span>") . "\n" .
-                                     "</div>";
-                               print "<div class=\"list_link\">\n" .
-                                     $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, "blob") . " | " .
-                                     $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . "\n" .
-                                     "</div>\n";
-                       } elsif ($op eq "*") {
-                               $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/;
-                               my $from_id = $1;
-                               my $to_id = $2;
-                               $mode =~ m/^([0-7]{6})->([0-7]{6})$/;
-                               my $from_mode = $1;
-                               my $to_mode = $2;
-                               my $mode_chnge = "";
-                               if ($from_mode != $to_mode) {
-                                       $mode_chnge = " <span style=\"color: #777777;\">[changed";
-                                       if (((oct $from_mode) & S_IFMT) != ((oct $to_mode) & S_IFMT)) {
-                                               $mode_chnge .= " from " . file_type($from_mode) . " to " . file_type($to_mode);
-                                       }
-                                       if (((oct $from_mode) & 0777) != ((oct $to_mode) & 0777)) {
-                                               if (S_ISREG($from_mode) && S_ISREG($to_mode)) {
-                                                       $mode_chnge .= sprintf(" mode: %04o->%04o", (oct $from_mode) & 0777, (oct $to_mode) & 0777);
-                                               } elsif (S_ISREG($to_mode)) {
-                                                       $mode_chnge .= sprintf(" mode: %04o", (oct $to_mode) & 0777);
-                                               }
+                               if (((oct $from_mode) & 0777) != ((oct $to_mode) & 0777)) {
+                                       if (S_ISREG($from_mode) && S_ISREG($to_mode)) {
+                                               $mode_chnge .= sprintf(" mode: %04o->%04o", (oct $from_mode) & 0777, (oct $to_mode) & 0777);
+                                       } elsif (S_ISREG($to_mode)) {
+                                               $mode_chnge .= sprintf(" mode: %04o", (oct $to_mode) & 0777);
                                        }
-                                       $mode_chnge .= "]</span>\n";
-                               }
-                               print "<div class=\"list\">\n";
-                               if ($to_id ne $from_id) {
-                                       print $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file"},
-                                             escapeHTML($file) . $mode_chnge) . "\n" .
-                                             "</div>\n";
-                               } else {
-                                       print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"},
-                                             escapeHTML($file) . $mode_chnge) . "\n" .
-                                             "</div>\n";
                                }
-                               print "<div class=\"list_link\">\n";
-                               if ($to_id ne $from_id) {
-                                       print $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file"}, "diff") . " | ";
-                               }
-                               print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"}, "blob") . " | " .
-                                     $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . "\n" .
-                                     "</div>\n";
+                               $mode_chnge .= "]</span>\n";
                        }
+                       print "<td>";
+                       if ($to_id ne $from_id) {
+                               print $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file", -class => "list"}, escapeHTML($file));
+                       } else {
+                               print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file", -class => "list"}, escapeHTML($file));
+                       }
+                       print "</td>\n" .
+                             "<td>$mode_chnge</td>\n" .
+                             "<td class=\"link\">";
+                       print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"}, "blob");
+                       if ($to_id ne $from_id) {
+                               print " | " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file"}, "diff");
+                       }
+                       print " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . "\n";
+                       print "</td>\n";
                }
+               print "</tr>\n";
        }
+       print "</table><br/>\n" .
+             "</div>\n";
        git_footer_html();
 }
 
@@ -1202,7 +1290,7 @@ sub git_blobdiff {
                      $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") .
                      " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") .
                      " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "commitdiff") .
-                     " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash_base"}, "tree");
+                     " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash_base"}, "tree");
                        if (defined $file_name) {
                                print " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash_base;f=$file_name"}, "history");
                        }
@@ -1238,7 +1326,7 @@ sub git_commitdiff {
        if (!%co) {
                die_error(undef, "Unknown commit object.");
        }
-       open my $fd, "-|", "$gitbin/git-diff-tree -r " . $co{'parent'} . " $hash" || die_error(undef, "Open failed.");
+       open my $fd, "-|", "$gitbin/git-diff-tree -r $co{'parent'} $hash" || die_error(undef, "Open failed.");
        my (@difftree) = map { chomp; $_ } <$fd>;
        close $fd || die_error(undef, "Reading diff-tree failed.");
 
@@ -1253,6 +1341,30 @@ sub git_commitdiff {
              $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" .
              "</div>\n";
        print "<div class=\"page_body\">\n";
+       my $comment = $co{'comment'};
+       my $empty = 0;
+       my $signed = 0;
+       my @log = @$comment;
+       # remove first and empty lines after that
+       shift @log;
+       while (defined $log[0] && $log[0] eq "") {
+               shift @log;
+       }
+       foreach my $line (@log) {
+               if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
+                       next;
+               }
+               if ($line eq "") {
+                       if ($empty) {
+                               next;
+                       }
+                       $empty = 1;
+               } else {
+                       $empty = 0;
+               }
+               print escapeHTML($line) . "<br/>\n";
+       }
+       print "<br/>\n";
        foreach my $line (@difftree) {
                # '*100644->100644      blob    8e5f9bbdf4de94a1bc4b4da8cb06677ce0a57716->8da3a306d0c0c070d87048d14a033df02f40a154      Makefile'
                $line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/;
@@ -1307,7 +1419,7 @@ sub git_history {
        print "<div class=\"page_nav\">\n" .
              $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | " .
              $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff") . " | " .
-             $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash"}, "tree") .
+             $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, "tree") .
              "<br/><br/>\n" .
              "</div>\n";
        print "<div>\n" .
@@ -1316,8 +1428,11 @@ sub git_history {
        print "<div class=\"page_path\">\n" .
              "/$file_name<br/>\n";
        print "</div>\n";
+
        open my $fd, "-|", "$gitbin/git-rev-list $hash | $gitbin/git-diff-tree -r --stdin $file_name";
        my $commit;
+       print "<div class=\"page_body\">\n" .
+             "<table cellspacing=\"0\">\n";
        while (my $line = <$fd>) {
                if ($line =~ m/^([0-9a-fA-F]{40}) /){
                        $commit = $1;
@@ -1333,24 +1448,26 @@ sub git_history {
                        if (!%co) {
                                next;
                        }
-                       print "<div class=\"list\">\n" .
-                             $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"},
-                             "<span class=\"log_age\">" . $co{'age_string'} . "</span>" . escapeHTML($co{'title'})) . "\n" .
-                             "</div>\n";
-                       print "<div class=\"list_link\">\n" .
+                       print "<tr>" .
+                             "<td><i>$co{'age_string'}</i></td>\n" .
+                             "<td><i>$co{'author_name'}</i></td>\n" .
+                             "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list"}, "<b>" . escapeHTML($co{'title'}) . "</b>") . "</td>\n" .
+                             "<td class=\"link\">" .
                              $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") .
                              " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" .  $co{'tree'} . ";hb=$commit"}, "tree") .
-                             " | " . $cgi->a({-href => "$my_uri?p=$project;a=blob;hb=$commit;f=" . $file}, "blob");
+                             " | " . $cgi->a({-href => "$my_uri?p=$project;a=blob;hb=$commit;f=$file"}, "blob");
                        my $blob = git_get_hash_by_path($hash, $file_name);
                        my $blob_parent = git_get_hash_by_path($commit, $file_name);
                        if (defined $blob && defined $blob_parent && $blob ne $blob_parent) {
-                               print " | " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$blob;hp=$blob_parent;hb=$commit;f=" . $file}, "diff");
+                               print " | " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$blob;hp=$blob_parent;hb=$commit;f=$file"}, "diff");
                        }
-                       print "<br/>\n" .
-                             "</div>\n";
+                       print "</td>\n" .
+                             "</tr>\n";
                        undef $commit;
                }
        }
+       print "</table><br/>\n" .
+             "</div>\n";
        close $fd;
        git_footer_html();
 }