3 # gitweb - simple web interface to track changes in git repositories
5 # (C) 2005, Kay Sievers <kay.sievers@vrfy.org>
6 # (C) 2005, Christian Gierke <ch@gierke.de>
8 # This program is licensed under the GPL v2, or a later version
12 use CGI qw(:standard :escapeHTML -nosticky);
13 use CGI::Util qw(unescape);
14 use CGI::Carp qw(fatalsToBrowser);
19 my $my_url = $cgi->url();
20 my $my_uri = $cgi->url(-absolute => 1);
23 # absolute fs-path which will be prepended to the project path
24 my $projectroot = "/pub/scm";
26 # location of the git-core binaries
27 my $gitbin = "/usr/bin";
29 # location for temporary files needed for diffs
30 my $git_temp = "/tmp/gitweb";
32 # target of the home link on top of all pages
33 my $home_link = $my_uri;
35 # html text to include at home page
36 my $home_text = "indextext.html";
38 # source of projects list
39 #my $projects_list = $projectroot;
40 my $projects_list = "index/index.aux";
42 # input validation and dispatch
43 my $action = $cgi->param('a');
44 if (defined $action) {
45 if ($action =~ m/[^0-9a-zA-Z\.\-_]+/) {
47 die_error(undef, "Invalid action parameter.");
49 if ($action eq "git-logo.png") {
52 } elsif ($action eq "opml") {
58 my $project = $cgi->param('p');
59 if (defined $project) {
60 if ($project =~ m/(^|\/)(|\.|\.\.)($|\/)/) {
62 die_error(undef, "Non-canonical project parameter.");
64 if ($project =~ m/[^a-zA-Z0-9_\.\/\-\+\#\~]/) {
66 die_error(undef, "Invalid character in project parameter.");
68 if (!(-d "$projectroot/$project")) {
70 die_error(undef, "No such directory.");
72 if (!(-e "$projectroot/$project/HEAD")) {
74 die_error(undef, "No such project.");
76 $rss_link = "<link rel=\"alternate\" title=\"$project log\" href=\"$my_uri?p=$project;a=rss\" type=\"application/rss+xml\"/>";
77 $ENV{'GIT_DIR'} = "$projectroot/$project";
83 my $file_name = $cgi->param('f');
84 if (defined $file_name) {
85 if ($file_name =~ m/(^|\/)(|\.|\.\.)($|\/)/) {
87 die_error(undef, "Non-canonical file parameter.");
89 if ($file_name =~ m/[^a-zA-Z0-9_\.\/\-\+\#\~\:\!]/) {
91 die_error(undef, "Invalid character in file parameter.");
95 my $hash = $cgi->param('h');
97 if (!($hash =~ m/^[0-9a-fA-F]{40}$/)) {
98 if ($hash =~ m/(^|\/)(|\.|\.\.)($|\/)/) {
100 die_error(undef, "Non-canonical hash parameter.");
102 if ($hash =~ m/[^a-zA-Z0-9_\.\/\-\+\#\~\:\!]/) {
104 die_error(undef, "Invalid character in hash parameter.");
106 # replace branch-name with hash
107 my $branchlist = git_read_refs("refs/heads");
108 foreach my $entry (@$branchlist) {
109 my %branch = %$entry;
110 if ($branch{'name'} eq $hash) {
111 $hash = $branch{'id'};
118 my $hash_parent = $cgi->param('hp');
119 if (defined $hash_parent && !($hash_parent =~ m/^[0-9a-fA-F]{40}$/)) {
121 die_error(undef, "Invalid hash_parent parameter.");
124 my $hash_base = $cgi->param('hb');
125 if (defined $hash_base && !($hash_base =~ m/^[0-9a-fA-F]{40}$/)) {
127 die_error(undef, "Invalid parent hash parameter.");
130 my $page = $cgi->param('pg');
132 if ($page =~ m/^[^0-9]+$/) {
134 die_error(undef, "Invalid page parameter.");
138 my $searchtext = $cgi->param('s');
139 if (defined $searchtext) {
140 if ($searchtext =~ m/[^a-zA-Z0-9_\.\/\-\+\:\@ ]/) {
142 die_error(undef, "Invalid search parameter.");
144 $searchtext = quotemeta $searchtext;
147 if (!defined $action || $action eq "summary") {
150 } elsif ($action eq "branches") {
153 } elsif ($action eq "tags") {
156 } elsif ($action eq "blob") {
159 } elsif ($action eq "blob_plain") {
162 } elsif ($action eq "tree") {
165 } elsif ($action eq "rss") {
168 } elsif ($action eq "commit") {
171 } elsif ($action eq "log") {
174 } elsif ($action eq "blobdiff") {
177 } elsif ($action eq "blobdiff_plain") {
178 git_blobdiff_plain();
180 } elsif ($action eq "commitdiff") {
183 } elsif ($action eq "commitdiff_plain") {
184 git_commitdiff_plain();
186 } elsif ($action eq "history") {
189 } elsif ($action eq "search") {
192 } elsif ($action eq "shortlog") {
195 } elsif ($action eq "tag") {
200 die_error(undef, "Unknown action.");
204 sub git_header_html {
205 my $status = shift || "200 OK";
208 if (defined $project) {
209 $title .= " - $project";
210 if (defined $action) {
211 $title .= "/$action";
214 print $cgi->header(-type=>'text/html', -charset => 'utf-8', -status=> $status);
216 <?xml version="1.0" encoding="utf-8"?>
217 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
218 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
219 <!-- git web interface v$version, (C) 2005, Kay Sievers <kay.sievers\@vrfy.org>, Christian Gierke <ch\@gierke.de> -->
221 <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
222 <meta name="robots" content="index, nofollow"/>
223 <title>$title</title>
225 <style type="text/css">
226 body { font-family: sans-serif; font-size: 12px; margin:0px; border:solid #d9d8d1; border-width:1px; margin:10px; }
228 a:hover, a:visited, a:active { color:#880000; }
229 div.page_header { height:25px; padding:8px; font-size:18px; font-weight:bold; background-color:#d9d8d1; }
230 div.page_header a:visited { color:#0000cc; }
231 div.page_header a:hover { color:#880000; }
232 div.page_nav { padding:8px; }
233 div.page_nav a:visited { color:#0000cc; }
234 div.page_path { padding:8px; border:solid #d9d8d1; border-width:0px 0px 1px}
235 div.page_footer { height:17px; padding:4px 8px; background-color: #d9d8d1; }
236 div.page_footer_text { float:left; color:#555555; font-style:italic; }
237 div.page_body { padding:8px; }
239 display:block; padding:6px 8px;
240 font-weight:bold; background-color:#edece6; text-decoration:none; color:#000000;
242 a.title:hover { background-color: #d9d8d1; }
243 div.title_text { padding:6px 0px; border: solid #d9d8d1; border-width:0px 0px 1px; }
244 div.log_body { padding:8px 8px 8px 150px; }
245 span.age { position:relative; float:left; width:142px; font-style:italic; }
248 font-size:10px; font-family:sans-serif; font-style:normal;
249 position:relative; float:left; width:136px;
251 div.list_head { padding:6px 8px 4px; border:solid #d9d8d1; border-width:1px 0px 0px; font-style:italic; }
252 a.list { text-decoration:none; color:#000000; }
253 a.list:hover { text-decoration:underline; color:#880000; }
254 a.text { text-decoration:none; color:#0000cc; }
255 a.text:visited { text-decoration:none; color:#880000; }
256 a.text:hover { text-decoration:underline; color:#880000; }
257 table { padding:8px 4px; }
258 th { padding:2px 5px; font-size:12px; text-align:left; }
259 tr.light:hover { background-color:#edece6; }
260 tr.dark { background-color:#f6f6f0; }
261 tr.dark:hover { background-color:#edece6; }
262 td { padding:2px 5px; font-size:12px; vertical-align:top; }
263 td.link { padding:2px 5px; font-family:sans-serif; font-size:10px; }
264 div.pre { font-family:monospace; font-size:12px; white-space:pre; }
265 div.diff_info { font-family:monospace; color:#000099; background-color:#edece6; font-style:italic; }
266 div.index_include { border:solid #d9d8d1; border-width:0px 0px 1px; padding:12px 8px; }
267 div.search { margin:4px 8px; position:absolute; top:56px; right:12px }
268 a.linenr { color:#999999; text-decoration:none }
270 float:right; padding:3px 0px; width:35px; line-height:10px;
271 border:1px solid; border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e;
272 color:#ffffff; background-color:#ff6600;
273 font-weight:bold; font-family:sans-serif; font-size:10px;
274 text-align:center; text-decoration:none;
276 a.rss_logo:hover { background-color:#ee5500; }
281 print "<div class=\"page_header\">\n" .
282 "<a href=\"http://www.kernel.org/pub/software/scm/git/docs/\" title=\"git documentation\">" .
283 "<img src=\"$my_uri?a=git-logo.png\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/>" .
285 print $cgi->a({-href => $home_link}, "projects") . " / ";
286 if (defined $project) {
287 print $cgi->a({-href => "$my_uri?p=$project;a=summary"}, escapeHTML($project));
288 if (defined $action) {
292 if (!defined $searchtext) {
295 $cgi->param("a", "search");
296 print $cgi->startform(-method => "get", -action => "$my_uri") .
297 "<div class=\"search\">\n" .
298 $cgi->hidden(-name => "p") . "\n" .
299 $cgi->hidden(-name => "a") . "\n" .
300 $cgi->textfield(-name => "s", -value => $searchtext) . "\n" .
302 $cgi->end_form() . "\n";
307 sub git_footer_html {
308 print "<div class=\"page_footer\">\n";
309 if (defined $project) {
310 my $descr = git_read_description($project);
311 if (defined $descr) {
312 print "<div class=\"page_footer_text\">" . escapeHTML($descr) . "</div>\n";
314 print $cgi->a({-href => "$my_uri?p=$project;a=rss", -class => "rss_logo"}, "RSS") . "\n";
316 print $cgi->a({-href => "$my_uri?a=opml", -class => "rss_logo"}, "RSS") . "\n";
324 my $status = shift || "403 Forbidden";
325 my $error = shift || "Malformed query, file missing or permission denied";
327 git_header_html($status);
328 print "<div class=\"page_body\">\n" .
330 "$status - $error\n" .
340 open my $fd, "-|", "$gitbin/git-cat-file -t $hash" or return;
350 open my $fd, "$projectroot/$path" or return undef;
354 if ($head =~ m/^[0-9a-fA-F]{40}$/) {
359 sub git_read_description {
362 open my $fd, "$projectroot/$path/description" or return undef;
374 open my $fd, "-|", "$gitbin/git-cat-file tag $tag_id" or return;
375 $tag{'id'} = $tag_id;
376 while (my $line = <$fd>) {
378 if ($line =~ m/^object ([0-9a-fA-F]{40})$/) {
380 } elsif ($line =~ m/^type (.+)$/) {
382 } elsif ($line =~ m/^tag (.+)$/) {
384 } elsif ($line =~ m/^tagger (.*) ([0-9]+) (.*)$/) {
388 } elsif ($line =~ m/--BEGIN/) {
389 push @comment, $line;
391 } elsif ($line eq "") {
395 push @comment, <$fd>;
396 $tag{'comment'} = \@comment;
398 if (!defined $tag{'name'}) {
404 sub git_read_commit {
405 my $commit_id = shift;
406 my $commit_text = shift;
412 if (defined $commit_text) {
413 @commit_lines = @$commit_text;
415 open my $fd, "-|", "$gitbin/git-cat-file commit $commit_id" or return;
416 @commit_lines = map { chomp; $_ } <$fd>;
419 while (my $line = shift @commit_lines) {
420 last if $line eq "\n";
421 if ($line =~ m/^tree ([0-9a-fA-F]{40})$/) {
423 } elsif ($line =~ m/^parent ([0-9a-fA-F]{40})$/) {
425 } elsif ($line =~ m/^author (.*) ([0-9]+) (.*)$/) {
427 $co{'author_epoch'} = $2;
428 $co{'author_tz'} = $3;
429 if ($co{'author'} =~ m/^([^<]+) </) {
430 $co{'author_name'} = $1;
432 $co{'author_name'} = $co{'author'};
434 } elsif ($line =~ m/^committer (.*) ([0-9]+) (.*)$/) {
435 $co{'committer'} = $1;
436 $co{'committer_epoch'} = $2;
437 $co{'committer_tz'} = $3;
438 $co{'committer_name'} = $co{'committer'};
439 $co{'committer_name'} =~ s/ <.*//;
442 if (!defined $co{'tree'}) {
445 $co{'id'} = $commit_id;
446 $co{'parents'} = \@parents;
447 $co{'parent'} = $parents[0];
448 $co{'comment'} = \@commit_lines;
449 foreach my $title (@commit_lines) {
451 $co{'title'} = chop_str($title, 80);
452 # remove leading stuff of merges to make the interesting part visible
453 if (length($title) > 50) {
454 $title =~ s/^Automatic //;
455 $title =~ s/^merge (of|with) /Merge ... /i;
456 if (length($title) > 50) {
457 $title =~ s/(http|rsync):\/\///;
459 if (length($title) > 50) {
460 $title =~ s/(master|www|rsync)\.//;
462 if (length($title) > 50) {
463 $title =~ s/kernel.org:?//;
465 if (length($title) > 50) {
466 $title =~ s/\/pub\/scm//;
469 $co{'title_short'} = chop_str($title, 50);
474 my $age = time - $co{'committer_epoch'};
476 if ($age > 60*60*24*365*2) {
477 $co{'age_string'} = (int $age/60/60/24/365);
478 $co{'age_string'} .= " years ago";
479 } elsif ($age > 60*60*24*(365/12)*2) {
480 $co{'age_string'} = int $age/60/60/24/(365/12);
481 $co{'age_string'} .= " months ago";
482 } elsif ($age > 60*60*24*7*2) {
483 $co{'age_string'} = int $age/60/60/24/7;
484 $co{'age_string'} .= " weeks ago";
485 } elsif ($age > 60*60*24*2) {
486 $co{'age_string'} = int $age/60/60/24;
487 $co{'age_string'} .= " days ago";
488 } elsif ($age > 60*60*2) {
489 $co{'age_string'} = int $age/60/60;
490 $co{'age_string'} .= " hours ago";
491 } elsif ($age > 60*2) {
492 $co{'age_string'} = int $age/60;
493 $co{'age_string'} .= " min ago";
495 $co{'age_string'} = int $age;
496 $co{'age_string'} .= " sec ago";
498 $co{'age_string'} .= " right now";
500 my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($co{'committer_epoch'});
501 if ($age > 60*60*24*7*2) {
502 $co{'age_string_date'} = sprintf "%4i-%02u-%02i", 1900 + $year, $mon+1, $mday;
503 $co{'age_string_age'} = $co{'age_string'};
505 $co{'age_string_date'} = $co{'age_string'};
506 $co{'age_string_age'} = sprintf "%4i-%02u-%02i", 1900 + $year, $mon+1, $mday;
513 my $from_name = shift;
516 my $format = shift || "html";
518 my $from_tmp = "/dev/null";
519 my $to_tmp = "/dev/null";
522 # create tmp from-file
524 $from_tmp = "$git_temp/gitweb_" . $$ . "_from";
525 open my $fd2, "> $from_tmp";
526 open my $fd, "-|", "$gitbin/git-cat-file blob $from";
535 $to_tmp = "$git_temp/gitweb_" . $$ . "_to";
536 open my $fd2, "> $to_tmp";
537 open my $fd, "-|", "$gitbin/git-cat-file blob $to";
544 open my $fd, "-|", "/usr/bin/diff -u -p -L $from_name -L $to_name $from_tmp $to_tmp";
545 if ($format eq "plain") {
550 while (my $line = <$fd>) {
552 my $char = substr($line, 0, 1);
555 $color = " style=\"color:#008800;\"";
556 } elsif ($char eq "-") {
557 $color = " style=\"color:#cc0000;\"";
558 } elsif ($char eq "@") {
559 $color = " style=\"color:#990099;\"";
560 } elsif ($char eq "\\") {
564 while ((my $pos = index($line, "\t")) != -1) {
565 if (my $count = (8 - (($pos-1) % 8))) {
566 my $spaces = ' ' x $count;
567 $line =~ s/\t/$spaces/;
570 print "<div class=\"pre\"$color>" . escapeHTML($line) . "</div>\n";
584 my $mode = oct shift;
586 if (S_ISDIR($mode & S_IFMT)) {
588 } elsif (S_ISLNK($mode)) {
590 } elsif (S_ISREG($mode)) {
591 # git cares only about the executable bit
592 if ($mode & S_IXUSR) {
605 my $add_len = shift || 10;
607 $str =~ m/^(.{0,$len}[^ \/\-_:\.@]{0,$add_len})/;
609 if ($chopped ne $str) {
616 my $mode = oct shift;
618 if (S_ISDIR($mode & S_IFMT)) {
620 } elsif (S_ISLNK($mode)) {
622 } elsif (S_ISREG($mode)) {
629 sub format_log_line_html {
632 $line = escapeHTML($line);
633 $line =~ s/ / /g;
634 if ($line =~ m/([0-9a-fA-F]{40})/) {
636 if (git_get_type($hash_text) eq "commit") {
637 my $link = $cgi->a({-class => "text", -href => "$my_uri?p=$project;a=commit;h=$hash_text"}, $hash_text);
638 $line =~ s/$hash_text/$link/;
646 my $tz = shift || "-0000";
649 my @months = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
650 my @days = ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
651 my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($epoch);
652 $date{'hour'} = $hour;
653 $date{'minute'} = $min;
654 $date{'mday'} = $mday;
655 $date{'day'} = $days[$wday];
656 $date{'month'} = $months[$mon];
657 $date{'rfc2822'} = sprintf "%s, %d %s %4d %02d:%02d:%02d +0000", $days[$wday], $mday, $months[$mon], 1900+$year, $hour ,$min, $sec;
658 $date{'mday-time'} = sprintf "%d %s %02d:%02d", $mday, $months[$mon], $hour ,$min;
660 $tz =~ m/^([+\-][0-9][0-9])([0-9][0-9])$/;
661 my $local = $epoch + ((int $1 + ($2/60)) * 3600);
662 ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($local);
663 $date{'hour_local'} = $hour;
664 $date{'minute_local'} = $min;
665 $date{'tz_local'} = $tz;
669 # git-logo (cached in browser for one day)
671 print $cgi->header(-type => 'image/png', -expires => '+1d');
672 # cat git-logo.png | hexdump -e '16/1 " %02x" "\n"' | sed 's/ /\\x/g'
673 print "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52" .
674 "\x00\x00\x00\x48\x00\x00\x00\x1b\x04\x03\x00\x00\x00\x2d\xd9\xd4" .
675 "\x2d\x00\x00\x00\x18\x50\x4c\x54\x45\xff\xff\xff\x60\x60\x5d\xb0" .
676 "\xaf\xaa\x00\x80\x00\xce\xcd\xc7\xc0\x00\x00\xe8\xe8\xe6\xf7\xf7" .
677 "\xf6\x95\x0c\xa7\x47\x00\x00\x00\x73\x49\x44\x41\x54\x28\xcf\x63" .
678 "\x48\x67\x20\x04\x4a\x5c\x18\x0a\x08\x2a\x62\x53\x61\x20\x02\x08" .
679 "\x0d\x69\x45\xac\xa1\xa1\x01\x30\x0c\x93\x60\x36\x26\x52\x91\xb1" .
680 "\x01\x11\xd6\xe1\x55\x64\x6c\x6c\xcc\x6c\x6c\x0c\xa2\x0c\x70\x2a" .
681 "\x62\x06\x2a\xc1\x62\x1d\xb3\x01\x02\x53\xa4\x08\xe8\x00\x03\x18" .
682 "\x26\x56\x11\xd4\xe1\x20\x97\x1b\xe0\xb4\x0e\x35\x24\x71\x29\x82" .
683 "\x99\x30\xb8\x93\x0a\x11\xb9\x45\x88\xc1\x8d\xa0\xa2\x44\x21\x06" .
684 "\x27\x41\x82\x40\x85\xc1\x45\x89\x20\x70\x01\x00\xa4\x3d\x21\xc5" .
685 "\x12\x1c\x9a\xfe\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82";
691 my ($dev, $ino, $mode, $nlink, $st_uid, $st_gid, $rdev, $size) = stat($path);
692 my ($name, $passwd, $uid, $gid, $quota, $comment, $gcos, $dir, $shell) = getpwuid($st_uid);
693 if (!defined $gcos) {
697 $owner =~ s/[,;].*$//;
701 sub git_read_projects {
704 if (-d $projects_list) {
705 # search in directory
706 my $dir = $projects_list;
707 opendir my $dh, $dir or return undef;
708 while (my $dir = readdir($dh)) {
709 if (-e "$projectroot/$dir/HEAD") {
717 } elsif (-f $projects_list) {
718 # read from file(url-encoded):
719 # 'git%2Fgit.git Linus+Torvalds'
720 # 'libs%2Fklibc%2Fklibc.git H.+Peter+Anvin'
721 # 'linux%2Fhotplug%2Fudev.git Greg+Kroah-Hartman'
722 open my $fd , $projects_list or return undef;
723 while (my $line = <$fd>) {
725 my ($path, $owner) = split ' ', $line;
726 $path = unescape($path);
727 $owner = unescape($owner);
728 if (!defined $path) {
731 if (-e "$projectroot/$path/HEAD") {
741 @list = sort {$a->{'path'} cmp $b->{'path'}} @list;
745 sub git_project_list {
746 my @list = git_read_projects();
748 die_error(undef, "No project found.");
752 print "<div class=\"index_include\">\n";
753 open (my $fd, $home_text);
758 print "<table cellspacing=\"0\">\n" .
760 "<th>Project</th>\n" .
761 "<th>Description</th>\n" .
763 "<th>last change</th>\n" .
767 foreach my $pr (@list) {
769 my $head = git_read_hash("$proj{'path'}/HEAD");
770 if (!defined $head) {
773 $ENV{'GIT_DIR'} = "$projectroot/$proj{'path'}";
774 my %co = git_read_commit($head);
778 my $descr = git_read_description($proj{'path'}) || "";
779 $descr = chop_str($descr, 25, 5);
780 # get directory owner if not already specified
781 if (!defined $proj{'owner'}) {
782 $proj{'owner'} = get_file_owner("$projectroot/$proj{'path'}") || "";
785 print "<tr class=\"dark\">\n";
787 print "<tr class=\"light\">\n";
790 print "<td>" . $cgi->a({-href => "$my_uri?p=$proj{'path'};a=summary", -class => "list"}, escapeHTML($proj{'path'})) . "</td>\n" .
791 "<td>$descr</td>\n" .
792 "<td><i>" . chop_str($proj{'owner'}, 15) . "</i></td>\n";
794 if ($co{'age'} < 60*60*2) {
795 $colored_age = "<span style =\"color: #009900;\"><b><i>$co{'age_string'}</i></b></span>";
796 } elsif ($co{'age'} < 60*60*24*2) {
797 $colored_age = "<span style =\"color: #009900;\"><i>$co{'age_string'}</i></span>";
799 $colored_age = "<i>$co{'age_string'}</i>";
801 print "<td>$colored_age</td>\n" .
802 "<td class=\"link\">" .
803 $cgi->a({-href => "$my_uri?p=$proj{'path'};a=summary"}, "summary") .
804 " | " . $cgi->a({-href => "$my_uri?p=$proj{'path'};a=shortlog"}, "shortlog") .
805 " | " . $cgi->a({-href => "$my_uri?p=$proj{'path'};a=log"}, "log") .
818 opendir my $dh, "$projectroot/$project/$ref_dir";
819 while (my $dir = readdir($dh)) {
820 if ($dir =~ m/^\./) {
823 if (-d "$projectroot/$project/$ref_dir/$dir") {
824 opendir my $dh2, "$projectroot/$project/$ref_dir/$dir";
825 my @subdirs = grep !m/^\./, readdir $dh2;
827 foreach my $subdir (@subdirs) {
828 push @refs, "$dir/$subdir"
835 foreach my $ref_file (@refs) {
836 my $ref_id = git_read_hash("$project/$ref_dir/$ref_file");
837 my $type = git_get_type($ref_id) || next;
840 $ref_item{'type'} = $type;
841 $ref_item{'id'} = $ref_id;
842 if ($type eq "tag") {
843 my %tag = git_read_tag($ref_id);
844 $ref_item{'comment'} = $tag{'comment'};
845 if ($tag{'type'} eq "commit") {
846 %co = git_read_commit($tag{'object'});
848 $ref_item{'reftype'} = $tag{'type'};
849 $ref_item{'name'} = $tag{'name'};
850 $ref_item{'refid'} = $tag{'object'};
851 } elsif ($type eq "commit"){
852 %co = git_read_commit($ref_id);
853 $ref_item{'reftype'} = "commit";
854 $ref_item{'name'} = $ref_file;
855 $ref_item{'title'} = $co{'title'};
856 $ref_item{'refid'} = $ref_id;
858 $ref_item{'epoch'} = $co{'committer_epoch'} || 0;
859 $ref_item{'age'} = $co{'age_string'} || "unknown";
861 push @reflist, \%ref_item;
864 @reflist = sort {$b->{'epoch'} <=> $a->{'epoch'}} @reflist;
869 my $descr = git_read_description($project) || "none";
870 my $head = git_read_hash("$project/HEAD");
871 my %co = git_read_commit($head);
872 my %cd = date_str($co{'committer_epoch'}, $co{'committer_tz'});
875 if (-f $projects_list) {
876 open (my $fd , $projects_list);
877 while (my $line = <$fd>) {
879 my ($pr, $ow) = split ' ', $line;
882 if ($pr eq $project) {
889 if (!defined $owner) {
890 $owner = get_file_owner("$projectroot/$project");
894 print "<div class=\"page_nav\">\n" .
896 " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "shortlog") .
897 " | " . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") .
898 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$head"}, "commit") .
899 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$head"}, "commitdiff") .
900 " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree"}, "tree") .
903 print "<div class=\"title\"> </div>\n";
904 print "<table cellspacing=\"0\">\n" .
905 "<tr><td>description</td><td>" . escapeHTML($descr) . "</td></tr>\n" .
906 "<tr><td>owner</td><td>$owner</td></tr>\n" .
907 "<tr><td>last change</td><td>$cd{'rfc2822'}</td></tr>\n" .
909 open my $fd, "-|", "$gitbin/git-rev-list --max-count=17 " . git_read_hash("$project/HEAD") or die_error(undef, "Open failed.");
910 my (@revlist) = map { chomp; $_ } <$fd>;
913 $cgi->a({-href => "$my_uri?p=$project;a=shortlog", -class => "title"}, "shortlog") .
916 print "<table cellspacing=\"0\">\n";
918 foreach my $commit (@revlist) {
919 my %co = git_read_commit($commit);
920 my %ad = date_str($co{'author_epoch'});
922 print "<tr class=\"dark\">\n";
924 print "<tr class=\"light\">\n";
928 print "<td><i>$co{'age_string'}</i></td>\n" .
929 "<td><i>" . escapeHTML(chop_str($co{'author_name'}, 10)) . "</i></td>\n" .
931 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list"},
932 "<b>" . escapeHTML($co{'title_short'}) . "</b>") .
934 "<td class=\"link\">" .
935 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") .
936 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "commitdiff") .
940 print "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "...") . "</td>\n" .
947 my $taglist = git_read_refs("refs/tags");
948 if (defined @$taglist) {
950 $cgi->a({-href => "$my_uri?p=$project;a=tags", -class => "title"}, "tags") .
953 print "<table cellspacing=\"0\">\n";
955 foreach my $entry (@$taglist) {
957 my $comment_lines = $tag{'comment'};
958 my $comment = shift @$comment_lines;
959 if (defined($comment)) {
960 $comment = chop_str($comment, 30, 5);
963 print "<tr class=\"dark\">\n";
965 print "<tr class=\"light\">\n";
969 print "<td><i>$tag{'age'}</i></td>\n" .
971 $cgi->a({-href => "$my_uri?p=$project;a=$tag{'reftype'};h=$tag{'refid'}", -class => "list"},
972 "<b>" . escapeHTML($tag{'name'}) . "</b>") .
975 if (defined($comment)) {
976 print $cgi->a({-class => "list", -href => "$my_uri?p=$project;a=tag;h=$tag{'id'}"}, $comment);
979 "<td class=\"link\">";
980 if ($tag{'type'} eq "tag") {
981 print $cgi->a({-href => "$my_uri?p=$project;a=tag;h=$tag{'id'}"}, "tag") . " | ";
983 print $cgi->a({-href => "$my_uri?p=$project;a=$tag{'reftype'};h=$tag{'refid'}"}, $tag{'reftype'});
984 if ($tag{'reftype'} eq "commit") {
985 print " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'name'}"}, "shortlog") .
986 " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'refid'}"}, "log");
991 print "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=tags"}, "...") . "</td>\n" .
999 my $branchlist = git_read_refs("refs/heads");
1000 if (defined @$branchlist) {
1002 $cgi->a({-href => "$my_uri?p=$project;a=branches", -class => "title"}, "branches") .
1005 print "<table cellspacing=\"0\">\n";
1007 foreach my $entry (@$branchlist) {
1010 print "<tr class=\"dark\">\n";
1012 print "<tr class=\"light\">\n";
1016 print "<td><i>$tag{'age'}</i></td>\n" .
1018 $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'name'}", -class => "list"},
1019 "<b>" . escapeHTML($tag{'name'}) . "</b>") .
1021 "<td class=\"link\">" .
1022 $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'name'}"}, "shortlog") .
1023 " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'name'}"}, "log") .
1027 print "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=branches"}, "...") . "</td>\n" .
1038 my $head = git_read_hash("$project/HEAD");
1040 print "<div class=\"page_nav\">\n" .
1041 $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") .
1042 " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "shortlog") .
1043 " | " . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") .
1044 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$head"}, "commit") .
1045 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$head"}, "commitdiff") .
1046 " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;hb=$head"}, "tree") . "<br/>\n" .
1049 my %tag = git_read_tag($hash);
1051 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML($tag{'name'})) . "\n" .
1053 print "<div class=\"title_text\">\n" .
1054 "<table cellspacing=\"0\">\n" .
1055 "<tr><td>$tag{'type'}</td><td>" . $cgi->a({-class => "text", -href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'object'}"}, $tag{'object'}) . "</td></tr>\n";
1056 if (defined($tag{'author'})) {
1057 my %ad = date_str($tag{'epoch'}, $tag{'tz'});
1058 print "<tr><td>author</td><td>" . escapeHTML($tag{'author'}) . "</td></tr>\n";
1059 print "<tr><td></td><td>" . $ad{'rfc2822'} . sprintf(" (%02d:%02d %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'}) . "</td></tr>\n";
1061 print "</table>\n\n" .
1063 print "<div class=\"page_body\">";
1064 my $comment = $tag{'comment'};
1065 foreach my $line (@$comment) {
1066 print escapeHTML($line) . "<br/>\n";
1073 my $head = git_read_hash("$project/HEAD");
1075 print "<div class=\"page_nav\">\n" .
1076 $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") .
1077 " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "shortlog") .
1078 " | " . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") .
1079 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$head"}, "commit") .
1080 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$head"}, "commitdiff") .
1081 " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;hb=$head"}, "tree") . "<br/>\n" .
1084 my $taglist = git_read_refs("refs/tags");
1086 $cgi->a({-href => "$my_uri?p=$project;a=summary", -class => "title"}, " ") .
1088 print "<table cellspacing=\"0\">\n";
1090 if (defined @$taglist) {
1091 foreach my $entry (@$taglist) {
1093 my $comment_lines = $tag{'comment'};
1094 my $comment = shift @$comment_lines;
1095 if (defined($comment)) {
1096 $comment = chop_str($comment, 30, 5);
1099 print "<tr class=\"dark\">\n";
1101 print "<tr class=\"light\">\n";
1104 print "<td><i>$tag{'age'}</i></td>\n" .
1106 $cgi->a({-href => "$my_uri?p=$project;a=$tag{'reftype'};h=$tag{'refid'}", -class => "list"},
1107 "<b>" . escapeHTML($tag{'name'}) . "</b>") .
1110 if (defined($comment)) {
1111 print $cgi->a({-class => "list", -href => "$my_uri?p=$project;a=tag;h=$tag{'id'}"}, $comment);
1114 "<td class=\"link\">";
1115 if ($tag{'type'} eq "tag") {
1116 print $cgi->a({-href => "$my_uri?p=$project;a=tag;h=$tag{'id'}"}, "tag") . " | ";
1118 print $cgi->a({-href => "$my_uri?p=$project;a=$tag{'reftype'};h=$tag{'refid'}"}, $tag{'reftype'});
1119 if ($tag{'reftype'} eq "commit") {
1120 print " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'name'}"}, "shortlog") .
1121 " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'refid'}"}, "log");
1132 my $head = git_read_hash("$project/HEAD");
1134 print "<div class=\"page_nav\">\n" .
1135 $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") .
1136 " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "shortlog") .
1137 " | " . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") .
1138 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$head"}, "commit") .
1139 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$head"}, "commitdiff") .
1140 " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;hb=$head"}, "tree") . "<br/>\n" .
1143 my $taglist = git_read_refs("refs/heads");
1145 $cgi->a({-href => "$my_uri?p=$project;a=summary", -class => "title"}, " ") .
1147 print "<table cellspacing=\"0\">\n";
1149 if (defined @$taglist) {
1150 foreach my $entry (@$taglist) {
1153 print "<tr class=\"dark\">\n";
1155 print "<tr class=\"light\">\n";
1158 print "<td><i>$tag{'age'}</i></td>\n" .
1160 $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'name'}", -class => "list"}, "<b>" . escapeHTML($tag{'name'}) . "</b>") .
1162 "<td class=\"link\">" .
1163 $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'name'}"}, "shortlog") .
1164 " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'name'}"}, "log") .
1173 sub git_get_hash_by_path {
1175 my $path = shift || return undef;
1178 my @parts = split '/', $path;
1179 while (my $part = shift @parts) {
1180 open my $fd, "-|", "$gitbin/git-ls-tree $tree" or die_error(undef, "Open git-ls-tree failed.");
1181 my (@entries) = map { chomp; $_ } <$fd>;
1182 close $fd or return undef;
1183 foreach my $line (@entries) {
1184 #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c'
1185 $line =~ m/^([0-9]+) (.+) ([0-9a-fA-F]{40})\t(.+)$/;
1190 if ($t_name eq $part) {
1194 if ($t_type eq "tree") {
1204 if (!defined $hash && defined $file_name) {
1205 my $base = $hash_base || git_read_hash("$project/HEAD");
1206 $hash = git_get_hash_by_path($base, $file_name, "blob");
1208 open my $fd, "-|", "$gitbin/git-cat-file blob $hash" or die_error(undef, "Open failed.");
1209 my $base = $file_name || "";
1211 if (defined $hash_base && (my %co = git_read_commit($hash_base))) {
1212 print "<div class=\"page_nav\">\n" .
1213 $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") .
1214 " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "shortlog") .
1215 " | " . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") .
1216 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") .
1217 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "commitdiff") .
1218 " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash_base"}, "tree") . "<br/>\n";
1219 print $cgi->a({-href => "$my_uri?p=$project;a=blob_plain;h=$hash"}, "plain") . "<br/>\n" .
1222 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base", -class => "title"}, escapeHTML($co{'title'})) .
1225 print "<div class=\"page_nav\">\n" .
1226 "<br/><br/></div>\n" .
1227 "<div class=\"title\">$hash</div>\n";
1229 if (defined $file_name) {
1230 print "<div class=\"page_path\"><b>$file_name</b></div>\n";
1232 print "<div class=\"page_body\">\n";
1234 while (my $line = <$fd>) {
1237 while ((my $pos = index($line, "\t")) != -1) {
1238 if (my $count = (8 - ($pos % 8))) {
1239 my $spaces = ' ' x $count;
1240 $line =~ s/\t/$spaces/;
1243 printf "<div class=\"pre\"><a id=\"l%i\" href=\"#l%i\" class=\"linenr\">%4i</a> %s</div>\n", $nr, $nr, $nr, escapeHTML($line);
1245 close $fd or print "Reading blob failed.\n";
1250 sub git_blob_plain {
1251 print $cgi->header(-type => "text/plain", -charset => 'utf-8');
1252 open my $fd, "-|", "$gitbin/git-cat-file blob $hash" or return;
1260 if (!defined $hash) {
1261 $hash = git_read_hash("$project/HEAD");
1262 if (defined $file_name) {
1263 my $base = $hash_base || git_read_hash("$project/HEAD");
1264 $hash = git_get_hash_by_path($base, $file_name, "tree");
1266 if (!defined $hash_base) {
1267 $hash_base = git_read_hash("$project/HEAD");
1270 open my $fd, "-|", "$gitbin/git-ls-tree $hash" or die_error(undef, "Open git-ls-tree failed.");
1271 my (@entries) = map { chomp; $_ } <$fd>;
1272 close $fd or die_error(undef, "Reading tree failed.");
1278 if (defined $hash_base && (my %co = git_read_commit($hash_base))) {
1279 $base_key = ";hb=$hash_base";
1280 print "<div class=\"page_nav\">\n" .
1281 $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") .
1282 " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash_base"}, "shortlog") .
1283 " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$hash_base"}, "log") .
1284 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") .
1285 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "commitdiff") .
1290 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base", -class => "title"}, escapeHTML($co{'title'})) . "\n" .
1293 print "<div class=\"page_nav\">\n";
1294 print "<br/><br/></div>\n";
1295 print "<div class=\"title\">$hash</div>\n";
1297 if (defined $file_name) {
1298 $base = "$file_name/";
1299 print "<div class=\"page_path\"><b>/$file_name</b></div>\n";
1301 print "<div class=\"page_path\"><b>/</b></div>\n";
1303 print "<div class=\"page_body\">\n";
1304 print "<table cellspacing=\"0\">\n";
1306 foreach my $line (@entries) {
1307 #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c'
1308 $line =~ m/^([0-9]+) (.+) ([0-9a-fA-F]{40})\t(.+)$/;
1313 $file_key = ";f=$base$t_name";
1315 print "<tr class=\"dark\">\n";
1317 print "<tr class=\"light\">\n";
1320 print "<td style=\"font-family:monospace\">" . mode_str($t_mode) . "</td>\n";
1321 if ($t_type eq "blob") {
1322 print "<td class=\"list\">" .
1323 $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash" . $base_key . $file_key, -class => "list"}, $t_name) .
1325 "<td class=\"link\">" .
1326 $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash" . $base_key . $file_key}, "blob") .
1327 " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash_base" . $file_key}, "history") .
1329 } elsif ($t_type eq "tree") {
1330 print "<td class=\"list\">" .
1331 $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$t_hash" . $base_key . $file_key}, $t_name) .
1333 "<td class=\"link\">" .
1334 $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$t_hash" . $base_key . $file_key}, "tree") .
1339 print "</table>\n" .
1345 # http://www.notestips.com/80256B3A007F2692/1/NAMO5P9UPQ
1346 open my $fd, "-|", "$gitbin/git-rev-list --max-count=20 " . git_read_hash("$project/HEAD") or die_error(undef, "Open failed.");
1347 my (@revlist) = map { chomp; $_ } <$fd>;
1348 close $fd or die_error(undef, "Reading rev-list failed.");
1350 print $cgi->header(-type => 'text/xml', -charset => 'utf-8');
1351 print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n".
1352 "<rss version=\"2.0\" xmlns:content=\"http://purl.org/rss/1.0/modules/content/\">\n";
1353 print "<channel>\n";
1354 print "<title>$project</title>\n".
1355 "<link>" . escapeHTML("$my_url?p=$project;a=summary") . "</link>\n".
1356 "<description>$project log</description>\n".
1357 "<language>en</language>\n";
1359 foreach my $commit (@revlist) {
1360 my %co = git_read_commit($commit);
1361 my %cd = date_str($co{'committer_epoch'});
1364 sprintf("%d %s %02d:%02d", $cd{'mday'}, $cd{'month'}, $cd{'hour'}, $cd{'minute'}) . " - " . escapeHTML($co{'title'}) .
1366 "<pubDate>$cd{'rfc2822'}</pubDate>\n" .
1367 "<link>" . escapeHTML("$my_url?p=$project;a=commit;h=$commit") . "</link>\n" .
1368 "<description>" . escapeHTML($co{'title'}) . "</description>\n" .
1369 "<content:encoded>" .
1371 my $comment = $co{'comment'};
1372 foreach my $line (@$comment) {
1373 print "$line<br/>\n";
1376 "</content:encoded>\n" .
1379 print "</channel></rss>";
1383 my @list = git_read_projects();
1385 print $cgi->header(-type => 'text/xml', -charset => 'utf-8');
1386 print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n".
1387 "<opml version=\"1.0\">\n".
1389 " <title>Git OPML Export</title>\n".
1392 "<outline text=\"git RSS feeds\">\n";
1394 foreach my $pr (@list) {
1396 my $head = git_read_hash("$proj{'path'}/HEAD");
1397 if (!defined $head) {
1400 $ENV{'GIT_DIR'} = "$projectroot/$proj{'path'}";
1401 my %co = git_read_commit($head);
1406 my $path = escapeHTML(chop_str($proj{'path'}, 25, 5));
1407 my $rss = "$my_url?p=$proj{'path'};a=rss";
1408 my $html = "$my_url?p=$proj{'path'};a=summary";
1409 print "<outline type=\"rss\" text=\"$path\" title=\"$path\" xmlUrl=\"$rss\" htmlUrl=\"$html\"/>\n";
1411 print "</outline>\n".
1417 my $head = git_read_hash("$project/HEAD");
1418 if (!defined $hash) {
1421 if (!defined $page) {
1425 print "<div class=\"page_nav\">\n";
1426 print $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") .
1427 " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash"}, "shortlog") .
1429 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") .
1430 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff") .
1431 " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash;hb=$hash"}, "tree") . "<br/>\n";
1433 my $limit = sprintf("--max-count=%i", (100 * ($page+1)));
1434 open my $fd, "-|", "$gitbin/git-rev-list $limit $hash" or die_error(undef, "Open failed.");
1435 my (@revlist) = map { chomp; $_ } <$fd>;
1438 if ($hash ne $head || $page) {
1439 print $cgi->a({-href => "$my_uri?p=$project;a=log"}, "HEAD");
1445 $cgi->a({-href => "$my_uri?p=$project;a=log;h=$hash;pg=" . ($page-1), -accesskey => "p", -title => "Alt-p"}, "prev");
1447 print " ⋅ prev";
1449 if ($#revlist >= (100 * ($page+1)-1)) {
1451 $cgi->a({-href => "$my_uri?p=$project;a=log;h=$hash;pg=" . ($page+1), -accesskey => "n", -title => "Alt-n"}, "next");
1453 print " ⋅ next";
1459 $cgi->a({-href => "$my_uri?p=$project;a=summary", -class => "title"}, " ") .
1461 my %co = git_read_commit($hash);
1462 print "<div class=\"page_body\"> Last change $co{'age_string'}.<br/><br/></div>\n";
1464 for (my $i = ($page * 100); $i <= $#revlist; $i++) {
1465 my $commit = $revlist[$i];
1466 my %co = git_read_commit($commit);
1468 my %ad = date_str($co{'author_epoch'});
1470 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "title"},
1471 "<span class=\"age\">$co{'age_string'}</span>" . escapeHTML($co{'title'})) . "\n" .
1473 print "<div class=\"title_text\">\n" .
1474 "<div class=\"log_link\">\n" .
1475 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") .
1476 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "commitdiff") .
1479 "<i>" . escapeHTML($co{'author_name'}) . " [$ad{'rfc2822'}]</i><br/>\n" .
1481 "<div class=\"log_body\">\n";
1482 my $comment = $co{'comment'};
1484 foreach my $line (@$comment) {
1485 if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
1496 print format_log_line_html($line) . "<br/>\n";
1507 my %co = git_read_commit($hash);
1509 die_error(undef, "Unknown commit object.");
1511 my %ad = date_str($co{'author_epoch'}, $co{'author_tz'});
1512 my %cd = date_str($co{'committer_epoch'}, $co{'committer_tz'});
1516 my $parent = $co{'parent'};
1517 if (!defined $parent) {
1521 open my $fd, "-|", "$gitbin/git-diff-tree -r -M $root $parent $hash" or die_error(undef, "Open failed.");
1522 @difftree = map { chomp; $_ } <$fd>;
1523 close $fd or die_error(undef, "Reading diff-tree failed.");
1525 print "<div class=\"page_nav\">\n" .
1526 $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") .
1527 " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash"}, "shortlog") .
1528 " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$hash"}, "log") .
1530 if (defined $co{'parent'}) {
1531 print " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff");
1533 print " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, "tree") . "\n" .
1534 "<br/><br/></div>\n";
1535 if (defined $co{'parent'}) {
1537 $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" .
1541 $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" .
1544 print "<div class=\"title_text\">\n" .
1545 "<table cellspacing=\"0\">\n";
1546 print "<tr><td>author</td><td>" . escapeHTML($co{'author'}) . "</td></tr>\n".
1548 "<td></td><td> $ad{'rfc2822'}";
1549 if ($ad{'hour_local'} < 6) {
1550 printf(" (<span style=\"color: #cc0000;\">%02d:%02d</span> %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
1552 printf(" (%02d:%02d %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
1556 print "<tr><td>committer</td><td>" . escapeHTML($co{'committer'}) . "</td></tr>\n";
1557 print "<tr><td></td><td> $cd{'rfc2822'}" . sprintf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}) . "</td></tr>\n";
1558 print "<tr><td>commit</td><td style=\"font-family:monospace\">$hash</td></tr>\n";
1561 "<td style=\"font-family:monospace\">" .
1562 $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash", class => "list"}, $co{'tree'}) .
1564 "<td class=\"link\">" . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, "tree") .
1567 my $parents = $co{'parents'};
1568 foreach my $par (@$parents) {
1571 "<td style=\"font-family:monospace\">" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$par", class => "list"}, $par) . "</td>" .
1572 "<td class=\"link\">" .
1573 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$par"}, "commit") .
1574 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash;hp=$par"}, "commitdiff") .
1580 print "<div class=\"page_body\">\n";
1581 my $comment = $co{'comment'};
1584 foreach my $line (@$comment) {
1585 # print only one empty line
1587 if ($empty || $signed) {
1594 if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
1596 print "<span style=\"color: #888888\">" . escapeHTML($line) . "</span><br/>\n";
1599 print format_log_line_html($line) . "<br/>\n";
1603 print "<div class=\"list_head\">\n";
1604 if ($#difftree > 10) {
1605 print(($#difftree + 1) . " files changed:\n");
1608 print "<table cellspacing=\"0\">\n";
1610 foreach my $line (@difftree) {
1611 # ':100644 100644 03b218260e99b78c6df0ed378e59ed9205ccc96d 3b93d5e7cc7f7dd4ebed13a5cc1a4ad976fc94d8 M ls-files.c'
1612 # ':100644 100644 7f9281985086971d3877aca27704f2aaf9c448ce bc190ebc71bbd923f2b728e505408f5e54bd073a M rev-tree.c'
1613 if (!($line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)([0-9]{0,3})\t(.*)$/)) {
1621 my $similarity = $6;
1624 print "<tr class=\"dark\">\n";
1626 print "<tr class=\"light\">\n";
1629 if ($status eq "A") {
1631 if (S_ISREG(oct $to_mode)) {
1632 $mode_chng = sprintf(" with mode: %04o", (oct $to_mode) & 0777);
1635 $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hp=$hash;f=$file", -class => "list"}, escapeHTML($file)) . "</td>\n" .
1636 "<td><span style=\"color: #008000;\">[new " . file_type($to_mode) . "$mode_chng]</span></td>\n" .
1637 "<td class=\"link\">" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"}, "blob") . "</td>\n";
1638 } elsif ($status eq "D") {
1640 $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file", -class => "list"}, escapeHTML($file)) . "</td>\n" .
1641 "<td><span style=\"color: #c00000;\">[deleted " . file_type($from_mode). "]</span></td>\n" .
1642 "<td class=\"link\">" .
1643 $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file"}, "blob") .
1644 " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") .
1646 } elsif ($status eq "M" || $status eq "T") {
1647 my $mode_chnge = "";
1648 if ($from_mode != $to_mode) {
1649 $mode_chnge = " <span style=\"color: #777777;\">[changed";
1650 if (((oct $from_mode) & S_IFMT) != ((oct $to_mode) & S_IFMT)) {
1651 $mode_chnge .= " from " . file_type($from_mode) . " to " . file_type($to_mode);
1653 if (((oct $from_mode) & 0777) != ((oct $to_mode) & 0777)) {
1654 if (S_ISREG($from_mode) && S_ISREG($to_mode)) {
1655 $mode_chnge .= sprintf(" mode: %04o->%04o", (oct $from_mode) & 0777, (oct $to_mode) & 0777);
1656 } elsif (S_ISREG($to_mode)) {
1657 $mode_chnge .= sprintf(" mode: %04o", (oct $to_mode) & 0777);
1660 $mode_chnge .= "]</span>\n";
1663 if ($to_id ne $from_id) {
1664 print $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file", -class => "list"}, escapeHTML($file));
1666 print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file", -class => "list"}, escapeHTML($file));
1669 "<td>$mode_chnge</td>\n" .
1670 "<td class=\"link\">";
1671 print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"}, "blob");
1672 if ($to_id ne $from_id) {
1673 print " | " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file"}, "diff");
1675 print " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . "\n";
1677 } elsif ($status eq "R") {
1678 my ($from_file, $to_file) = split "\t", $file;
1680 if ($from_mode != $to_mode) {
1681 $mode_chng = sprintf(", mode: %04o", (oct $to_mode) & 0777);
1684 $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$to_file", -class => "list"}, escapeHTML($to_file)) . "</td>\n" .
1685 "<td><span style=\"color: #777777;\">[moved from " .
1686 $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$from_file", -class => "list"}, escapeHTML($from_file)) .
1687 " with " . (int $similarity) . "% similarity$mode_chng]</span></td>\n" .
1688 "<td class=\"link\">" .
1689 $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$to_file"}, "blob");
1690 if ($to_id ne $from_id) {
1691 print " | " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$to_file"}, "diff");
1702 mkdir($git_temp, 0700);
1704 if (defined $hash_base && (my %co = git_read_commit($hash_base))) {
1705 print "<div class=\"page_nav\">\n" .
1706 $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") .
1707 " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "shortlog") .
1708 " | " . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") .
1709 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") .
1710 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "commitdiff") .
1711 " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash_base"}, "tree") .
1713 print $cgi->a({-href => "$my_uri?p=$project;a=blobdiff_plain;h=$hash;hp=$hash_parent"}, "plain") .
1716 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base", -class => "title"}, escapeHTML($co{'title'})) . "\n" .
1719 print "<div class=\"page_nav\">\n" .
1720 "<br/><br/></div>\n" .
1721 "<div class=\"title\">$hash vs $hash_parent</div>\n";
1723 if (defined $file_name) {
1724 print "<div class=\"page_path\"><b>/$file_name</b></div>\n";
1726 print "<div class=\"page_body\">\n" .
1727 "<div class=\"diff_info\">blob:" .
1728 $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$hash_parent;hb=$hash_base;f=$file_name"}, $hash_parent) .
1730 $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$hash;hb=$hash_base;f=$file_name"}, $hash) .
1732 git_diff_print($hash_parent, $file_name || $hash_parent, $hash, $file_name || $hash);
1737 sub git_blobdiff_plain {
1738 mkdir($git_temp, 0700);
1739 print $cgi->header(-type => "text/plain", -charset => 'utf-8');
1740 git_diff_print($hash_parent, $file_name || $hash_parent, $hash, $file_name || $hash, "plain");
1743 sub git_commitdiff {
1744 mkdir($git_temp, 0700);
1745 my %co = git_read_commit($hash);
1747 die_error(undef, "Unknown commit object.");
1749 if (!defined $hash_parent) {
1750 $hash_parent = $co{'parent'};
1752 open my $fd, "-|", "$gitbin/git-diff-tree -r $hash_parent $hash" or die_error(undef, "Open failed.");
1753 my (@difftree) = map { chomp; $_ } <$fd>;
1754 close $fd or die_error(undef, "Reading diff-tree failed.");
1757 print "<div class=\"page_nav\">\n" .
1758 $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") .
1759 " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash"}, "shortlog") .
1760 " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$hash"}, "log") .
1761 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") .
1763 " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, "tree") . "<br/>\n";
1764 print $cgi->a({-href => "$my_uri?p=$project;a=commitdiff_plain;h=$hash;hp=$hash_parent"}, "plain") . "\n" .
1767 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" .
1769 print "<div class=\"page_body\">\n";
1770 my $comment = $co{'comment'};
1773 my @log = @$comment;
1774 # remove first and empty lines after that
1776 while (defined $log[0] && $log[0] eq "") {
1779 foreach my $line (@log) {
1780 if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
1791 print format_log_line_html($line) . "<br/>\n";
1794 foreach my $line (@difftree) {
1795 # ':100644 100644 03b218260e99b78c6df0ed378e59ed9205ccc96d 3b93d5e7cc7f7dd4ebed13a5cc1a4ad976fc94d8 M ls-files.c'
1796 # ':100644 100644 7f9281985086971d3877aca27704f2aaf9c448ce bc190ebc71bbd923f2b728e505408f5e54bd073a M rev-tree.c'
1797 $line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$/;
1804 if ($status eq "A") {
1805 print "<div class=\"diff_info\">" . file_type($to_mode) . ":" .
1806 $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"}, $to_id) . "(new)" .
1808 git_diff_print(undef, "/dev/null", $to_id, "b/$file");
1809 } elsif ($status eq "D") {
1810 print "<div class=\"diff_info\">" . file_type($from_mode) . ":" .
1811 $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file"}, $from_id) . "(deleted)" .
1813 git_diff_print($from_id, "a/$file", undef, "/dev/null");
1814 } elsif ($status eq "M") {
1815 if ($from_id ne $to_id) {
1816 print "<div class=\"diff_info\">" .
1817 file_type($from_mode) . ":" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file"}, $from_id) .
1819 file_type($to_mode) . ":" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"}, $to_id);
1821 git_diff_print($from_id, "a/$file", $to_id, "b/$file");
1830 sub git_commitdiff_plain {
1831 mkdir($git_temp, 0700);
1832 open my $fd, "-|", "$gitbin/git-diff-tree -r $hash_parent $hash" or die_error(undef, "Open failed.");
1833 my (@difftree) = map { chomp; $_ } <$fd>;
1834 close $fd or die_error(undef, "Reading diff-tree failed.");
1836 # try to figure out the next tag after this commit
1839 my $tags = git_read_refs("refs/tags");
1840 foreach my $entry (@$tags) {
1842 $taghash{$tag{'refid'}} = $tag{'name'};
1844 open $fd, "-|", "$gitbin/git-rev-list HEAD";
1845 while (my $commit = <$fd>) {
1847 if ($taghash{$commit}) {
1848 $tagname = $taghash{$commit};
1850 if ($commit eq $hash) {
1856 print $cgi->header(-type => "text/plain", -charset => 'utf-8');
1857 my %co = git_read_commit($hash);
1858 my %ad = date_str($co{'author_epoch'}, $co{'author_tz'});
1859 my $comment = $co{'comment'};
1860 print "From: $co{'author'}\n" .
1861 "Date: $ad{'rfc2822'} ($ad{'tz_local'})\n".
1862 "Subject: $co{'title'}\n";
1863 if (defined $tagname) {
1864 print "X-Git-Tag: $tagname\n";
1866 print "X-Git-Url: $my_url?p=$project;a=commitdiff;h=$hash\n" .
1869 foreach my $line (@$comment) {;
1874 foreach my $line (@difftree) {
1875 $line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$/;
1880 if ($status eq "A") {
1881 git_diff_print(undef, "/dev/null", $to_id, "b/$file", "plain");
1882 } elsif ($status eq "D") {
1883 git_diff_print($from_id, "a/$file", undef, "/dev/null", "plain");
1884 } elsif ($status eq "M") {
1885 git_diff_print($from_id, "a/$file", $to_id, "b/$file", "plain");
1891 if (!defined $hash) {
1892 $hash = git_read_hash("$project/HEAD");
1894 my %co = git_read_commit($hash);
1896 die_error(undef, "Unknown commit object.");
1899 print "<div class=\"page_nav\">\n" .
1900 $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") .
1901 " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "shortlog") .
1902 " | " . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") .
1903 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") .
1904 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff") .
1905 " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, "tree") .
1909 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" .
1911 print "<div class=\"page_path\"><b>/$file_name</b><br/></div>\n";
1913 open my $fd, "-|", "$gitbin/git-rev-list $hash | $gitbin/git-diff-tree -r --stdin $file_name";
1915 print "<table cellspacing=\"0\">\n";
1917 while (my $line = <$fd>) {
1918 if ($line =~ m/^([0-9a-fA-F]{40})/){
1922 if ($line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$/ && (defined $commit)) {
1923 my %co = git_read_commit($commit);
1928 print "<tr class=\"dark\">\n";
1930 print "<tr class=\"light\">\n";
1933 print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
1934 "<td><i>" . escapeHTML(chop_str($co{'author_name'}, 15, 3)) . "</i></td>\n" .
1935 "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list"}, "<b>" .
1936 escapeHTML(chop_str($co{'title'}, 50)) . "</b>") . "</td>\n" .
1937 "<td class=\"link\">" .
1938 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") .
1939 " | " . $cgi->a({-href => "$my_uri?p=$project;a=blob;hb=$commit;f=$file_name"}, "blob");
1940 my $blob = git_get_hash_by_path($hash, $file_name);
1941 my $blob_parent = git_get_hash_by_path($commit, $file_name);
1942 if (defined $blob && defined $blob_parent && $blob ne $blob_parent) {
1944 $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$blob;hp=$blob_parent;hb=$commit;f=$file_name"},
1958 if (!defined $searchtext) {
1959 die_error("", "Text field empty.");
1961 if (!defined $hash) {
1962 $hash = git_read_hash("$project/HEAD");
1964 my %co = git_read_commit($hash);
1966 die_error(undef, "Unknown commit object.");
1968 # pickaxe may take all resources of your box and run for several minutes
1969 # with every query - so decide by yourself how public you make this feature :)
1970 my $commit_search = 1;
1971 my $author_search = 0;
1972 my $committer_search = 0;
1973 my $pickaxe_search = 0;
1974 if ($searchtext =~ s/^author\\://i) {
1976 } elsif ($searchtext =~ s/^committer\\://i) {
1977 $committer_search = 1;
1978 } elsif ($searchtext =~ s/^pickaxe\\://i) {
1980 $pickaxe_search = 1;
1983 print "<div class=\"page_nav\">\n" .
1984 $cgi->a({-href => "$my_uri?p=$project;a=summary;h=$hash"}, "summary") .
1985 " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "shortlog") .
1986 " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$hash"}, "log") .
1987 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") .
1988 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff") .
1989 " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, "tree") .
1994 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" .
1996 print "<table cellspacing=\"0\">\n";
1998 if ($commit_search) {
2000 open my $fd, "-|", "$gitbin/git-rev-list --header $hash";
2001 while (my $commit_text = <$fd>) {
2002 if (!grep m/$searchtext/i, $commit_text) {
2005 if ($author_search && !grep m/\nauthor .*$searchtext/i, $commit_text) {
2008 if ($committer_search && !grep m/\ncommitter .*$searchtext/i, $commit_text) {
2011 my @commit_lines = split "\n", $commit_text;
2012 my $commit = shift @commit_lines;
2013 my %co = git_read_commit($commit, \@commit_lines);
2018 print "<tr class=\"dark\">\n";
2020 print "<tr class=\"light\">\n";
2023 print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
2024 "<td><i>" . escapeHTML(chop_str($co{'author_name'}, 15, 5)) . "</i></td>\n" .
2026 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list"}, "<b>" . escapeHTML(chop_str($co{'title'}, 50)) . "</b><br/>");
2027 my $comment = $co{'comment'};
2028 foreach my $line (@$comment) {
2029 if ($line =~ m/^(.*)($searchtext)(.*)$/i) {
2030 my $lead = escapeHTML($1) || "";
2031 $lead = chop_str($lead, 30, 10);
2032 my $match = escapeHTML($2) || "";
2033 my $trail = escapeHTML($3) || "";
2034 $trail = chop_str($trail, 30, 10);
2035 my $text = "$lead<span style=\"color:#e00000\">$match</span>$trail";
2036 print chop_str($text, 80, 5) . "<br/>\n";
2040 "<td class=\"link\">" .
2041 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") .
2042 " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$commit"}, "tree");
2049 if ($pickaxe_search) {
2051 open my $fd, "-|", "$gitbin/git-rev-list $hash | $gitbin/git-diff-tree -r --stdin -S$searchtext";
2054 while (my $line = <$fd>) {
2055 if (%co && $line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$/) {
2058 $set{'from_id'} = $3;
2060 $set{'id'} = $set{'to_id'};
2061 if ($set{'id'} =~ m/0{40}/) {
2062 $set{'id'} = $set{'from_id'};
2064 if ($set{'id'} =~ m/0{40}/) {
2068 } elsif ($line =~ m/^([0-9a-fA-F]{40}) /){
2071 print "<tr class=\"dark\">\n";
2073 print "<tr class=\"light\">\n";
2076 print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
2077 "<td><i>" . escapeHTML(chop_str($co{'author_name'}, 15, 5)) . "</i></td>\n" .
2079 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$co{'id'}", -class => "list"}, "<b>" .
2080 escapeHTML(chop_str($co{'title'}, 50)) . "</b><br/>");
2081 while (my $setref = shift @files) {
2083 print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$set{'id'};hb=$co{'id'};f=$set{'file'}", class => "list"},
2084 "<span style=\"color:#e00000\">" . escapeHTML($set{'file'}) . "</span>") .
2088 "<td class=\"link\">" .
2089 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$co{'id'}"}, "commit") .
2090 " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$co{'id'}"}, "tree");
2094 %co = git_read_commit($1);
2104 my $head = git_read_hash("$project/HEAD");
2105 if (!defined $hash) {
2108 if (!defined $page) {
2112 print "<div class=\"page_nav\">\n" .
2113 $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") .
2115 " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$hash"}, "log") .
2116 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") .
2117 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff") .
2118 " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash;hb=$hash"}, "tree") . "<br/>\n";
2120 my $limit = sprintf("--max-count=%i", (100 * ($page+1)));
2121 open my $fd, "-|", "$gitbin/git-rev-list $limit $hash" or die_error(undef, "Open failed.");
2122 my (@revlist) = map { chomp; $_ } <$fd>;
2125 if ($hash ne $head || $page) {
2126 print $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "HEAD");
2132 $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash;pg=" . ($page-1), -accesskey => "p", -title => "Alt-p"}, "prev");
2134 print " ⋅ prev";
2136 if ($#revlist >= (100 * ($page+1)-1)) {
2138 $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash;pg=" . ($page+1), -accesskey => "n", -title => "Alt-n"}, "next");
2140 print " ⋅ next";
2145 $cgi->a({-href => "$my_uri?p=$project;a=summary", -class => "title"}, " ") .
2147 print "<table cellspacing=\"0\">\n";
2149 for (my $i = ($page * 100); $i <= $#revlist; $i++) {
2150 my $commit = $revlist[$i];
2151 my %co = git_read_commit($commit);
2152 my %ad = date_str($co{'author_epoch'});
2154 print "<tr class=\"dark\">\n";
2156 print "<tr class=\"light\">\n";
2159 print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
2160 "<td><i>" . escapeHTML(chop_str($co{'author_name'}, 10)) . "</i></td>\n" .
2161 "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list"}, "<b>" .
2162 escapeHTML($co{'title_short'}) . "</b>") . "</td>\n" .
2163 "<td class=\"link\">" .
2164 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") .
2165 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "commitdiff") .
2169 if ($#revlist >= (100 * ($page+1)-1)) {
2172 $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash;pg=" . ($page+1), -title => "Alt-n"}, "next") .