use Fcntl ':mode';
my $cgi = new CGI;
-my $version = "220";
+my $version = "229";
my $my_url = $cgi->url();
my $my_uri = $cgi->url(-absolute => 1);
my $rss_link = "";
git_opml();
exit;
}
-} else {
- $action = "summary";
}
my $project = $cgi->param('p');
die_error(undef, "No such project.");
}
$rss_link = "<link rel=\"alternate\" title=\"$project log\" href=\"$my_uri?p=$project;a=rss\" type=\"application/rss+xml\"/>";
- $ENV{'GIT_OBJECT_DIRECTORY'} = "$projectroot/$project/objects";
+ $ENV{'GIT_DIR'} = "$projectroot/$project";
} else {
git_project_list();
exit;
}
my $hash = $cgi->param('h');
-if (defined $hash && !($hash =~ m/^[0-9a-fA-F]{40}$/)) {
- undef $hash;
- die_error(undef, "Invalid hash parameter.");
+if (defined $hash) {
+ if (!($hash =~ m/^[0-9a-fA-F]{40}$/)) {
+ if ($hash =~ m/(^|\/)(|\.|\.\.)($|\/)/) {
+ undef $hash;
+ die_error(undef, "Non-canonical hash parameter.");
+ }
+ if ($hash =~ m/[^a-zA-Z0-9_\.\/\-\+\#\~\:\!]/) {
+ undef $hash;
+ die_error(undef, "Invalid character in hash parameter.");
+ }
+ # replace branch-name with hash
+ my $branchlist = git_read_refs("refs/heads");
+ foreach my $entry (@$branchlist) {
+ my %branch = %$entry;
+ if ($branch{'name'} eq $hash) {
+ $hash = $branch{'id'};
+ last;
+ }
+ }
+ }
}
my $hash_parent = $cgi->param('hp');
}
}
-
my $searchtext = $cgi->param('s');
if (defined $searchtext) {
if ($searchtext =~ m/[^a-zA-Z0-9_\.\/\-\+\:\@ ]/) {
$searchtext = quotemeta $searchtext;
}
-if ($action eq "summary") {
+if (!defined $action || $action eq "summary") {
git_summary();
exit;
} elsif ($action eq "branches") {
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; }
div.search { margin:4px 8px; position:absolute; top:56px; right:12px }
+a.linenr { color:#999999; text-decoration:none }
a.rss_logo {
float:right; padding:3px 0px; width:35px; line-height:10px;
border:1px solid; border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e;
} else {
$co{'age_string'} .= " right now";
}
+ my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($co{'committer_epoch'});
+ if ($age > 60*60*24*7*2) {
+ $co{'age_string_date'} = sprintf "%4i-%02u-%02i", 1900 + $year, $mon, $mday;
+ $co{'age_string_age'} = $co{'age_string'};
+ } else {
+ $co{'age_string_date'} = $co{'age_string'};
+ $co{'age_string_age'} = sprintf "%4i-%02u-%02i", 1900 + $year, $mon, $mday;
+ }
return %co;
}
if (!defined $head) {
next;
}
- $ENV{'GIT_OBJECT_DIRECTORY'} = "$projectroot/$proj{'path'}/objects";
+ $ENV{'GIT_DIR'} = "$projectroot/$proj{'path'}";
my %co = git_read_commit($head);
if (!%co) {
next;
my $ref_dir = shift;
my @reflist;
+ my @refs;
opendir my $dh, "$projectroot/$project/$ref_dir";
- my @refs = grep !m/^\./, readdir $dh;
+ while (my $dir = readdir($dh)) {
+ if ($dir =~ m/^\./) {
+ next;
+ }
+ if (-d "$projectroot/$project/$ref_dir/$dir") {
+ opendir my $dh2, "$projectroot/$project/$ref_dir/$dir";
+ my @subdirs = grep !m/^\./, readdir $dh2;
+ closedir($dh2);
+ foreach my $subdir (@subdirs) {
+ push @refs, "$dir/$subdir"
+ }
+ next;
+ }
+ push @refs, $dir;
+ }
closedir($dh);
foreach my $ref_file (@refs) {
my $ref_id = git_read_hash("$project/$ref_dir/$ref_file");
if ($i-- > 0) {
print "<td><i>$tag{'age'}</i></td>\n" .
"<td>" .
- $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'id'}", -class => "list"},
+ $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'name'}", -class => "list"},
"<b>" . escapeHTML($tag{'name'}) . "</b>") .
"</td>\n" .
"<td class=\"link\">" .
- $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'id'}"}, "shortlog") .
- " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}"}, "log") .
+ $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'name'}"}, "shortlog") .
+ " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'name'}"}, "log") .
"</td>\n" .
"</tr>";
} else {
$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"},
+ $cgi->a({-href => "$my_uri?p=$project;a=shortlog;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'});
if ($tag{'type'} eq "commit") {
- print " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'id'}"}, "shortlog") .
+ print " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'name'}"}, "shortlog") .
" | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}"}, "log");
}
print "</td>\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>") .
+ $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'name'}", -class => "list"}, "<b>" . escapeHTML($tag{'name'}) . "</b>") .
"</td>\n" .
"<td class=\"link\">" .
- $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'id'}"}, "shortog") .
- " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}"}, "log") .
+ $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'name'}"}, "shortlog") .
+ " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'name'}"}, "log") .
"</td>\n" .
"</tr>";
}
$line =~ s/\t/$spaces/;
}
}
- printf "<div class=\"pre\"><span style=\"color:#999999;\">%4i</span> %s</div>\n", $nr, escapeHTML($line);
+ printf "<div class=\"pre\"><a id=\"l%i\" href=\"#l%i\" class=\"linenr\">%4i</a> %s</div>\n", $nr, $nr, $nr, escapeHTML($line);
}
close $fd or print "Reading blob failed.\n";
print "</div>";
"<rss version=\"2.0\" xmlns:content=\"http://purl.org/rss/1.0/modules/content/\">\n";
print "<channel>\n";
print "<title>$project</title>\n".
- "<link>" . escapeHTML("$my_url/$project/log") . "</link>\n".
+ "<link>" . escapeHTML("$my_url?p=$project;a=summary") . "</link>\n".
"<description>$project log</description>\n".
"<language>en</language>\n";
if (!defined $head) {
next;
}
- $ENV{'GIT_OBJECT_DIRECTORY'} = "$projectroot/$proj{'path'}/objects";
+ $ENV{'GIT_DIR'} = "$projectroot/$proj{'path'}";
my %co = git_read_commit($head);
if (!%co) {
next;
my $path = escapeHTML(chop_str($proj{'path'}, 25, 5));
my $rss = "$my_url?p=$proj{'path'};a=rss";
- my $html = "$my_url?p=$proj{'path'};a=log";
+ my $html = "$my_url?p=$proj{'path'};a=summary";
print "<outline type=\"rss\" text=\"$path\" title=\"$path\" xmlUrl=\"$rss\" htmlUrl=\"$html\"/>\n";
}
print "</outline>\n".
print "<table cellspacing=\"0\">\n";
my $alternate = 0;
while (my $line = <$fd>) {
- if ($line =~ m/^([0-9a-fA-F]{40}) /){
+ if ($line =~ m/^([0-9a-fA-F]{40})/){
$commit = $1;
next;
}
print "<tr class=\"light\">\n";
}
$alternate ^= 1;
- print "<td><i>$co{'age_string'}</i></td>\n" .
+ print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
"<td><i>" . escapeHTML(chop_str($co{'author_name'}, 15, 3)) . "</i></td>\n" .
"<td>" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list"}, "<b>" .
escapeHTML(chop_str($co{'title'}, 50)) . "</b>") . "</td>\n" .
print "<tr class=\"light\">\n";
}
$alternate ^= 1;
- print "<td><i>$co{'age_string'}</i></td>\n" .
+ print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
"<td><i>" . escapeHTML(chop_str($co{'author_name'}, 15, 5)) . "</i></td>\n" .
"<td>" .
$cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list"}, "<b>" . escapeHTML(chop_str($co{'title'}, 50)) . "</b><br/>");
print "<tr class=\"light\">\n";
}
$alternate ^= 1;
- print "<td><i>$co{'age_string'}</i></td>\n" .
+ print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
"<td><i>" . escapeHTML(chop_str($co{'author_name'}, 15, 5)) . "</i></td>\n" .
"<td>" .
$cgi->a({-href => "$my_uri?p=$project;a=commit;h=$co{'id'}", -class => "list"}, "<b>" .
print "<tr class=\"light\">\n";
}
$alternate ^= 1;
- print "<td><i>$co{'age_string'}</i></td>\n" .
+ print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</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_short'}) . "</b>") . "</td>\n" .