use Fcntl ':mode';
my $cgi = new CGI;
-my $version = "150";
+my $version = "164";
my $my_url = $cgi->url();
my $my_uri = $cgi->url(-absolute => 1);
my $rss_link = "";
font-weight:bold; background-color:#edece6; text-decoration:none; color:#000000;
}
a.title:hover { background-color: #d9d8d1; }
-div.title_text { padding:6px 8px; border: solid #d9d8d1; border-width:0px 0px 1px; }
+div.title_text { padding:6px 0px; border: solid #d9d8d1; border-width:0px 0px 1px; }
div.log_body { padding:8px 8px 8px 150px; }
span.age { position:relative; float:left; width:142px; font-style:italic; }
div.log_link {
+ padding:0px 8px;
font-size:10px; font-family:sans-serif; font-style:normal;
- position:relative; float:left; width:142px;
+ position:relative; float:left; width:136px;
}
-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;
-}
-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; }
-td.pre { font-family:monospace; font-size:12px; white-space:pre; padding:2px 15px 0px 0px; }
+div.list_head { padding:6px 8px 4px; border:solid #d9d8d1; border-width:1px 0px 0px; font-style:italic; }
+a.list { text-decoration:none; color:#000000; }
+a.list:hover { color:#880000; }
+table { padding:8px 4px; }
+th { padding:2px 5px; font-size:12px; text-align:left; }
+td { padding:2px 5px; font-size:12px; }
+td.link { padding:2px 5px; font-family:sans-serif; font-size:10px; }
div.pre { font-family:monospace; font-size:12px; white-space:pre; }
div.diff_info { font-family:monospace; color:#000099; background-color:#edece6; font-style:italic; }
div.index_include { border:solid #d9d8d1; border-width:0px 0px 1px; padding:12px 8px; }
git_header_html($status);
print "<div class=\"page_body\">\n" .
- "<br/><br/>\n";
- print "$status - $error\n";
- print "<br/></div>\n";
+ "<br/><br/>\n" .
+ "$status - $error\n" .
+ "<br/>\n" .
+ "</div>\n";
git_footer_html();
exit;
}
chomp $line;
if ($line =~ m/^object ([0-9a-fA-F]{40})$/) {
$tag{'object'} = $1;
- } elsif ($line =~ m/^type (.*)$/) {
+ } elsif ($line =~ m/^type (.+)$/) {
$tag{'type'} = $1;
- } elsif ($line =~ m/^tag (.*)$/) {
+ } elsif ($line =~ m/^tag (.+)$/) {
$tag{'name'} = $1;
}
}
while (my $line = <$fd>) {
last if $line eq "\n";
chomp $line;
- if ($line =~ m/^tree (.*)$/) {
+ if ($line =~ m/^tree ([0-9a-fA-F]{40})$/) {
$co{'tree'} = $1;
- } elsif ($line =~ m/^parent (.*)$/) {
+ } elsif ($line =~ m/^parent ([0-9a-fA-F]{40})$/) {
push @parents, $1;
} elsif ($line =~ m/^author (.*) ([0-9]+) (.*)$/) {
$co{'author'} = $1;
$co{'author_epoch'} = $2;
$co{'author_tz'} = $3;
- $co{'author_name'} = $co{'author'};
- $co{'author_name'} =~ s/ <.*//;
+ if ($co{'author'} =~ m/^([^<]+) </) {
+ $co{'author_name'} = $1;
+ } else {
+ $co{'author_name'} = $co{'author'};
+ }
} elsif ($line =~ m/^committer (.*) ([0-9]+) (.*)$/) {
$co{'committer'} = $1;
$co{'committer_epoch'} = $2;
$co{'parent'} = $parents[0];
my (@comment) = map { chomp; $_ } <$fd>;
$co{'comment'} = \@comment;
- $comment[0] =~ m/^(.{0,60}[^ ]*)/;
- $co{'title'} = $1;
- if ($comment[0] ne $co{'title'}) {
- $co{'title'} .= " ...";
- }
+ $co{'title'} = chop_str($comment[0], 50);
close $fd || return;
my $age = time - $co{'committer_epoch'};
}
}
+sub chop_str {
+ my $str = shift;
+ my $len = shift;
+
+ $str =~ m/^(.{0,$len}[^ \/\-_:\.@]{0,10})/;
+ my $chopped = $1;
+ if ($chopped ne $str) {
+ $chopped .= " ...";
+ }
+ return $chopped;
+}
+
sub file_type {
my $mode = oct shift;
}
closedir($dh);
} elsif (-f $projects_list) {
- # read from file:
- # 'git/git.git:Linus Torvalds'
- # 'linux/hotplug/udev.git'
+ # read from file(url-encoded):
+ # 'git%2Fgit.git Linus+Torvalds'
+ # 'libs%2Fklibc%2Fklibc.git H.+Peter+Anvin'
+ # 'linux%2Fhotplug%2Fudev.git Greg+Kroah-Hartman'
open my $fd , $projects_list || return undef;
while (my $line = <$fd>) {
chomp $line;
close $fd;
print "</div>\n";
}
- print "<div class=\"page_body\"><br/>\n" .
- "<table cellspacing=\"0\">\n" .
+ print "<table cellspacing=\"0\">\n" .
"<tr>\n" .
"<th>Project</th>\n" .
"<th>Description</th>\n" .
"<th>last change</th>\n" .
"<th></th>\n" .
"</tr>\n";
+ my $alternate = 0;
foreach my $pr (@list) {
my %proj = %$pr;
my $head = git_read_hash("$proj{'path'}/HEAD");
next;
}
my $descr = git_read_description($proj{'path'}) || "";
+ $descr = chop_str($descr, 30);
# get directory owner if not already specified
if (!defined $proj{'owner'}) {
$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" .
+ if ($alternate) {
+ print "<tr style=\"background-color:#f6f5ed\">\n";
+ } else {
+ print "<tr>\n";
+ }
+ $alternate ^= 1;
+ print "<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";
+ "<td><i>" . chop_str($proj{'owner'}, 20) . "</i></td>\n";
my $colored_age;
if ($co{'age'} < 60*60*2) {
$colored_age = "<span style =\"color: #009900;\"><b><i>$co{'age_string'}</i></b></span>";
"<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";
}
- print "</table>\n" .
- "<br/>\n" .
- "</div>\n";
+ print "</table>\n";
git_footer_html();
}
sub git_read_refs {
my $ref_dir = shift;
- my @taglist;
+ my @reflist;
opendir my $dh, "$projectroot/$project/$ref_dir";
- my @tags = grep !m/^\./, readdir $dh;
+ my @refs = grep !m/^\./, readdir $dh;
closedir($dh);
- foreach my $tag_file (@tags) {
- my $tag_id = git_read_hash("$project/$ref_dir/$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{'title'} = $co{'title'};
- $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 {
"<br/><br/>\n" .
"</div>\n";
print "<div class=\"title\">project</div>\n";
- print "<div class=\"page_body\">\n" .
- "<table cellspacing=\"0\">\n" .
+ print "<table cellspacing=\"0\">\n" .
"<tr><td>description</td><td>" . escapeHTML($descr) . "</td></tr>\n" .
"<tr><td>owner</td><td>$owner</td></tr>\n" .
"<tr><td>last change</td><td>$cd{'rfc2822'}</td></tr>\n" .
- "</table>\n" .
- "<br/></div>\n";
- open my $fd, "-|", "$gitbin/git-rev-list --max-count=11 " . git_read_hash("$project/HEAD") || die_error(undef, "Open failed.");
+ "</table>\n";
+ open my $fd, "-|", "$gitbin/git-rev-list --max-count=16 " . git_read_hash("$project/HEAD") || die_error(undef, "Open failed.");
my (@revlist) = map { chomp; $_ } <$fd>;
close $fd;
print "<div>\n" .
$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";
+ my $i = 15;
+ print "<table cellspacing=\"0\">\n";
+ my $alternate = 0;
foreach my $commit (@revlist) {
my %co = git_read_commit($commit);
my %ad = date_str($co{'author_epoch'});
- print "<tr>\n";
+ if ($alternate) {
+ print "<tr style=\"background-color:#f6f5ed\">\n";
+ } else {
+ print "<tr>\n";
+ }
+ $alternate ^= 1;
if (--$i > 0) {
- print "<td>$co{'age_string'}</td>\n" .
- "<td>$co{'author_name'}</td>\n" .
- "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, escapeHTML($co{'title'})) . "</td>\n" .
+ print "<td><i>$co{'age_string'}</i></td>\n" .
+ "<td><i>" . escapeHTML(chop_str($co{'author_name'}, 10)) . "</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" .
last;
}
}
- print "</table\n>" .
- "</div>\n";
+ print "</table\n>";
my $taglist = git_read_refs("refs/tags");
if (defined @$taglist) {
print "<div>\n" .
$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";
+ my $i = 15;
+ print "<table cellspacing=\"0\">\n";
+ my $alternate = 0;
foreach my $entry (@$taglist) {
my %tag = %$entry;
- print "<tr>\n";
+ if ($alternate) {
+ print "<tr style=\"background-color:#f6f5ed\">\n";
+ } else {
+ print "<tr>\n";
+ }
+ $alternate ^= 1;
if (--$i > 0) {
- print "<td>$tag{'age'}</td>\n" .
- "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'id'}"}, escapeHTML($tag{'name'})) . "</td>\n" .
+ 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" .
last;
}
}
- print "</table\n>" .
- "</div>\n";
+ print "</table\n>";
}
my $branchlist = git_read_refs("refs/heads");
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";
+ my $i = 15;
+ print "<table cellspacing=\"0\">\n";
+ my $alternate = 0;
foreach my $entry (@$branchlist) {
my %tag = %$entry;
- print "<tr>\n";
+ if ($alternate) {
+ print "<tr style=\"background-color:#f6f5ed\">\n";
+ } else {
+ print "<tr>\n";
+ }
+ $alternate ^= 1;
if (--$i > 0) {
- print "<td>$tag{'age'}</td>\n" .
- "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}"}, escapeHTML($tag{'name'})) . "</td>\n" .
+ 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" .
last;
}
}
- print "</table\n>" .
- "</div>\n";
+ print "</table\n>";
}
git_footer_html();
}
print "<div>\n" .
$cgi->a({-href => "$my_uri?p=$project;a=summary", -class => "title"}, "tags") .
"</div>\n";
+ print "<table cellspacing=\"0\">\n";
+ my $alternate = 0;
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=\"age\">$tag{'age'}</span>" . escapeHTML($tag{'name'})) . "\n" .
- "</div>\n";
+ if ($alternate) {
+ print "<tr style=\"background-color:#f6f5ed\">\n";
+ } else {
+ print "<tr>\n";
+ }
+ $alternate ^= 1;
+ 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=$tag{'type'};h=$tag{'id'}"}, $tag{'type'}) . "</td>\n" .
+ "</tr>";
}
}
- print "<div class=\"list\"><br/></div>\n";
+ print "</table\n>";
git_footer_html();
}
print "<div>\n" .
$cgi->a({-href => "$my_uri?p=$project;a=summary", -class => "title"}, "branches") .
"</div>\n";
+ print "<table cellspacing=\"0\">\n";
+ my $alternate = 0;
if (defined @$taglist) {
foreach my $entry (@$taglist) {
my %tag = %$entry;
- print "<div class=\"list\">\n" .
- $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}"},
- "<span class=\"age\">$tag{'age'}</span>" . escapeHTML($tag{'name'})) . "\n" .
- "</div>\n";
+ if ($alternate) {
+ print "<tr style=\"background-color:#f6f5ed\">\n";
+ } else {
+ print "<tr>\n";
+ }
+ $alternate ^= 1;
+ 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>";
}
}
- print "<div class=\"list\"><br/></div>\n";
+ print "</table\n>";
git_footer_html();
}
close $fd || return undef;
foreach my $line (@entries) {
#'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c'
- $line =~ m/^([0-9]+)\t(.*)\t(.*)\t(.*)$/;
+ $line =~ m/^([0-9]+)\t(.+)\t([0-9a-fA-F]{40})\t(.+)$/;
my $t_mode = $1;
my $t_type = $2;
my $t_hash = $3;
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");
+ 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>;
}
print "<div class=\"page_body\">\n";
print "<table cellspacing=\"0\">\n";
+ my $alternate = 0;
foreach my $line (@entries) {
#'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c'
- $line =~ m/^([0-9]+)\t(.*)\t(.*)\t(.*)$/;
+ $line =~ m/^([0-9]+)\t(.+)\t([0-9a-fA-F]{40})\t(.+)$/;
my $t_mode = $1;
my $t_type = $2;
my $t_hash = $3;
my $t_name = $4;
$file_key = ";f=$base$t_name";
- print "<tr>\n" .
- "<td class=\"pre\">" . mode_str($t_mode) . "</td>\n";
+ if ($alternate) {
+ print "<tr style=\"background-color:#f6f5ed\">\n";
+ } else {
+ print "<tr>\n";
+ }
+ $alternate ^= 1;
+ print "<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";
+ print "<td class=\"link\">" .
+ $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash_base" . $file_key}, "history") .
+ "</td>\n";
}
print "</tr>\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 "") {
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 {
printf(" (%02d:%02d %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
}
- print "</td></tr>\n";
+ 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>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", class => "list"}, $co{'tree'}) . "</td>" .
+ "<td class=\"link\">" . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, "tree") .
+ "</td>" .
+ "</tr>\n";
my $parents = $co{'parents'};
foreach my $par (@$parents) {
- 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 "<tr>" .
+ "<td>parent</td>" .
+ "<td style=\"font-family:monospace\">" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$par", class => "list"}, $par) . "</td>" .
+ "<td class=\"link\">" .
+ $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$par"}, "commit") .
+ " |" . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash;hp=$par"}, "commitdiff") .
+ "</td>" .
+ "</tr>\n";
}
print "</table>".
"</div>\n";
} 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 {
print(($#difftree + 1) . " files changed:\n");
}
print "</div>\n";
+ print "<table cellspacing=\"0\">\n";
+ my $alternate = 0;
foreach my $line (@difftree) {
# '*100644->100644 blob 9f91a116d91926df3ba936a80f020a6ab1084d2b->bb90a0c3a91eb52020d0db0e8b4f94d30e02d596 net/ipv4/route.c'
# '+100644 blob 4a83ab6cd565d21ab0385bac6643826b83c2fcd4 arch/arm/lib/bitops.h'
# '*100664->100644 blob b1a8e3dd5556b61dd771d32307c6ee5d7150fa43->b1a8e3dd5556b61dd771d32307c6ee5d7150fa43 show-files.c'
# '*100664->100644 blob d08e895238bac36d8220586fdc28c27e1a7a76d3->d08e895238bac36d8220586fdc28c27e1a7a76d3 update-cache.c'
- $line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/;
+ $line =~ m/^(.)(.+)\t(.+)\t([0-9a-fA-F]{40}|[0-9a-fA-F]{40}->[0-9a-fA-F]{40})\t(.+)$/;
my $op = $1;
my $mode = $2;
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;
+ }
+ if ($alternate) {
+ print "<tr style=\"background-color:#f6f5ed\">\n";
+ } else {
+ print "<tr>\n";
+ }
+ $alternate ^= 1;
+ 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>\n";
git_footer_html();
}
if (!%co) {
die_error(undef, "Unknown commit object.");
}
- open my $fd, "-|", "$gitbin/git-diff-tree -r $co{'parent'} $hash" || die_error(undef, "Open failed.");
+ if (!defined $hash_parent) {
+ $hash_parent = $co{'parent'};
+ }
+ open my $fd, "-|", "$gitbin/git-diff-tree -r $hash_parent $hash" || die_error(undef, "Open failed.");
my (@difftree) = map { chomp; $_ } <$fd>;
close $fd || die_error(undef, "Reading diff-tree failed.");
my $comment = $co{'comment'};
my $empty = 0;
my $signed = 0;
- foreach my $line (@$comment) {
- if ($line =~ m/^(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
+ 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 "") {
print "<br/>\n";
foreach my $line (@difftree) {
# '*100644->100644 blob 8e5f9bbdf4de94a1bc4b4da8cb06677ce0a57716->8da3a306d0c0c070d87048d14a033df02f40a154 Makefile'
- $line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/;
+ $line =~ m/^(.)(.+)\t(.+)\t([0-9a-fA-F]{40}|[0-9a-fA-F]{40}->[0-9a-fA-F]{40})\t(.+)$/;
my $op = $1;
my $mode = $2;
my $type = $3;
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 "<table cellspacing=\"0\">\n";
+ my $alternate = 0;
while (my $line = <$fd>) {
if ($line =~ m/^([0-9a-fA-F]{40}) /){
$commit = $1;
next;
}
- if ($line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/ && (defined $commit)) {
- my $type = $3;
- my $file = $5;
- if ($file ne $file_name || $type ne "blob") {
- next;
- }
+ if ($line =~ m/^(.)(.+)\t(.+)\t([0-9a-fA-F]{40}->[0-9a-fA-F]{40})\t(.+)$/ && (defined $commit)) {
my %co = git_read_commit($commit);
if (!%co) {
next;
}
- print "<div class=\"list\">\n" .
- $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"},
- "<span class=\"age\">$co{'age_string'}</span>" . escapeHTML($co{'title'})) . "\n" .
- "</div>\n";
- print "<div class=\"list_link\">\n" .
+ if ($alternate) {
+ print "<tr style=\"background-color:#f6f5ed\">\n";
+ } else {
+ print "<tr>\n";
+ }
+ $alternate ^= 1;
+ print "<td><i>$co{'age_string'}</i></td>\n" .
+ "<td><i>" . escapeHTML(chop_str($co{'author_name'}, 10)) . "</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_name"}, "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_name"}, "diff");
}
- print "<br/>\n" .
- "</div>\n";
+ print "</td>\n" .
+ "</tr>\n";
undef $commit;
}
}
+ print "</table>\n";
close $fd;
git_footer_html();
}