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";
25 $projectroot = "/home/kay/public_html/pub/scm";
27 # location of the git-core binaries
28 my $gitbin = "/usr/bin";
30 # location for temporary files needed for diffs
31 my $git_temp = "/tmp/gitweb";
33 # target of the home link on top of all pages
34 my $home_link = $my_uri;
36 # html text to include at home page
37 my $home_text = "indextext.html";
39 # source of projects list
40 #my $projects_list = $projectroot;
41 my $projects_list = "index/index.aux";
43 # input validation and dispatch
44 my $action = $cgi->param('a');
45 if (defined $action) {
46 if ($action =~ m/[^0-9a-zA-Z\.\-_]+/) {
48 die_error(undef, "Invalid action parameter.");
50 if ($action eq "git-logo.png") {
53 } elsif ($action eq "opml") {
59 my $project = $cgi->param('p');
60 if (defined $project) {
61 if ($project =~ m/(^|\/)(|\.|\.\.)($|\/)/) {
63 die_error(undef, "Non-canonical project parameter.");
65 if ($project =~ m/[^a-zA-Z0-9_\.\/\-\+\#\~]/) {
67 die_error(undef, "Invalid character in project parameter.");
69 if (!(-d "$projectroot/$project")) {
71 die_error(undef, "No such directory.");
73 if (!(-e "$projectroot/$project/HEAD")) {
75 die_error(undef, "No such project.");
77 $rss_link = "<link rel=\"alternate\" title=\"$project log\" href=\"$my_uri?p=$project;a=rss\" type=\"application/rss+xml\"/>";
78 $ENV{'GIT_DIR'} = "$projectroot/$project";
84 my $file_name = $cgi->param('f');
85 if (defined $file_name) {
86 if ($file_name =~ m/(^|\/)(|\.|\.\.)($|\/)/) {
88 die_error(undef, "Non-canonical file parameter.");
90 if ($file_name =~ m/[^a-zA-Z0-9_\.\/\-\+\#\~\:\!]/) {
92 die_error(undef, "Invalid character in file parameter.");
96 my $hash = $cgi->param('h');
98 if (!($hash =~ m/^[0-9a-fA-F]{40}$/)) {
99 if ($hash =~ m/(^|\/)(|\.|\.\.)($|\/)/) {
101 die_error(undef, "Non-canonical hash parameter.");
103 if ($hash =~ m/[^a-zA-Z0-9_\.\/\-\+\#\~\:\!]/) {
105 die_error(undef, "Invalid character in hash parameter.");
107 # replace branch-name with hash
108 my $branchlist = git_read_refs("refs/heads");
109 foreach my $entry (@$branchlist) {
110 my %branch = %$entry;
111 if ($branch{'name'} eq $hash) {
112 $hash = $branch{'id'};
119 my $hash_parent = $cgi->param('hp');
120 if (defined $hash_parent && !($hash_parent =~ m/^[0-9a-fA-F]{40}$/)) {
122 die_error(undef, "Invalid hash_parent parameter.");
125 my $hash_base = $cgi->param('hb');
126 if (defined $hash_base && !($hash_base =~ m/^[0-9a-fA-F]{40}$/)) {
128 die_error(undef, "Invalid parent hash parameter.");
131 my $page = $cgi->param('pg');
133 if ($page =~ m/^[^0-9]+$/) {
135 die_error(undef, "Invalid page parameter.");
139 my $searchtext = $cgi->param('s');
140 if (defined $searchtext) {
141 if ($searchtext =~ m/[^a-zA-Z0-9_\.\/\-\+\:\@ ]/) {
143 die_error(undef, "Invalid search parameter.");
145 $searchtext = quotemeta $searchtext;
148 if (!defined $action || $action eq "summary") {
151 } elsif ($action eq "branches") {
154 } elsif ($action eq "tags") {
157 } elsif ($action eq "blob") {
160 } elsif ($action eq "blob_plain") {
163 } elsif ($action eq "tree") {
166 } elsif ($action eq "rss") {
169 } elsif ($action eq "commit") {
172 } elsif ($action eq "log") {
175 } elsif ($action eq "blobdiff") {
178 } elsif ($action eq "blobdiff_plain") {
179 git_blobdiff_plain();
181 } elsif ($action eq "commitdiff") {
184 } elsif ($action eq "commitdiff_plain") {
185 git_commitdiff_plain();
187 } elsif ($action eq "history") {
190 } elsif ($action eq "search") {
193 } elsif ($action eq "shortlog") {
196 } elsif ($action eq "tag") {
201 die_error(undef, "Unknown action.");
205 sub git_header_html {
206 my $status = shift || "200 OK";
209 if (defined $project) {
210 $title .= " - $project";
211 if (defined $action) {
212 $title .= "/$action";
215 print $cgi->header(-type=>'text/html', -charset => 'utf-8', -status=> $status);
217 <?xml version="1.0" encoding="utf-8"?>
218 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
219 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
220 <!-- git web interface v$version, (C) 2005, Kay Sievers <kay.sievers\@vrfy.org>, Christian Gierke <ch\@gierke.de> -->
222 <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
223 <meta name="robots" content="index, nofollow"/>
224 <title>$title</title>
226 <style type="text/css">
227 body { font-family: sans-serif; font-size: 12px; margin:0px; border:solid #d9d8d1; border-width:1px; margin:10px; }
229 a:hover, a:visited, a:active { color:#880000; }
230 div.page_header { height:25px; padding:8px; font-size:18px; font-weight:bold; background-color:#d9d8d1; }
231 div.page_header a:visited { color:#0000cc; }
232 div.page_header a:hover { color:#880000; }
233 div.page_nav { padding:8px; }
234 div.page_nav a:visited { color:#0000cc; }
235 div.page_path { padding:8px; border:solid #d9d8d1; border-width:0px 0px 1px}
236 div.page_footer { height:17px; padding:4px 8px; background-color: #d9d8d1; }
237 div.page_footer_text { float:left; color:#555555; font-style:italic; }
238 div.page_body { padding:8px; }
240 display:block; padding:6px 8px;
241 font-weight:bold; background-color:#edece6; text-decoration:none; color:#000000;
243 a.title:hover { background-color: #d9d8d1; }
244 div.title_text { padding:6px 0px; border: solid #d9d8d1; border-width:0px 0px 1px; }
245 div.log_body { padding:8px 8px 8px 150px; }
246 span.age { position:relative; float:left; width:142px; font-style:italic; }
249 font-size:10px; font-family:sans-serif; font-style:normal;
250 position:relative; float:left; width:136px;
252 div.list_head { padding:6px 8px 4px; border:solid #d9d8d1; border-width:1px 0px 0px; font-style:italic; }
253 a.list { text-decoration:none; color:#000000; }
254 a.list:hover { text-decoration:underline; color:#880000; }
255 a.text { text-decoration:none; color:#0000cc; }
256 a.text:visited { text-decoration:none; color:#880000; }
257 a.text:hover { text-decoration:underline; color:#880000; }
258 table { padding:8px 4px; }
259 th { padding:2px 5px; font-size:12px; text-align:left; }
260 tr.light:hover { background-color:#edece6; }
261 tr.dark { background-color:#f6f6f0; }
262 tr.dark:hover { background-color:#edece6; }
263 td { padding:2px 5px; font-size:12px; vertical-align:top; }
264 td.link { padding:2px 5px; font-family:sans-serif; font-size:10px; }
265 div.pre { font-family:monospace; font-size:12px; white-space:pre; }
266 div.diff_info { font-family:monospace; color:#000099; background-color:#edece6; font-style:italic; }
267 div.index_include { border:solid #d9d8d1; border-width:0px 0px 1px; padding:12px 8px; }
268 div.search { margin:4px 8px; position:absolute; top:56px; right:12px }
269 a.linenr { color:#999999; text-decoration:none }
271 float:right; padding:3px 0px; width:35px; line-height:10px;
272 border:1px solid; border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e;
273 color:#ffffff; background-color:#ff6600;
274 font-weight:bold; font-family:sans-serif; font-size:10px;
275 text-align:center; text-decoration:none;
277 a.rss_logo:hover { background-color:#ee5500; }
282 print "<div class=\"page_header\">\n" .
283 "<a href=\"http://www.kernel.org/pub/software/scm/git/docs/\" title=\"git documentation\">" .
284 "<img src=\"$my_uri?a=git-logo.png\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/>" .
286 print $cgi->a({-href => $home_link}, "projects") . " / ";
287 if (defined $project) {
288 print $cgi->a({-href => "$my_uri?p=$project;a=summary"}, escapeHTML($project));
289 if (defined $action) {
293 if (!defined $searchtext) {
296 $cgi->param("a", "search");
297 print $cgi->startform(-method => "get", -action => "$my_uri") .
298 "<div class=\"search\">\n" .
299 $cgi->hidden(-name => "p") . "\n" .
300 $cgi->hidden(-name => "a") . "\n" .
301 $cgi->textfield(-name => "s", -value => $searchtext) . "\n" .
303 $cgi->end_form() . "\n";
308 sub git_footer_html {
309 print "<div class=\"page_footer\">\n";
310 if (defined $project) {
311 my $descr = git_read_description($project);
312 if (defined $descr) {
313 print "<div class=\"page_footer_text\">" . escapeHTML($descr) . "</div>\n";
315 print $cgi->a({-href => "$my_uri?p=$project;a=rss", -class => "rss_logo"}, "RSS") . "\n";
317 print $cgi->a({-href => "$my_uri?a=opml", -class => "rss_logo"}, "RSS") . "\n";
325 my $status = shift || "403 Forbidden";
326 my $error = shift || "Malformed query, file missing or permission denied";
328 git_header_html($status);
329 print "<div class=\"page_body\">\n" .
331 "$status - $error\n" .
341 open my $fd, "-|", "$gitbin/git-cat-file -t $hash" or return;
351 open my $fd, "$projectroot/$path" or return undef;
355 if ($head =~ m/^[0-9a-fA-F]{40}$/) {
360 sub git_read_description {
363 open my $fd, "$projectroot/$path/description" or return undef;
375 open my $fd, "-|", "$gitbin/git-cat-file tag $tag_id" or return;
376 $tag{'id'} = $tag_id;
377 while (my $line = <$fd>) {
379 if ($line =~ m/^object ([0-9a-fA-F]{40})$/) {
381 } elsif ($line =~ m/^type (.+)$/) {
383 } elsif ($line =~ m/^tag (.+)$/) {
385 } elsif ($line =~ m/^tagger (.*) ([0-9]+) (.*)$/) {
389 } elsif ($line =~ m/--BEGIN/) {
390 push @comment, $line;
392 } elsif ($line eq "") {
396 push @comment, <$fd>;
397 $tag{'comment'} = \@comment;
399 if (!defined $tag{'name'}) {
409 if ($age > 60*60*24*365*2) {
410 $age_str = (int $age/60/60/24/365);
411 $age_str .= " years ago";
412 } elsif ($age > 60*60*24*(365/12)*2) {
413 $age_str = int $age/60/60/24/(365/12);
414 $age_str .= " months ago";
415 } elsif ($age > 60*60*24*7*2) {
416 $age_str = int $age/60/60/24/7;
417 $age_str .= " weeks ago";
418 } elsif ($age > 60*60*24*2) {
419 $age_str = int $age/60/60/24;
420 $age_str .= " days ago";
421 } elsif ($age > 60*60*2) {
422 $age_str = int $age/60/60;
423 $age_str .= " hours ago";
424 } elsif ($age > 60*2) {
425 $age_str = int $age/60;
426 $age_str .= " min ago";
429 $age_str .= " sec ago";
431 $age_str .= " right now";
436 sub git_read_commit {
437 my $commit_id = shift;
438 my $commit_text = shift;
444 if (defined $commit_text) {
445 @commit_lines = @$commit_text;
447 open my $fd, "-|", "$gitbin/git-cat-file commit $commit_id" or return;
448 @commit_lines = map { chomp; $_ } <$fd>;
451 while (my $line = shift @commit_lines) {
452 last if $line eq "\n";
453 if ($line =~ m/^tree ([0-9a-fA-F]{40})$/) {
455 } elsif ($line =~ m/^parent ([0-9a-fA-F]{40})$/) {
457 } elsif ($line =~ m/^author (.*) ([0-9]+) (.*)$/) {
459 $co{'author_epoch'} = $2;
460 $co{'author_tz'} = $3;
461 if ($co{'author'} =~ m/^([^<]+) </) {
462 $co{'author_name'} = $1;
464 $co{'author_name'} = $co{'author'};
466 } elsif ($line =~ m/^committer (.*) ([0-9]+) (.*)$/) {
467 $co{'committer'} = $1;
468 $co{'committer_epoch'} = $2;
469 $co{'committer_tz'} = $3;
470 $co{'committer_name'} = $co{'committer'};
471 $co{'committer_name'} =~ s/ <.*//;
474 if (!defined $co{'tree'}) {
477 $co{'id'} = $commit_id;
478 $co{'parents'} = \@parents;
479 $co{'parent'} = $parents[0];
480 $co{'comment'} = \@commit_lines;
481 foreach my $title (@commit_lines) {
483 $co{'title'} = chop_str($title, 80);
484 # remove leading stuff of merges to make the interesting part visible
485 if (length($title) > 50) {
486 $title =~ s/^Automatic //;
487 $title =~ s/^merge (of|with) /Merge ... /i;
488 if (length($title) > 50) {
489 $title =~ s/(http|rsync):\/\///;
491 if (length($title) > 50) {
492 $title =~ s/(master|www|rsync)\.//;
494 if (length($title) > 50) {
495 $title =~ s/kernel.org:?//;
497 if (length($title) > 50) {
498 $title =~ s/\/pub\/scm//;
501 $co{'title_short'} = chop_str($title, 50);
506 my $age = time - $co{'committer_epoch'};
508 $co{'age_string'} = age_string($age);
509 my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($co{'committer_epoch'});
510 if ($age > 60*60*24*7*2) {
511 $co{'age_string_date'} = sprintf "%4i-%02u-%02i", 1900 + $year, $mon+1, $mday;
512 $co{'age_string_age'} = $co{'age_string'};
514 $co{'age_string_date'} = $co{'age_string'};
515 $co{'age_string_age'} = sprintf "%4i-%02u-%02i", 1900 + $year, $mon+1, $mday;
522 my $from_name = shift;
525 my $format = shift || "html";
527 my $from_tmp = "/dev/null";
528 my $to_tmp = "/dev/null";
531 # create tmp from-file
533 $from_tmp = "$git_temp/gitweb_" . $$ . "_from";
534 open my $fd2, "> $from_tmp";
535 open my $fd, "-|", "$gitbin/git-cat-file blob $from";
544 $to_tmp = "$git_temp/gitweb_" . $$ . "_to";
545 open my $fd2, "> $to_tmp";
546 open my $fd, "-|", "$gitbin/git-cat-file blob $to";
553 open my $fd, "-|", "/usr/bin/diff -u -p -L $from_name -L $to_name $from_tmp $to_tmp";
554 if ($format eq "plain") {
559 while (my $line = <$fd>) {
561 my $char = substr($line, 0, 1);
564 $color = " style=\"color:#008800;\"";
565 } elsif ($char eq "-") {
566 $color = " style=\"color:#cc0000;\"";
567 } elsif ($char eq "@") {
568 $color = " style=\"color:#990099;\"";
569 } elsif ($char eq "\\") {
573 while ((my $pos = index($line, "\t")) != -1) {
574 if (my $count = (8 - (($pos-1) % 8))) {
575 my $spaces = ' ' x $count;
576 $line =~ s/\t/$spaces/;
579 print "<div class=\"pre\"$color>" . escapeHTML($line) . "</div>\n";
593 my $mode = oct shift;
595 if (S_ISDIR($mode & S_IFMT)) {
597 } elsif (S_ISLNK($mode)) {
599 } elsif (S_ISREG($mode)) {
600 # git cares only about the executable bit
601 if ($mode & S_IXUSR) {
614 my $add_len = shift || 10;
616 $str =~ m/^(.{0,$len}[^ \/\-_:\.@]{0,$add_len})/;
618 if ($chopped ne $str) {
625 my $mode = oct shift;
627 if (S_ISDIR($mode & S_IFMT)) {
629 } elsif (S_ISLNK($mode)) {
631 } elsif (S_ISREG($mode)) {
638 sub format_log_line_html {
641 $line = escapeHTML($line);
642 $line =~ s/ / /g;
643 if ($line =~ m/([0-9a-fA-F]{40})/) {
645 if (git_get_type($hash_text) eq "commit") {
646 my $link = $cgi->a({-class => "text", -href => "$my_uri?p=$project;a=commit;h=$hash_text"}, $hash_text);
647 $line =~ s/$hash_text/$link/;
655 my $tz = shift || "-0000";
658 my @months = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
659 my @days = ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
660 my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($epoch);
661 $date{'hour'} = $hour;
662 $date{'minute'} = $min;
663 $date{'mday'} = $mday;
664 $date{'day'} = $days[$wday];
665 $date{'month'} = $months[$mon];
666 $date{'rfc2822'} = sprintf "%s, %d %s %4d %02d:%02d:%02d +0000", $days[$wday], $mday, $months[$mon], 1900+$year, $hour ,$min, $sec;
667 $date{'mday-time'} = sprintf "%d %s %02d:%02d", $mday, $months[$mon], $hour ,$min;
669 $tz =~ m/^([+\-][0-9][0-9])([0-9][0-9])$/;
670 my $local = $epoch + ((int $1 + ($2/60)) * 3600);
671 ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($local);
672 $date{'hour_local'} = $hour;
673 $date{'minute_local'} = $min;
674 $date{'tz_local'} = $tz;
678 # git-logo (cached in browser for one day)
680 print $cgi->header(-type => 'image/png', -expires => '+1d');
681 # cat git-logo.png | hexdump -e '16/1 " %02x" "\n"' | sed 's/ /\\x/g'
682 print "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52" .
683 "\x00\x00\x00\x48\x00\x00\x00\x1b\x04\x03\x00\x00\x00\x2d\xd9\xd4" .
684 "\x2d\x00\x00\x00\x18\x50\x4c\x54\x45\xff\xff\xff\x60\x60\x5d\xb0" .
685 "\xaf\xaa\x00\x80\x00\xce\xcd\xc7\xc0\x00\x00\xe8\xe8\xe6\xf7\xf7" .
686 "\xf6\x95\x0c\xa7\x47\x00\x00\x00\x73\x49\x44\x41\x54\x28\xcf\x63" .
687 "\x48\x67\x20\x04\x4a\x5c\x18\x0a\x08\x2a\x62\x53\x61\x20\x02\x08" .
688 "\x0d\x69\x45\xac\xa1\xa1\x01\x30\x0c\x93\x60\x36\x26\x52\x91\xb1" .
689 "\x01\x11\xd6\xe1\x55\x64\x6c\x6c\xcc\x6c\x6c\x0c\xa2\x0c\x70\x2a" .
690 "\x62\x06\x2a\xc1\x62\x1d\xb3\x01\x02\x53\xa4\x08\xe8\x00\x03\x18" .
691 "\x26\x56\x11\xd4\xe1\x20\x97\x1b\xe0\xb4\x0e\x35\x24\x71\x29\x82" .
692 "\x99\x30\xb8\x93\x0a\x11\xb9\x45\x88\xc1\x8d\xa0\xa2\x44\x21\x06" .
693 "\x27\x41\x82\x40\x85\xc1\x45\x89\x20\x70\x01\x00\xa4\x3d\x21\xc5" .
694 "\x12\x1c\x9a\xfe\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82";
700 my ($dev, $ino, $mode, $nlink, $st_uid, $st_gid, $rdev, $size) = stat($path);
701 my ($name, $passwd, $uid, $gid, $quota, $comment, $gcos, $dir, $shell) = getpwuid($st_uid);
702 if (!defined $gcos) {
706 $owner =~ s/[,;].*$//;
710 sub git_read_projects {
713 if (-d $projects_list) {
714 # search in directory
715 my $dir = $projects_list;
716 opendir my $dh, $dir or return undef;
717 while (my $dir = readdir($dh)) {
718 if (-e "$projectroot/$dir/HEAD") {
726 } elsif (-f $projects_list) {
727 # read from file(url-encoded):
728 # 'git%2Fgit.git Linus+Torvalds'
729 # 'libs%2Fklibc%2Fklibc.git H.+Peter+Anvin'
730 # 'linux%2Fhotplug%2Fudev.git Greg+Kroah-Hartman'
731 open my $fd , $projects_list or return undef;
732 while (my $line = <$fd>) {
734 my ($path, $owner) = split ' ', $line;
735 $path = unescape($path);
736 $owner = unescape($owner);
737 if (!defined $path) {
740 if (-e "$projectroot/$path/HEAD") {
750 @list = sort {$a->{'path'} cmp $b->{'path'}} @list;
754 sub git_project_list {
755 my @list = git_read_projects();
757 die_error(undef, "No project found.");
761 print "<div class=\"index_include\">\n";
762 open (my $fd, $home_text);
767 print "<table cellspacing=\"0\">\n" .
769 "<th>Project</th>\n" .
770 "<th>Description</th>\n" .
772 "<th>last change</th>\n" .
776 foreach my $pr (@list) {
778 my $head = git_read_hash("$proj{'path'}/HEAD");
779 if (!defined $head) {
782 $ENV{'GIT_DIR'} = "$projectroot/$proj{'path'}";
783 my %co = git_read_commit($head);
787 my $descr = git_read_description($proj{'path'}) || "";
788 $descr = chop_str($descr, 25, 5);
789 # get directory owner if not already specified
790 if (!defined $proj{'owner'}) {
791 $proj{'owner'} = get_file_owner("$projectroot/$proj{'path'}") || "";
794 print "<tr class=\"dark\">\n";
796 print "<tr class=\"light\">\n";
799 print "<td>" . $cgi->a({-href => "$my_uri?p=$proj{'path'};a=summary", -class => "list"}, escapeHTML($proj{'path'})) . "</td>\n" .
800 "<td>$descr</td>\n" .
801 "<td><i>" . chop_str($proj{'owner'}, 15) . "</i></td>\n";
803 if ($co{'age'} < 60*60*2) {
804 $colored_age = "<span style =\"color: #009900;\"><b><i>$co{'age_string'}</i></b></span>";
805 } elsif ($co{'age'} < 60*60*24*2) {
806 $colored_age = "<span style =\"color: #009900;\"><i>$co{'age_string'}</i></span>";
808 $colored_age = "<i>$co{'age_string'}</i>";
810 print "<td>$colored_age</td>\n" .
811 "<td class=\"link\">" .
812 $cgi->a({-href => "$my_uri?p=$proj{'path'};a=summary"}, "summary") .
813 " | " . $cgi->a({-href => "$my_uri?p=$proj{'path'};a=shortlog"}, "shortlog") .
814 " | " . $cgi->a({-href => "$my_uri?p=$proj{'path'};a=log"}, "log") .
827 opendir my $dh, "$projectroot/$project/$ref_dir";
828 while (my $dir = readdir($dh)) {
829 if ($dir =~ m/^\./) {
832 if (-d "$projectroot/$project/$ref_dir/$dir") {
833 opendir my $dh2, "$projectroot/$project/$ref_dir/$dir";
834 my @subdirs = grep !m/^\./, readdir $dh2;
836 foreach my $subdir (@subdirs) {
837 push @refs, "$dir/$subdir"
844 foreach my $ref_file (@refs) {
845 my $ref_id = git_read_hash("$project/$ref_dir/$ref_file");
846 my $type = git_get_type($ref_id) || next;
849 $ref_item{'type'} = $type;
850 $ref_item{'id'} = $ref_id;
851 $ref_item{'epoch'} = 0;
852 $ref_item{'age'} = "unknown";
853 if ($type eq "tag") {
854 my %tag = git_read_tag($ref_id);
855 $ref_item{'comment'} = $tag{'comment'};
856 if ($tag{'type'} eq "commit") {
857 %co = git_read_commit($tag{'object'});
858 $ref_item{'epoch'} = $co{'committer_epoch'};
859 $ref_item{'age'} = $co{'age_string'};
860 } elsif (defined($tag{'epoch'})) {
861 my $age = time - $tag{'epoch'};
862 $ref_item{'epoch'} = $tag{'epoch'};
863 $ref_item{'age'} = age_string($age);
865 $ref_item{'reftype'} = $tag{'type'};
866 $ref_item{'name'} = $tag{'name'};
867 $ref_item{'refid'} = $tag{'object'};
868 } elsif ($type eq "commit"){
869 %co = git_read_commit($ref_id);
870 $ref_item{'reftype'} = "commit";
871 $ref_item{'name'} = $ref_file;
872 $ref_item{'title'} = $co{'title'};
873 $ref_item{'refid'} = $ref_id;
874 $ref_item{'epoch'} = $co{'committer_epoch'};
875 $ref_item{'age'} = $co{'age_string'};
878 push @reflist, \%ref_item;
881 @reflist = sort {$b->{'epoch'} <=> $a->{'epoch'}} @reflist;
886 my $descr = git_read_description($project) || "none";
887 my $head = git_read_hash("$project/HEAD");
888 my %co = git_read_commit($head);
889 my %cd = date_str($co{'committer_epoch'}, $co{'committer_tz'});
892 if (-f $projects_list) {
893 open (my $fd , $projects_list);
894 while (my $line = <$fd>) {
896 my ($pr, $ow) = split ' ', $line;
899 if ($pr eq $project) {
906 if (!defined $owner) {
907 $owner = get_file_owner("$projectroot/$project");
911 print "<div class=\"page_nav\">\n" .
913 " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "shortlog") .
914 " | " . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") .
915 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$head"}, "commit") .
916 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$head"}, "commitdiff") .
917 " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree"}, "tree") .
920 print "<div class=\"title\"> </div>\n";
921 print "<table cellspacing=\"0\">\n" .
922 "<tr><td>description</td><td>" . escapeHTML($descr) . "</td></tr>\n" .
923 "<tr><td>owner</td><td>$owner</td></tr>\n" .
924 "<tr><td>last change</td><td>$cd{'rfc2822'}</td></tr>\n" .
926 open my $fd, "-|", "$gitbin/git-rev-list --max-count=17 " . git_read_hash("$project/HEAD") or die_error(undef, "Open failed.");
927 my (@revlist) = map { chomp; $_ } <$fd>;
930 $cgi->a({-href => "$my_uri?p=$project;a=shortlog", -class => "title"}, "shortlog") .
933 print "<table cellspacing=\"0\">\n";
935 foreach my $commit (@revlist) {
936 my %co = git_read_commit($commit);
937 my %ad = date_str($co{'author_epoch'});
939 print "<tr class=\"dark\">\n";
941 print "<tr class=\"light\">\n";
945 print "<td><i>$co{'age_string'}</i></td>\n" .
946 "<td><i>" . escapeHTML(chop_str($co{'author_name'}, 10)) . "</i></td>\n" .
948 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list"},
949 "<b>" . escapeHTML($co{'title_short'}) . "</b>") .
951 "<td class=\"link\">" .
952 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") .
953 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "commitdiff") .
957 print "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "...") . "</td>\n" .
964 my $taglist = git_read_refs("refs/tags");
965 if (defined @$taglist) {
967 $cgi->a({-href => "$my_uri?p=$project;a=tags", -class => "title"}, "tags") .
970 print "<table cellspacing=\"0\">\n";
972 foreach my $entry (@$taglist) {
974 my $comment_lines = $tag{'comment'};
975 my $comment = shift @$comment_lines;
976 if (defined($comment)) {
977 $comment = chop_str($comment, 30, 5);
980 print "<tr class=\"dark\">\n";
982 print "<tr class=\"light\">\n";
986 print "<td><i>$tag{'age'}</i></td>\n" .
988 $cgi->a({-href => "$my_uri?p=$project;a=$tag{'reftype'};h=$tag{'refid'}", -class => "list"},
989 "<b>" . escapeHTML($tag{'name'}) . "</b>") .
992 if (defined($comment)) {
993 print $cgi->a({-class => "list", -href => "$my_uri?p=$project;a=tag;h=$tag{'id'}"}, $comment);
996 "<td class=\"link\">";
997 if ($tag{'type'} eq "tag") {
998 print $cgi->a({-href => "$my_uri?p=$project;a=tag;h=$tag{'id'}"}, "tag") . " | ";
1000 print $cgi->a({-href => "$my_uri?p=$project;a=$tag{'reftype'};h=$tag{'refid'}"}, $tag{'reftype'});
1001 if ($tag{'reftype'} eq "commit") {
1002 print " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'name'}"}, "shortlog") .
1003 " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'refid'}"}, "log");
1008 print "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=tags"}, "...") . "</td>\n" .
1016 my $branchlist = git_read_refs("refs/heads");
1017 if (defined @$branchlist) {
1019 $cgi->a({-href => "$my_uri?p=$project;a=branches", -class => "title"}, "branches") .
1022 print "<table cellspacing=\"0\">\n";
1024 foreach my $entry (@$branchlist) {
1027 print "<tr class=\"dark\">\n";
1029 print "<tr class=\"light\">\n";
1033 print "<td><i>$tag{'age'}</i></td>\n" .
1035 $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'name'}", -class => "list"},
1036 "<b>" . escapeHTML($tag{'name'}) . "</b>") .
1038 "<td class=\"link\">" .
1039 $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'name'}"}, "shortlog") .
1040 " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'name'}"}, "log") .
1044 print "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=branches"}, "...") . "</td>\n" .
1055 my $head = git_read_hash("$project/HEAD");
1057 print "<div class=\"page_nav\">\n" .
1058 $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") .
1059 " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "shortlog") .
1060 " | " . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") .
1061 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$head"}, "commit") .
1062 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$head"}, "commitdiff") .
1063 " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;hb=$head"}, "tree") . "<br/>\n" .
1066 my %tag = git_read_tag($hash);
1068 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML($tag{'name'})) . "\n" .
1070 print "<div class=\"title_text\">\n" .
1071 "<table cellspacing=\"0\">\n" .
1072 "<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";
1073 if (defined($tag{'author'})) {
1074 my %ad = date_str($tag{'epoch'}, $tag{'tz'});
1075 print "<tr><td>author</td><td>" . escapeHTML($tag{'author'}) . "</td></tr>\n";
1076 print "<tr><td></td><td>" . $ad{'rfc2822'} . sprintf(" (%02d:%02d %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'}) . "</td></tr>\n";
1078 print "</table>\n\n" .
1080 print "<div class=\"page_body\">";
1081 my $comment = $tag{'comment'};
1082 foreach my $line (@$comment) {
1083 print escapeHTML($line) . "<br/>\n";
1090 my $head = git_read_hash("$project/HEAD");
1092 print "<div class=\"page_nav\">\n" .
1093 $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") .
1094 " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "shortlog") .
1095 " | " . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") .
1096 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$head"}, "commit") .
1097 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$head"}, "commitdiff") .
1098 " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;hb=$head"}, "tree") . "<br/>\n" .
1101 my $taglist = git_read_refs("refs/tags");
1103 $cgi->a({-href => "$my_uri?p=$project;a=summary", -class => "title"}, " ") .
1105 print "<table cellspacing=\"0\">\n";
1107 if (defined @$taglist) {
1108 foreach my $entry (@$taglist) {
1110 my $comment_lines = $tag{'comment'};
1111 my $comment = shift @$comment_lines;
1112 if (defined($comment)) {
1113 $comment = chop_str($comment, 30, 5);
1116 print "<tr class=\"dark\">\n";
1118 print "<tr class=\"light\">\n";
1121 print "<td><i>$tag{'age'}</i></td>\n" .
1123 $cgi->a({-href => "$my_uri?p=$project;a=$tag{'reftype'};h=$tag{'refid'}", -class => "list"},
1124 "<b>" . escapeHTML($tag{'name'}) . "</b>") .
1127 if (defined($comment)) {
1128 print $cgi->a({-class => "list", -href => "$my_uri?p=$project;a=tag;h=$tag{'id'}"}, $comment);
1131 "<td class=\"link\">";
1132 if ($tag{'type'} eq "tag") {
1133 print $cgi->a({-href => "$my_uri?p=$project;a=tag;h=$tag{'id'}"}, "tag") . " | ";
1135 print $cgi->a({-href => "$my_uri?p=$project;a=$tag{'reftype'};h=$tag{'refid'}"}, $tag{'reftype'});
1136 if ($tag{'reftype'} eq "commit") {
1137 print " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'name'}"}, "shortlog") .
1138 " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'refid'}"}, "log");
1149 my $head = git_read_hash("$project/HEAD");
1151 print "<div class=\"page_nav\">\n" .
1152 $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") .
1153 " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "shortlog") .
1154 " | " . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") .
1155 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$head"}, "commit") .
1156 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$head"}, "commitdiff") .
1157 " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;hb=$head"}, "tree") . "<br/>\n" .
1160 my $taglist = git_read_refs("refs/heads");
1162 $cgi->a({-href => "$my_uri?p=$project;a=summary", -class => "title"}, " ") .
1164 print "<table cellspacing=\"0\">\n";
1166 if (defined @$taglist) {
1167 foreach my $entry (@$taglist) {
1170 print "<tr class=\"dark\">\n";
1172 print "<tr class=\"light\">\n";
1175 print "<td><i>$tag{'age'}</i></td>\n" .
1177 $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'name'}", -class => "list"}, "<b>" . escapeHTML($tag{'name'}) . "</b>") .
1179 "<td class=\"link\">" .
1180 $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'name'}"}, "shortlog") .
1181 " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'name'}"}, "log") .
1190 sub git_get_hash_by_path {
1192 my $path = shift || return undef;
1195 my @parts = split '/', $path;
1196 while (my $part = shift @parts) {
1197 open my $fd, "-|", "$gitbin/git-ls-tree $tree" or die_error(undef, "Open git-ls-tree failed.");
1198 my (@entries) = map { chomp; $_ } <$fd>;
1199 close $fd or return undef;
1200 foreach my $line (@entries) {
1201 #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c'
1202 $line =~ m/^([0-9]+) (.+) ([0-9a-fA-F]{40})\t(.+)$/;
1207 if ($t_name eq $part) {
1211 if ($t_type eq "tree") {
1221 if (!defined $hash && defined $file_name) {
1222 my $base = $hash_base || git_read_hash("$project/HEAD");
1223 $hash = git_get_hash_by_path($base, $file_name, "blob");
1225 open my $fd, "-|", "$gitbin/git-cat-file blob $hash" or die_error(undef, "Open failed.");
1226 my $base = $file_name || "";
1228 if (defined $hash_base && (my %co = git_read_commit($hash_base))) {
1229 print "<div class=\"page_nav\">\n" .
1230 $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") .
1231 " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "shortlog") .
1232 " | " . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") .
1233 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") .
1234 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "commitdiff") .
1235 " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash_base"}, "tree") . "<br/>\n";
1236 print $cgi->a({-href => "$my_uri?p=$project;a=blob_plain;h=$hash"}, "plain") . "<br/>\n" .
1239 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base", -class => "title"}, escapeHTML($co{'title'})) .
1242 print "<div class=\"page_nav\">\n" .
1243 "<br/><br/></div>\n" .
1244 "<div class=\"title\">$hash</div>\n";
1246 if (defined $file_name) {
1247 print "<div class=\"page_path\"><b>$file_name</b></div>\n";
1249 print "<div class=\"page_body\">\n";
1251 while (my $line = <$fd>) {
1254 while ((my $pos = index($line, "\t")) != -1) {
1255 if (my $count = (8 - ($pos % 8))) {
1256 my $spaces = ' ' x $count;
1257 $line =~ s/\t/$spaces/;
1260 printf "<div class=\"pre\"><a id=\"l%i\" href=\"#l%i\" class=\"linenr\">%4i</a> %s</div>\n", $nr, $nr, $nr, escapeHTML($line);
1262 close $fd or print "Reading blob failed.\n";
1267 sub git_blob_plain {
1268 print $cgi->header(-type => "text/plain", -charset => 'utf-8');
1269 open my $fd, "-|", "$gitbin/git-cat-file blob $hash" or return;
1277 if (!defined $hash) {
1278 $hash = git_read_hash("$project/HEAD");
1279 if (defined $file_name) {
1280 my $base = $hash_base || git_read_hash("$project/HEAD");
1281 $hash = git_get_hash_by_path($base, $file_name, "tree");
1283 if (!defined $hash_base) {
1284 $hash_base = git_read_hash("$project/HEAD");
1287 open my $fd, "-|", "$gitbin/git-ls-tree $hash" or die_error(undef, "Open git-ls-tree failed.");
1288 my (@entries) = map { chomp; $_ } <$fd>;
1289 close $fd or die_error(undef, "Reading tree failed.");
1295 if (defined $hash_base && (my %co = git_read_commit($hash_base))) {
1296 $base_key = ";hb=$hash_base";
1297 print "<div class=\"page_nav\">\n" .
1298 $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") .
1299 " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash_base"}, "shortlog") .
1300 " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$hash_base"}, "log") .
1301 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") .
1302 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "commitdiff") .
1307 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base", -class => "title"}, escapeHTML($co{'title'})) . "\n" .
1310 print "<div class=\"page_nav\">\n";
1311 print "<br/><br/></div>\n";
1312 print "<div class=\"title\">$hash</div>\n";
1314 if (defined $file_name) {
1315 $base = "$file_name/";
1316 print "<div class=\"page_path\"><b>/$file_name</b></div>\n";
1318 print "<div class=\"page_path\"><b>/</b></div>\n";
1320 print "<div class=\"page_body\">\n";
1321 print "<table cellspacing=\"0\">\n";
1323 foreach my $line (@entries) {
1324 #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c'
1325 $line =~ m/^([0-9]+) (.+) ([0-9a-fA-F]{40})\t(.+)$/;
1330 $file_key = ";f=$base$t_name";
1332 print "<tr class=\"dark\">\n";
1334 print "<tr class=\"light\">\n";
1337 print "<td style=\"font-family:monospace\">" . mode_str($t_mode) . "</td>\n";
1338 if ($t_type eq "blob") {
1339 print "<td class=\"list\">" .
1340 $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash" . $base_key . $file_key, -class => "list"}, $t_name) .
1342 "<td class=\"link\">" .
1343 $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash" . $base_key . $file_key}, "blob") .
1344 " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash_base" . $file_key}, "history") .
1346 } elsif ($t_type eq "tree") {
1347 print "<td class=\"list\">" .
1348 $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$t_hash" . $base_key . $file_key}, $t_name) .
1350 "<td class=\"link\">" .
1351 $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$t_hash" . $base_key . $file_key}, "tree") .
1356 print "</table>\n" .
1362 # http://www.notestips.com/80256B3A007F2692/1/NAMO5P9UPQ
1363 open my $fd, "-|", "$gitbin/git-rev-list --max-count=20 " . git_read_hash("$project/HEAD") or die_error(undef, "Open failed.");
1364 my (@revlist) = map { chomp; $_ } <$fd>;
1365 close $fd or die_error(undef, "Reading rev-list failed.");
1367 print $cgi->header(-type => 'text/xml', -charset => 'utf-8');
1368 print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n".
1369 "<rss version=\"2.0\" xmlns:content=\"http://purl.org/rss/1.0/modules/content/\">\n";
1370 print "<channel>\n";
1371 print "<title>$project</title>\n".
1372 "<link>" . escapeHTML("$my_url?p=$project;a=summary") . "</link>\n".
1373 "<description>$project log</description>\n".
1374 "<language>en</language>\n";
1376 foreach my $commit (@revlist) {
1377 my %co = git_read_commit($commit);
1378 my %cd = date_str($co{'committer_epoch'});
1381 sprintf("%d %s %02d:%02d", $cd{'mday'}, $cd{'month'}, $cd{'hour'}, $cd{'minute'}) . " - " . escapeHTML($co{'title'}) .
1383 "<pubDate>$cd{'rfc2822'}</pubDate>\n" .
1384 "<link>" . escapeHTML("$my_url?p=$project;a=commit;h=$commit") . "</link>\n" .
1385 "<description>" . escapeHTML($co{'title'}) . "</description>\n" .
1386 "<content:encoded>" .
1388 my $comment = $co{'comment'};
1389 foreach my $line (@$comment) {
1390 print "$line<br/>\n";
1393 "</content:encoded>\n" .
1396 print "</channel></rss>";
1400 my @list = git_read_projects();
1402 print $cgi->header(-type => 'text/xml', -charset => 'utf-8');
1403 print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n".
1404 "<opml version=\"1.0\">\n".
1406 " <title>Git OPML Export</title>\n".
1409 "<outline text=\"git RSS feeds\">\n";
1411 foreach my $pr (@list) {
1413 my $head = git_read_hash("$proj{'path'}/HEAD");
1414 if (!defined $head) {
1417 $ENV{'GIT_DIR'} = "$projectroot/$proj{'path'}";
1418 my %co = git_read_commit($head);
1423 my $path = escapeHTML(chop_str($proj{'path'}, 25, 5));
1424 my $rss = "$my_url?p=$proj{'path'};a=rss";
1425 my $html = "$my_url?p=$proj{'path'};a=summary";
1426 print "<outline type=\"rss\" text=\"$path\" title=\"$path\" xmlUrl=\"$rss\" htmlUrl=\"$html\"/>\n";
1428 print "</outline>\n".
1434 my $head = git_read_hash("$project/HEAD");
1435 if (!defined $hash) {
1438 if (!defined $page) {
1442 print "<div class=\"page_nav\">\n";
1443 print $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") .
1444 " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash"}, "shortlog") .
1446 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") .
1447 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff") .
1448 " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash;hb=$hash"}, "tree") . "<br/>\n";
1450 my $limit = sprintf("--max-count=%i", (100 * ($page+1)));
1451 open my $fd, "-|", "$gitbin/git-rev-list $limit $hash" or die_error(undef, "Open failed.");
1452 my (@revlist) = map { chomp; $_ } <$fd>;
1455 if ($hash ne $head || $page) {
1456 print $cgi->a({-href => "$my_uri?p=$project;a=log"}, "HEAD");
1462 $cgi->a({-href => "$my_uri?p=$project;a=log;h=$hash;pg=" . ($page-1), -accesskey => "p", -title => "Alt-p"}, "prev");
1464 print " ⋅ prev";
1466 if ($#revlist >= (100 * ($page+1)-1)) {
1468 $cgi->a({-href => "$my_uri?p=$project;a=log;h=$hash;pg=" . ($page+1), -accesskey => "n", -title => "Alt-n"}, "next");
1470 print " ⋅ next";
1476 $cgi->a({-href => "$my_uri?p=$project;a=summary", -class => "title"}, " ") .
1478 my %co = git_read_commit($hash);
1479 print "<div class=\"page_body\"> Last change $co{'age_string'}.<br/><br/></div>\n";
1481 for (my $i = ($page * 100); $i <= $#revlist; $i++) {
1482 my $commit = $revlist[$i];
1483 my %co = git_read_commit($commit);
1485 my %ad = date_str($co{'author_epoch'});
1487 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "title"},
1488 "<span class=\"age\">$co{'age_string'}</span>" . escapeHTML($co{'title'})) . "\n" .
1490 print "<div class=\"title_text\">\n" .
1491 "<div class=\"log_link\">\n" .
1492 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") .
1493 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "commitdiff") .
1496 "<i>" . escapeHTML($co{'author_name'}) . " [$ad{'rfc2822'}]</i><br/>\n" .
1498 "<div class=\"log_body\">\n";
1499 my $comment = $co{'comment'};
1501 foreach my $line (@$comment) {
1502 if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
1513 print format_log_line_html($line) . "<br/>\n";
1524 my %co = git_read_commit($hash);
1526 die_error(undef, "Unknown commit object.");
1528 my %ad = date_str($co{'author_epoch'}, $co{'author_tz'});
1529 my %cd = date_str($co{'committer_epoch'}, $co{'committer_tz'});
1533 my $parent = $co{'parent'};
1534 if (!defined $parent) {
1538 open my $fd, "-|", "$gitbin/git-diff-tree -r -M $root $parent $hash" or die_error(undef, "Open failed.");
1539 @difftree = map { chomp; $_ } <$fd>;
1540 close $fd or die_error(undef, "Reading diff-tree failed.");
1542 print "<div class=\"page_nav\">\n" .
1543 $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") .
1544 " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash"}, "shortlog") .
1545 " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$hash"}, "log") .
1547 if (defined $co{'parent'}) {
1548 print " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff");
1550 print " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, "tree") . "\n" .
1551 "<br/><br/></div>\n";
1552 if (defined $co{'parent'}) {
1554 $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" .
1558 $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" .
1561 print "<div class=\"title_text\">\n" .
1562 "<table cellspacing=\"0\">\n";
1563 print "<tr><td>author</td><td>" . escapeHTML($co{'author'}) . "</td></tr>\n".
1565 "<td></td><td> $ad{'rfc2822'}";
1566 if ($ad{'hour_local'} < 6) {
1567 printf(" (<span style=\"color: #cc0000;\">%02d:%02d</span> %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
1569 printf(" (%02d:%02d %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
1573 print "<tr><td>committer</td><td>" . escapeHTML($co{'committer'}) . "</td></tr>\n";
1574 print "<tr><td></td><td> $cd{'rfc2822'}" . sprintf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}) . "</td></tr>\n";
1575 print "<tr><td>commit</td><td style=\"font-family:monospace\">$hash</td></tr>\n";
1578 "<td style=\"font-family:monospace\">" .
1579 $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash", class => "list"}, $co{'tree'}) .
1581 "<td class=\"link\">" . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, "tree") .
1584 my $parents = $co{'parents'};
1585 foreach my $par (@$parents) {
1588 "<td style=\"font-family:monospace\">" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$par", class => "list"}, $par) . "</td>" .
1589 "<td class=\"link\">" .
1590 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$par"}, "commit") .
1591 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash;hp=$par"}, "commitdiff") .
1597 print "<div class=\"page_body\">\n";
1598 my $comment = $co{'comment'};
1601 foreach my $line (@$comment) {
1602 # print only one empty line
1604 if ($empty || $signed) {
1611 if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
1613 print "<span style=\"color: #888888\">" . escapeHTML($line) . "</span><br/>\n";
1616 print format_log_line_html($line) . "<br/>\n";
1620 print "<div class=\"list_head\">\n";
1621 if ($#difftree > 10) {
1622 print(($#difftree + 1) . " files changed:\n");
1625 print "<table cellspacing=\"0\">\n";
1627 foreach my $line (@difftree) {
1628 # ':100644 100644 03b218260e99b78c6df0ed378e59ed9205ccc96d 3b93d5e7cc7f7dd4ebed13a5cc1a4ad976fc94d8 M ls-files.c'
1629 # ':100644 100644 7f9281985086971d3877aca27704f2aaf9c448ce bc190ebc71bbd923f2b728e505408f5e54bd073a M rev-tree.c'
1630 if (!($line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)([0-9]{0,3})\t(.*)$/)) {
1638 my $similarity = $6;
1641 print "<tr class=\"dark\">\n";
1643 print "<tr class=\"light\">\n";
1646 if ($status eq "A") {
1648 if (S_ISREG(oct $to_mode)) {
1649 $mode_chng = sprintf(" with mode: %04o", (oct $to_mode) & 0777);
1652 $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hp=$hash;f=$file", -class => "list"}, escapeHTML($file)) . "</td>\n" .
1653 "<td><span style=\"color: #008000;\">[new " . file_type($to_mode) . "$mode_chng]</span></td>\n" .
1654 "<td class=\"link\">" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"}, "blob") . "</td>\n";
1655 } elsif ($status eq "D") {
1657 $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file", -class => "list"}, escapeHTML($file)) . "</td>\n" .
1658 "<td><span style=\"color: #c00000;\">[deleted " . file_type($from_mode). "]</span></td>\n" .
1659 "<td class=\"link\">" .
1660 $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file"}, "blob") .
1661 " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") .
1663 } elsif ($status eq "M" || $status eq "T") {
1664 my $mode_chnge = "";
1665 if ($from_mode != $to_mode) {
1666 $mode_chnge = " <span style=\"color: #777777;\">[changed";
1667 if (((oct $from_mode) & S_IFMT) != ((oct $to_mode) & S_IFMT)) {
1668 $mode_chnge .= " from " . file_type($from_mode) . " to " . file_type($to_mode);
1670 if (((oct $from_mode) & 0777) != ((oct $to_mode) & 0777)) {
1671 if (S_ISREG($from_mode) && S_ISREG($to_mode)) {
1672 $mode_chnge .= sprintf(" mode: %04o->%04o", (oct $from_mode) & 0777, (oct $to_mode) & 0777);
1673 } elsif (S_ISREG($to_mode)) {
1674 $mode_chnge .= sprintf(" mode: %04o", (oct $to_mode) & 0777);
1677 $mode_chnge .= "]</span>\n";
1680 if ($to_id ne $from_id) {
1681 print $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file", -class => "list"}, escapeHTML($file));
1683 print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file", -class => "list"}, escapeHTML($file));
1686 "<td>$mode_chnge</td>\n" .
1687 "<td class=\"link\">";
1688 print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"}, "blob");
1689 if ($to_id ne $from_id) {
1690 print " | " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file"}, "diff");
1692 print " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . "\n";
1694 } elsif ($status eq "R") {
1695 my ($from_file, $to_file) = split "\t", $file;
1697 if ($from_mode != $to_mode) {
1698 $mode_chng = sprintf(", mode: %04o", (oct $to_mode) & 0777);
1701 $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$to_file", -class => "list"}, escapeHTML($to_file)) . "</td>\n" .
1702 "<td><span style=\"color: #777777;\">[moved from " .
1703 $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$from_file", -class => "list"}, escapeHTML($from_file)) .
1704 " with " . (int $similarity) . "% similarity$mode_chng]</span></td>\n" .
1705 "<td class=\"link\">" .
1706 $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$to_file"}, "blob");
1707 if ($to_id ne $from_id) {
1708 print " | " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$to_file"}, "diff");
1719 mkdir($git_temp, 0700);
1721 if (defined $hash_base && (my %co = git_read_commit($hash_base))) {
1722 print "<div class=\"page_nav\">\n" .
1723 $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") .
1724 " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "shortlog") .
1725 " | " . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") .
1726 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") .
1727 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "commitdiff") .
1728 " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash_base"}, "tree") .
1730 print $cgi->a({-href => "$my_uri?p=$project;a=blobdiff_plain;h=$hash;hp=$hash_parent"}, "plain") .
1733 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base", -class => "title"}, escapeHTML($co{'title'})) . "\n" .
1736 print "<div class=\"page_nav\">\n" .
1737 "<br/><br/></div>\n" .
1738 "<div class=\"title\">$hash vs $hash_parent</div>\n";
1740 if (defined $file_name) {
1741 print "<div class=\"page_path\"><b>/$file_name</b></div>\n";
1743 print "<div class=\"page_body\">\n" .
1744 "<div class=\"diff_info\">blob:" .
1745 $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$hash_parent;hb=$hash_base;f=$file_name"}, $hash_parent) .
1747 $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$hash;hb=$hash_base;f=$file_name"}, $hash) .
1749 git_diff_print($hash_parent, $file_name || $hash_parent, $hash, $file_name || $hash);
1754 sub git_blobdiff_plain {
1755 mkdir($git_temp, 0700);
1756 print $cgi->header(-type => "text/plain", -charset => 'utf-8');
1757 git_diff_print($hash_parent, $file_name || $hash_parent, $hash, $file_name || $hash, "plain");
1760 sub git_commitdiff {
1761 mkdir($git_temp, 0700);
1762 my %co = git_read_commit($hash);
1764 die_error(undef, "Unknown commit object.");
1766 if (!defined $hash_parent) {
1767 $hash_parent = $co{'parent'};
1769 open my $fd, "-|", "$gitbin/git-diff-tree -r $hash_parent $hash" or die_error(undef, "Open failed.");
1770 my (@difftree) = map { chomp; $_ } <$fd>;
1771 close $fd or die_error(undef, "Reading diff-tree failed.");
1774 print "<div class=\"page_nav\">\n" .
1775 $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") .
1776 " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash"}, "shortlog") .
1777 " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$hash"}, "log") .
1778 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") .
1780 " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, "tree") . "<br/>\n";
1781 print $cgi->a({-href => "$my_uri?p=$project;a=commitdiff_plain;h=$hash;hp=$hash_parent"}, "plain") . "\n" .
1784 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" .
1786 print "<div class=\"page_body\">\n";
1787 my $comment = $co{'comment'};
1790 my @log = @$comment;
1791 # remove first and empty lines after that
1793 while (defined $log[0] && $log[0] eq "") {
1796 foreach my $line (@log) {
1797 if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
1808 print format_log_line_html($line) . "<br/>\n";
1811 foreach my $line (@difftree) {
1812 # ':100644 100644 03b218260e99b78c6df0ed378e59ed9205ccc96d 3b93d5e7cc7f7dd4ebed13a5cc1a4ad976fc94d8 M ls-files.c'
1813 # ':100644 100644 7f9281985086971d3877aca27704f2aaf9c448ce bc190ebc71bbd923f2b728e505408f5e54bd073a M rev-tree.c'
1814 $line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$/;
1821 if ($status eq "A") {
1822 print "<div class=\"diff_info\">" . file_type($to_mode) . ":" .
1823 $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"}, $to_id) . "(new)" .
1825 git_diff_print(undef, "/dev/null", $to_id, "b/$file");
1826 } elsif ($status eq "D") {
1827 print "<div class=\"diff_info\">" . file_type($from_mode) . ":" .
1828 $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file"}, $from_id) . "(deleted)" .
1830 git_diff_print($from_id, "a/$file", undef, "/dev/null");
1831 } elsif ($status eq "M") {
1832 if ($from_id ne $to_id) {
1833 print "<div class=\"diff_info\">" .
1834 file_type($from_mode) . ":" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file"}, $from_id) .
1836 file_type($to_mode) . ":" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"}, $to_id);
1838 git_diff_print($from_id, "a/$file", $to_id, "b/$file");
1847 sub git_commitdiff_plain {
1848 mkdir($git_temp, 0700);
1849 open my $fd, "-|", "$gitbin/git-diff-tree -r $hash_parent $hash" or die_error(undef, "Open failed.");
1850 my (@difftree) = map { chomp; $_ } <$fd>;
1851 close $fd or die_error(undef, "Reading diff-tree failed.");
1853 # try to figure out the next tag after this commit
1856 my $tags = git_read_refs("refs/tags");
1857 foreach my $entry (@$tags) {
1859 $taghash{$tag{'refid'}} = $tag{'name'};
1861 open $fd, "-|", "$gitbin/git-rev-list HEAD";
1862 while (my $commit = <$fd>) {
1864 if ($taghash{$commit}) {
1865 $tagname = $taghash{$commit};
1867 if ($commit eq $hash) {
1873 print $cgi->header(-type => "text/plain", -charset => 'utf-8');
1874 my %co = git_read_commit($hash);
1875 my %ad = date_str($co{'author_epoch'}, $co{'author_tz'});
1876 my $comment = $co{'comment'};
1877 print "From: $co{'author'}\n" .
1878 "Date: $ad{'rfc2822'} ($ad{'tz_local'})\n".
1879 "Subject: $co{'title'}\n";
1880 if (defined $tagname) {
1881 print "X-Git-Tag: $tagname\n";
1883 print "X-Git-Url: $my_url?p=$project;a=commitdiff;h=$hash\n" .
1886 foreach my $line (@$comment) {;
1891 foreach my $line (@difftree) {
1892 $line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$/;
1897 if ($status eq "A") {
1898 git_diff_print(undef, "/dev/null", $to_id, "b/$file", "plain");
1899 } elsif ($status eq "D") {
1900 git_diff_print($from_id, "a/$file", undef, "/dev/null", "plain");
1901 } elsif ($status eq "M") {
1902 git_diff_print($from_id, "a/$file", $to_id, "b/$file", "plain");
1908 if (!defined $hash) {
1909 $hash = git_read_hash("$project/HEAD");
1911 my %co = git_read_commit($hash);
1913 die_error(undef, "Unknown commit object.");
1916 print "<div class=\"page_nav\">\n" .
1917 $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") .
1918 " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "shortlog") .
1919 " | " . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") .
1920 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") .
1921 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff") .
1922 " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, "tree") .
1926 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" .
1928 print "<div class=\"page_path\"><b>/$file_name</b><br/></div>\n";
1930 open my $fd, "-|", "$gitbin/git-rev-list $hash | $gitbin/git-diff-tree -r --stdin $file_name";
1932 print "<table cellspacing=\"0\">\n";
1934 while (my $line = <$fd>) {
1935 if ($line =~ m/^([0-9a-fA-F]{40})/){
1939 if ($line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$/ && (defined $commit)) {
1940 my %co = git_read_commit($commit);
1945 print "<tr class=\"dark\">\n";
1947 print "<tr class=\"light\">\n";
1950 print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
1951 "<td><i>" . escapeHTML(chop_str($co{'author_name'}, 15, 3)) . "</i></td>\n" .
1952 "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list"}, "<b>" .
1953 escapeHTML(chop_str($co{'title'}, 50)) . "</b>") . "</td>\n" .
1954 "<td class=\"link\">" .
1955 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") .
1956 " | " . $cgi->a({-href => "$my_uri?p=$project;a=blob;hb=$commit;f=$file_name"}, "blob");
1957 my $blob = git_get_hash_by_path($hash, $file_name);
1958 my $blob_parent = git_get_hash_by_path($commit, $file_name);
1959 if (defined $blob && defined $blob_parent && $blob ne $blob_parent) {
1961 $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$blob;hp=$blob_parent;hb=$commit;f=$file_name"},
1975 if (!defined $searchtext) {
1976 die_error("", "Text field empty.");
1978 if (!defined $hash) {
1979 $hash = git_read_hash("$project/HEAD");
1981 my %co = git_read_commit($hash);
1983 die_error(undef, "Unknown commit object.");
1985 # pickaxe may take all resources of your box and run for several minutes
1986 # with every query - so decide by yourself how public you make this feature :)
1987 my $commit_search = 1;
1988 my $author_search = 0;
1989 my $committer_search = 0;
1990 my $pickaxe_search = 0;
1991 if ($searchtext =~ s/^author\\://i) {
1993 } elsif ($searchtext =~ s/^committer\\://i) {
1994 $committer_search = 1;
1995 } elsif ($searchtext =~ s/^pickaxe\\://i) {
1997 $pickaxe_search = 1;
2000 print "<div class=\"page_nav\">\n" .
2001 $cgi->a({-href => "$my_uri?p=$project;a=summary;h=$hash"}, "summary") .
2002 " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "shortlog") .
2003 " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$hash"}, "log") .
2004 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") .
2005 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff") .
2006 " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, "tree") .
2011 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" .
2013 print "<table cellspacing=\"0\">\n";
2015 if ($commit_search) {
2017 open my $fd, "-|", "$gitbin/git-rev-list --header $hash";
2018 while (my $commit_text = <$fd>) {
2019 if (!grep m/$searchtext/i, $commit_text) {
2022 if ($author_search && !grep m/\nauthor .*$searchtext/i, $commit_text) {
2025 if ($committer_search && !grep m/\ncommitter .*$searchtext/i, $commit_text) {
2028 my @commit_lines = split "\n", $commit_text;
2029 my $commit = shift @commit_lines;
2030 my %co = git_read_commit($commit, \@commit_lines);
2035 print "<tr class=\"dark\">\n";
2037 print "<tr class=\"light\">\n";
2040 print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
2041 "<td><i>" . escapeHTML(chop_str($co{'author_name'}, 15, 5)) . "</i></td>\n" .
2043 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list"}, "<b>" . escapeHTML(chop_str($co{'title'}, 50)) . "</b><br/>");
2044 my $comment = $co{'comment'};
2045 foreach my $line (@$comment) {
2046 if ($line =~ m/^(.*)($searchtext)(.*)$/i) {
2047 my $lead = escapeHTML($1) || "";
2048 $lead = chop_str($lead, 30, 10);
2049 my $match = escapeHTML($2) || "";
2050 my $trail = escapeHTML($3) || "";
2051 $trail = chop_str($trail, 30, 10);
2052 my $text = "$lead<span style=\"color:#e00000\">$match</span>$trail";
2053 print chop_str($text, 80, 5) . "<br/>\n";
2057 "<td class=\"link\">" .
2058 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") .
2059 " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$commit"}, "tree");
2066 if ($pickaxe_search) {
2068 open my $fd, "-|", "$gitbin/git-rev-list $hash | $gitbin/git-diff-tree -r --stdin -S$searchtext";
2071 while (my $line = <$fd>) {
2072 if (%co && $line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$/) {
2075 $set{'from_id'} = $3;
2077 $set{'id'} = $set{'to_id'};
2078 if ($set{'id'} =~ m/0{40}/) {
2079 $set{'id'} = $set{'from_id'};
2081 if ($set{'id'} =~ m/0{40}/) {
2085 } elsif ($line =~ m/^([0-9a-fA-F]{40}) /){
2088 print "<tr class=\"dark\">\n";
2090 print "<tr class=\"light\">\n";
2093 print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
2094 "<td><i>" . escapeHTML(chop_str($co{'author_name'}, 15, 5)) . "</i></td>\n" .
2096 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$co{'id'}", -class => "list"}, "<b>" .
2097 escapeHTML(chop_str($co{'title'}, 50)) . "</b><br/>");
2098 while (my $setref = shift @files) {
2100 print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$set{'id'};hb=$co{'id'};f=$set{'file'}", class => "list"},
2101 "<span style=\"color:#e00000\">" . escapeHTML($set{'file'}) . "</span>") .
2105 "<td class=\"link\">" .
2106 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$co{'id'}"}, "commit") .
2107 " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$co{'id'}"}, "tree");
2111 %co = git_read_commit($1);
2121 my $head = git_read_hash("$project/HEAD");
2122 if (!defined $hash) {
2125 if (!defined $page) {
2129 print "<div class=\"page_nav\">\n" .
2130 $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") .
2132 " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$hash"}, "log") .
2133 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") .
2134 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff") .
2135 " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash;hb=$hash"}, "tree") . "<br/>\n";
2137 my $limit = sprintf("--max-count=%i", (100 * ($page+1)));
2138 open my $fd, "-|", "$gitbin/git-rev-list $limit $hash" or die_error(undef, "Open failed.");
2139 my (@revlist) = map { chomp; $_ } <$fd>;
2142 if ($hash ne $head || $page) {
2143 print $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "HEAD");
2149 $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash;pg=" . ($page-1), -accesskey => "p", -title => "Alt-p"}, "prev");
2151 print " ⋅ prev";
2153 if ($#revlist >= (100 * ($page+1)-1)) {
2155 $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash;pg=" . ($page+1), -accesskey => "n", -title => "Alt-n"}, "next");
2157 print " ⋅ next";
2162 $cgi->a({-href => "$my_uri?p=$project;a=summary", -class => "title"}, " ") .
2164 print "<table cellspacing=\"0\">\n";
2166 for (my $i = ($page * 100); $i <= $#revlist; $i++) {
2167 my $commit = $revlist[$i];
2168 my %co = git_read_commit($commit);
2169 my %ad = date_str($co{'author_epoch'});
2171 print "<tr class=\"dark\">\n";
2173 print "<tr class=\"light\">\n";
2176 print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
2177 "<td><i>" . escapeHTML(chop_str($co{'author_name'}, 10)) . "</i></td>\n" .
2178 "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list"}, "<b>" .
2179 escapeHTML($co{'title_short'}) . "</b>") . "</td>\n" .
2180 "<td class=\"link\">" .
2181 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") .
2182 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "commitdiff") .
2186 if ($#revlist >= (100 * ($page+1)-1)) {
2189 $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash;pg=" . ($page+1), -title => "Alt-n"}, "next") .