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") {
197 die_error
(undef, "Unknown action.");
201 sub git_header_html
{
202 my $status = shift || "200 OK";
205 if (defined $project) {
206 $title .= " - $project";
207 if (defined $action) {
208 $title .= "/$action";
211 print $cgi->header(-type
=>'text/html', -charset
=> 'utf-8', -status
=> $status);
213 <?xml version="1.0" encoding="utf-8"?>
214 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
215 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
216 <!-- git web interface v$version, (C) 2005, Kay Sievers <kay.sievers\@vrfy.org>, Christian Gierke <ch\@gierke.de> -->
218 <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
219 <meta name="robots" content="index, nofollow"/>
220 <title>$title</title>
222 <style type="text/css">
223 body { font-family: sans-serif; font-size: 12px; margin:0px; border:solid #d9d8d1; border-width:1px; margin:10px; }
225 a:hover, a:visited, a:active { color:#880000; }
226 div.page_header { height:25px; padding:8px; font-size:18px; font-weight:bold; background-color:#d9d8d1; }
227 div.page_header a:visited { color:#0000cc; }
228 div.page_header a:hover { color:#880000; }
229 div.page_nav { padding:8px; }
230 div.page_nav a:visited { color:#0000cc; }
231 div.page_path { padding:8px; border:solid #d9d8d1; border-width:0px 0px 1px}
232 div.page_footer { height:17px; padding:4px 8px; background-color: #d9d8d1; }
233 div.page_footer_text { float:left; color:#555555; font-style:italic; }
234 div.page_body { padding:8px; }
236 display:block; padding:6px 8px;
237 font-weight:bold; background-color:#edece6; text-decoration:none; color:#000000;
239 a.title:hover { background-color: #d9d8d1; }
240 div.title_text { padding:6px 0px; border: solid #d9d8d1; border-width:0px 0px 1px; }
241 div.log_body { padding:8px 8px 8px 150px; }
242 span.age { position:relative; float:left; width:142px; font-style:italic; }
245 font-size:10px; font-family:sans-serif; font-style:normal;
246 position:relative; float:left; width:136px;
248 div.list_head { padding:6px 8px 4px; border:solid #d9d8d1; border-width:1px 0px 0px; font-style:italic; }
249 a.list { text-decoration:none; color:#000000; }
250 a.list:hover { text-decoration:underline; color:#880000; }
251 table { padding:8px 4px; }
252 th { padding:2px 5px; font-size:12px; text-align:left; }
253 tr.light:hover { background-color:#edece6; }
254 tr.dark { background-color:#f6f6f0; }
255 tr.dark:hover { background-color:#edece6; }
256 td { padding:2px 5px; font-size:12px; vertical-align:top; }
257 td.link { padding:2px 5px; font-family:sans-serif; font-size:10px; }
258 div.pre { font-family:monospace; font-size:12px; white-space:pre; }
259 div.diff_info { font-family:monospace; color:#000099; background-color:#edece6; font-style:italic; }
260 div.index_include { border:solid #d9d8d1; border-width:0px 0px 1px; padding:12px 8px; }
261 div.search { margin:4px 8px; position:absolute; top:56px; right:12px }
262 a.linenr { color:#999999; text-decoration:none }
264 float:right; padding:3px 0px; width:35px; line-height:10px;
265 border:1px solid; border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e;
266 color:#ffffff; background-color:#ff6600;
267 font-weight:bold; font-family:sans-serif; font-size:10px;
268 text-align:center; text-decoration:none;
270 a.rss_logo:hover { background-color:#ee5500; }
275 print "<div class=\"page_header\">\n" .
276 "<a href=\"http://www.kernel.org/pub/software/scm/git/docs/\" title=\"git documentation\">" .
277 "<img src=\"$my_uri?a=git-logo.png\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/>" .
279 print $cgi->a({-href
=> $home_link}, "projects") . " / ";
280 if (defined $project) {
281 print $cgi->a({-href
=> "$my_uri?p=$project;a=summary"}, escapeHTML
($project));
282 if (defined $action) {
286 if (!defined $searchtext) {
289 $cgi->param("a", "search");
290 print $cgi->startform(-method
=> "get", -action
=> "$my_uri") .
291 "<div class=\"search\">\n" .
292 $cgi->hidden(-name
=> "p") . "\n" .
293 $cgi->hidden(-name
=> "a") . "\n" .
294 $cgi->textfield(-name
=> "s", -value
=> $searchtext) . "\n" .
296 $cgi->end_form() . "\n";
301 sub git_footer_html
{
302 print "<div class=\"page_footer\">\n";
303 if (defined $project) {
304 my $descr = git_read_description
($project);
305 if (defined $descr) {
306 print "<div class=\"page_footer_text\">" . escapeHTML
($descr) . "</div>\n";
308 print $cgi->a({-href
=> "$my_uri?p=$project;a=rss", -class => "rss_logo"}, "RSS") . "\n";
310 print $cgi->a({-href
=> "$my_uri?a=opml", -class => "rss_logo"}, "RSS") . "\n";
318 my $status = shift || "403 Forbidden";
319 my $error = shift || "Malformed query, file missing or permission denied";
321 git_header_html
($status);
322 print "<div class=\"page_body\">\n" .
324 "$status - $error\n" .
334 open my $fd, "-|", "$gitbin/git-cat-file -t $hash" or return;
344 open my $fd, "$projectroot/$path" or return undef;
348 if ($head =~ m/^[0-9a-fA-F]{40}$/) {
353 sub git_read_description
{
356 open my $fd, "$projectroot/$path/description" or return undef;
367 open my $fd, "-|", "$gitbin/git-cat-file tag $tag_id" or return;
368 while (my $line = <$fd>) {
370 if ($line =~ m/^object ([0-9a-fA-F]{40})$/) {
372 } elsif ($line =~ m/^type (.+)$/) {
374 } elsif ($line =~ m/^tag (.+)$/) {
379 if (!defined $tag{'name'}) {
385 sub git_read_commit
{
386 my $commit_id = shift;
387 my $commit_text = shift;
393 if (defined $commit_text) {
394 @commit_lines = @
$commit_text;
396 open my $fd, "-|", "$gitbin/git-cat-file commit $commit_id" or return;
397 @commit_lines = map { chomp; $_ } <$fd>;
400 while (my $line = shift @commit_lines) {
401 last if $line eq "\n";
402 if ($line =~ m/^tree ([0-9a-fA-F]{40})$/) {
404 } elsif ($line =~ m/^parent ([0-9a-fA-F]{40})$/) {
406 } elsif ($line =~ m/^author (.*) ([0-9]+) (.*)$/) {
408 $co{'author_epoch'} = $2;
409 $co{'author_tz'} = $3;
410 if ($co{'author'} =~ m/^([^<]+) </) {
411 $co{'author_name'} = $1;
413 $co{'author_name'} = $co{'author'};
415 } elsif ($line =~ m/^committer (.*) ([0-9]+) (.*)$/) {
416 $co{'committer'} = $1;
417 $co{'committer_epoch'} = $2;
418 $co{'committer_tz'} = $3;
419 $co{'committer_name'} = $co{'committer'};
420 $co{'committer_name'} =~ s/ <.*//;
423 if (!defined $co{'tree'}) {
426 $co{'id'} = $commit_id;
427 $co{'parents'} = \
@parents;
428 $co{'parent'} = $parents[0];
429 $co{'comment'} = \
@commit_lines;
430 foreach my $title (@commit_lines) {
432 $co{'title'} = chop_str
($title, 80);
433 # remove leading stuff of merges to make the interesting part visible
434 if (length($title) > 50) {
435 $title =~ s/^Automatic //;
436 $title =~ s/^merge (of|with) /Merge ... /i;
437 if (length($title) > 50) {
438 $title =~ s/(http|rsync):\/\///;
440 if (length($title) > 50) {
441 $title =~ s/(master|www|rsync)\.//;
443 if (length($title) > 50) {
444 $title =~ s/kernel.org:?//;
446 if (length($title) > 50) {
447 $title =~ s/\/pub\/scm//;
450 $co{'title_short'} = chop_str
($title, 50);
455 my $age = time - $co{'committer_epoch'};
457 if ($age > 60*60*24*365*2) {
458 $co{'age_string'} = (int $age/60/60/24/365);
459 $co{'age_string'} .= " years ago";
460 } elsif ($age > 60*60*24*(365/12)*2) {
461 $co{'age_string'} = int $age/60/60/24/(365/12);
462 $co{'age_string'} .= " months ago";
463 } elsif ($age > 60*60*24*7*2) {
464 $co{'age_string'} = int $age/60/60/24/7;
465 $co{'age_string'} .= " weeks ago";
466 } elsif ($age > 60*60*24*2) {
467 $co{'age_string'} = int $age/60/60/24;
468 $co{'age_string'} .= " days ago";
469 } elsif ($age > 60*60*2) {
470 $co{'age_string'} = int $age/60/60;
471 $co{'age_string'} .= " hours ago";
472 } elsif ($age > 60*2) {
473 $co{'age_string'} = int $age/60;
474 $co{'age_string'} .= " min ago";
476 $co{'age_string'} = int $age;
477 $co{'age_string'} .= " sec ago";
479 $co{'age_string'} .= " right now";
481 my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($co{'committer_epoch'});
482 if ($age > 60*60*24*7*2) {
483 $co{'age_string_date'} = sprintf "%4i-%02u-%02i", 1900 + $year, $mon+1, $mday;
484 $co{'age_string_age'} = $co{'age_string'};
486 $co{'age_string_date'} = $co{'age_string'};
487 $co{'age_string_age'} = sprintf "%4i-%02u-%02i", 1900 + $year, $mon+1, $mday;
494 my $from_name = shift;
497 my $format = shift || "html";
499 my $from_tmp = "/dev/null";
500 my $to_tmp = "/dev/null";
503 # create tmp from-file
505 $from_tmp = "$git_temp/gitweb_" . $$ . "_from";
506 open my $fd2, "> $from_tmp";
507 open my $fd, "-|", "$gitbin/git-cat-file blob $from";
516 $to_tmp = "$git_temp/gitweb_" . $$ . "_to";
517 open my $fd2, "> $to_tmp";
518 open my $fd, "-|", "$gitbin/git-cat-file blob $to";
525 open my $fd, "-|", "/usr/bin/diff -u -p -L $from_name -L $to_name $from_tmp $to_tmp";
526 if ($format eq "plain") {
531 while (my $line = <$fd>) {
533 my $char = substr($line, 0, 1);
536 $color = " style=\"color:#008800;\"";
537 } elsif ($char eq "-") {
538 $color = " style=\"color:#cc0000;\"";
539 } elsif ($char eq "@") {
540 $color = " style=\"color:#990099;\"";
541 } elsif ($char eq "\\") {
545 while ((my $pos = index($line, "\t")) != -1) {
546 if (my $count = (8 - (($pos-1) % 8))) {
547 my $spaces = ' ' x
$count;
548 $line =~ s/\t/$spaces/;
551 print "<div class=\"pre\"$color>" . escapeHTML
($line) . "</div>\n";
565 my $mode = oct shift;
567 if (S_ISDIR
($mode & S_IFMT
)) {
569 } elsif (S_ISLNK
($mode)) {
571 } elsif (S_ISREG
($mode)) {
572 # git cares only about the executable bit
573 if ($mode & S_IXUSR
) {
586 my $add_len = shift || 10;
588 $str =~ m/^(.{0,$len}[^ \/\
-_
:\
.@
]{0,$add_len})/;
590 if ($chopped ne $str) {
597 my $mode = oct shift;
599 if (S_ISDIR
($mode & S_IFMT
)) {
601 } elsif (S_ISLNK
($mode)) {
603 } elsif (S_ISREG
($mode)) {
610 sub format_log_line_html
{
613 $line = escapeHTML
($line);
614 $line =~ s/ / /g;
615 if ($line =~ m/([0-9a-fA-F]{40})/) {
617 if (git_get_type
($hash_text) eq "commit") {
618 my $link = $cgi->a({-class => "list", -href
=> "$my_uri?p=$project;a=commit;h=$hash_text"}, $hash_text);
619 $line =~ s/$hash_text/$link/;
627 my $tz = shift || "-0000";
630 my @months = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
631 my @days = ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
632 my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($epoch);
633 $date{'hour'} = $hour;
634 $date{'minute'} = $min;
635 $date{'mday'} = $mday;
636 $date{'day'} = $days[$wday];
637 $date{'month'} = $months[$mon];
638 $date{'rfc2822'} = sprintf "%s, %d %s %4d %02d:%02d:%02d +0000", $days[$wday], $mday, $months[$mon], 1900+$year, $hour ,$min, $sec;
639 $date{'mday-time'} = sprintf "%d %s %02d:%02d", $mday, $months[$mon], $hour ,$min;
641 $tz =~ m/^([+\-][0-9][0-9])([0-9][0-9])$/;
642 my $local = $epoch + ((int $1 + ($2/60)) * 3600);
643 ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($local);
644 $date{'hour_local'} = $hour;
645 $date{'minute_local'} = $min;
646 $date{'tz_local'} = $tz;
650 # git-logo (cached in browser for one day)
652 print $cgi->header(-type
=> 'image/png', -expires
=> '+1d');
653 # cat git-logo.png | hexdump -e '16/1 " %02x" "\n"' | sed 's/ /\\x/g'
654 print "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52" .
655 "\x00\x00\x00\x48\x00\x00\x00\x1b\x04\x03\x00\x00\x00\x2d\xd9\xd4" .
656 "\x2d\x00\x00\x00\x18\x50\x4c\x54\x45\xff\xff\xff\x60\x60\x5d\xb0" .
657 "\xaf\xaa\x00\x80\x00\xce\xcd\xc7\xc0\x00\x00\xe8\xe8\xe6\xf7\xf7" .
658 "\xf6\x95\x0c\xa7\x47\x00\x00\x00\x73\x49\x44\x41\x54\x28\xcf\x63" .
659 "\x48\x67\x20\x04\x4a\x5c\x18\x0a\x08\x2a\x62\x53\x61\x20\x02\x08" .
660 "\x0d\x69\x45\xac\xa1\xa1\x01\x30\x0c\x93\x60\x36\x26\x52\x91\xb1" .
661 "\x01\x11\xd6\xe1\x55\x64\x6c\x6c\xcc\x6c\x6c\x0c\xa2\x0c\x70\x2a" .
662 "\x62\x06\x2a\xc1\x62\x1d\xb3\x01\x02\x53\xa4\x08\xe8\x00\x03\x18" .
663 "\x26\x56\x11\xd4\xe1\x20\x97\x1b\xe0\xb4\x0e\x35\x24\x71\x29\x82" .
664 "\x99\x30\xb8\x93\x0a\x11\xb9\x45\x88\xc1\x8d\xa0\xa2\x44\x21\x06" .
665 "\x27\x41\x82\x40\x85\xc1\x45\x89\x20\x70\x01\x00\xa4\x3d\x21\xc5" .
666 "\x12\x1c\x9a\xfe\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82";
672 my ($dev, $ino, $mode, $nlink, $st_uid, $st_gid, $rdev, $size) = stat($path);
673 my ($name, $passwd, $uid, $gid, $quota, $comment, $gcos, $dir, $shell) = getpwuid($st_uid);
674 if (!defined $gcos) {
678 $owner =~ s/[,;].*$//;
682 sub git_read_projects
{
685 if (-d
$projects_list) {
686 # search in directory
687 my $dir = $projects_list;
688 opendir my $dh, $dir or return undef;
689 while (my $dir = readdir($dh)) {
690 if (-e
"$projectroot/$dir/HEAD") {
698 } elsif (-f
$projects_list) {
699 # read from file(url-encoded):
700 # 'git%2Fgit.git Linus+Torvalds'
701 # 'libs%2Fklibc%2Fklibc.git H.+Peter+Anvin'
702 # 'linux%2Fhotplug%2Fudev.git Greg+Kroah-Hartman'
703 open my $fd , $projects_list or return undef;
704 while (my $line = <$fd>) {
706 my ($path, $owner) = split ' ', $line;
707 $path = unescape
($path);
708 $owner = unescape
($owner);
709 if (!defined $path) {
712 if (-e
"$projectroot/$path/HEAD") {
722 @list = sort {$a->{'path'} cmp $b->{'path'}} @list;
726 sub git_project_list
{
727 my @list = git_read_projects
();
729 die_error
(undef, "No project found.");
733 print "<div class=\"index_include\">\n";
734 open (my $fd, $home_text);
739 print "<table cellspacing=\"0\">\n" .
741 "<th>Project</th>\n" .
742 "<th>Description</th>\n" .
744 "<th>last change</th>\n" .
748 foreach my $pr (@list) {
750 my $head = git_read_hash
("$proj{'path'}/HEAD");
751 if (!defined $head) {
754 $ENV{'GIT_DIR'} = "$projectroot/$proj{'path'}";
755 my %co = git_read_commit
($head);
759 my $descr = git_read_description
($proj{'path'}) || "";
760 $descr = chop_str
($descr, 25, 5);
761 # get directory owner if not already specified
762 if (!defined $proj{'owner'}) {
763 $proj{'owner'} = get_file_owner
("$projectroot/$proj{'path'}") || "";
766 print "<tr class=\"dark\">\n";
768 print "<tr class=\"light\">\n";
771 print "<td>" . $cgi->a({-href
=> "$my_uri?p=$proj{'path'};a=summary", -class => "list"}, escapeHTML
($proj{'path'})) . "</td>\n" .
772 "<td>$descr</td>\n" .
773 "<td><i>" . chop_str
($proj{'owner'}, 15) . "</i></td>\n";
775 if ($co{'age'} < 60*60*2) {
776 $colored_age = "<span style =\"color: #009900;\"><b><i>$co{'age_string'}</i></b></span>";
777 } elsif ($co{'age'} < 60*60*24*2) {
778 $colored_age = "<span style =\"color: #009900;\"><i>$co{'age_string'}</i></span>";
780 $colored_age = "<i>$co{'age_string'}</i>";
782 print "<td>$colored_age</td>\n" .
783 "<td class=\"link\">" .
784 $cgi->a({-href
=> "$my_uri?p=$proj{'path'};a=summary"}, "summary") .
785 " | " . $cgi->a({-href
=> "$my_uri?p=$proj{'path'};a=shortlog"}, "shortlog") .
786 " | " . $cgi->a({-href
=> "$my_uri?p=$proj{'path'};a=log"}, "log") .
799 opendir my $dh, "$projectroot/$project/$ref_dir";
800 while (my $dir = readdir($dh)) {
801 if ($dir =~ m/^\./) {
804 if (-d
"$projectroot/$project/$ref_dir/$dir") {
805 opendir my $dh2, "$projectroot/$project/$ref_dir/$dir";
806 my @subdirs = grep !m/^\./, readdir $dh2;
808 foreach my $subdir (@subdirs) {
809 push @refs, "$dir/$subdir"
816 foreach my $ref_file (@refs) {
817 my $ref_id = git_read_hash
("$project/$ref_dir/$ref_file");
818 my $type = git_get_type
($ref_id) || next;
821 if ($type eq "tag") {
822 my %tag = git_read_tag
($ref_id);
823 if ($tag{'type'} eq "commit") {
824 %co = git_read_commit
($tag{'object'});
826 $ref_item{'type'} = $tag{'type'};
827 $ref_item{'name'} = $tag{'name'};
828 $ref_item{'id'} = $tag{'object'};
829 } elsif ($type eq "commit"){
830 %co = git_read_commit
($ref_id);
831 $ref_item{'type'} = "commit";
832 $ref_item{'name'} = $ref_file;
833 $ref_item{'title'} = $co{'title'};
834 $ref_item{'id'} = $ref_id;
836 $ref_item{'epoch'} = $co{'committer_epoch'} || 0;
837 $ref_item{'age'} = $co{'age_string'} || "unknown";
839 push @reflist, \
%ref_item;
842 @reflist = sort {$b->{'epoch'} <=> $a->{'epoch'}} @reflist;
847 my $descr = git_read_description
($project) || "none";
848 my $head = git_read_hash
("$project/HEAD");
849 my %co = git_read_commit
($head);
850 my %cd = date_str
($co{'committer_epoch'}, $co{'committer_tz'});
853 if (-f
$projects_list) {
854 open (my $fd , $projects_list);
855 while (my $line = <$fd>) {
857 my ($pr, $ow) = split ' ', $line;
860 if ($pr eq $project) {
867 if (!defined $owner) {
868 $owner = get_file_owner
("$projectroot/$project");
872 print "<div class=\"page_nav\">\n" .
874 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=shortlog"}, "shortlog") .
875 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=log"}, "log") .
876 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$head"}, "commit") .
877 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=commitdiff;h=$head"}, "commitdiff") .
878 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=tree"}, "tree") .
881 print "<div class=\"title\"> </div>\n";
882 print "<table cellspacing=\"0\">\n" .
883 "<tr><td>description</td><td>" . escapeHTML
($descr) . "</td></tr>\n" .
884 "<tr><td>owner</td><td>$owner</td></tr>\n" .
885 "<tr><td>last change</td><td>$cd{'rfc2822'}</td></tr>\n" .
887 open my $fd, "-|", "$gitbin/git-rev-list --max-count=17 " . git_read_hash
("$project/HEAD") or die_error
(undef, "Open failed.");
888 my (@revlist) = map { chomp; $_ } <$fd>;
891 $cgi->a({-href
=> "$my_uri?p=$project;a=shortlog", -class => "title"}, "shortlog") .
894 print "<table cellspacing=\"0\">\n";
896 foreach my $commit (@revlist) {
897 my %co = git_read_commit
($commit);
898 my %ad = date_str
($co{'author_epoch'});
900 print "<tr class=\"dark\">\n";
902 print "<tr class=\"light\">\n";
906 print "<td><i>$co{'age_string'}</i></td>\n" .
907 "<td><i>" . escapeHTML
(chop_str
($co{'author_name'}, 10)) . "</i></td>\n" .
909 $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$commit", -class => "list"},
910 "<b>" . escapeHTML
($co{'title_short'}) . "</b>") .
912 "<td class=\"link\">" .
913 $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$commit"}, "commit") .
914 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=commitdiff;h=$commit"}, "commitdiff") .
918 print "<td>" . $cgi->a({-href
=> "$my_uri?p=$project;a=shortlog"}, "...") . "</td>\n" .
925 my $taglist = git_read_refs
("refs/tags");
926 if (defined @
$taglist) {
928 $cgi->a({-href
=> "$my_uri?p=$project;a=tags", -class => "title"}, "tags") .
931 print "<table cellspacing=\"0\">\n";
933 foreach my $entry (@
$taglist) {
936 print "<tr class=\"dark\">\n";
938 print "<tr class=\"light\">\n";
942 print "<td><i>$tag{'age'}</i></td>\n" .
944 $cgi->a({-href
=> "$my_uri?p=$project;a=$tag{'type'};h=$tag{'id'}", -class => "list"}, "<b>" .
945 escapeHTML
($tag{'name'}) . "</b>") .
947 "<td class=\"link\">" .
948 $cgi->a({-href
=> "$my_uri?p=$project;a=$tag{'type'};h=$tag{'id'}"}, $tag{'type'});
949 if ($tag{'type'} eq "commit") {
950 print " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=shortlog;h=$tag{'id'}"}, "shortlog") .
951 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=log;h=$tag{'id'}"}, "log");
956 print "<td>" . $cgi->a({-href
=> "$my_uri?p=$project;a=tags"}, "...") . "</td>\n" .
964 my $branchlist = git_read_refs
("refs/heads");
965 if (defined @
$branchlist) {
967 $cgi->a({-href
=> "$my_uri?p=$project;a=branches", -class => "title"}, "branches") .
970 print "<table cellspacing=\"0\">\n";
972 foreach my $entry (@
$branchlist) {
975 print "<tr class=\"dark\">\n";
977 print "<tr class=\"light\">\n";
981 print "<td><i>$tag{'age'}</i></td>\n" .
983 $cgi->a({-href
=> "$my_uri?p=$project;a=shortlog;h=$tag{'name'}", -class => "list"},
984 "<b>" . escapeHTML
($tag{'name'}) . "</b>") .
986 "<td class=\"link\">" .
987 $cgi->a({-href
=> "$my_uri?p=$project;a=shortlog;h=$tag{'name'}"}, "shortlog") .
988 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=log;h=$tag{'name'}"}, "log") .
992 print "<td>" . $cgi->a({-href
=> "$my_uri?p=$project;a=branches"}, "...") . "</td>\n" .
1003 my $head = git_read_hash
("$project/HEAD");
1005 print "<div class=\"page_nav\">\n" .
1006 $cgi->a({-href
=> "$my_uri?p=$project;a=summary"}, "summary") .
1007 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=shortlog"}, "shortlog") .
1008 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=log"}, "log") .
1009 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$head"}, "commit") .
1010 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=commitdiff;h=$head"}, "commitdiff") .
1011 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=tree;hb=$head"}, "tree") . "<br/>\n" .
1014 my $taglist = git_read_refs
("refs/tags");
1016 $cgi->a({-href
=> "$my_uri?p=$project;a=summary", -class => "title"}, " ") .
1018 print "<table cellspacing=\"0\">\n";
1020 if (defined @
$taglist) {
1021 foreach my $entry (@
$taglist) {
1024 print "<tr class=\"dark\">\n";
1026 print "<tr class=\"light\">\n";
1029 print "<td><i>$tag{'age'}</i></td>\n" .
1031 $cgi->a({-href
=> "$my_uri?p=$project;a=shortlog;h=$tag{'id'}", -class => "list"},
1032 "<b>" . escapeHTML
($tag{'name'}) . "</b>") .
1034 "<td class=\"link\">" .
1035 $cgi->a({-href
=> "$my_uri?p=$project;a=$tag{'type'};h=$tag{'id'}"}, $tag{'type'});
1036 if ($tag{'type'} eq "commit") {
1037 print " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=shortlog;h=$tag{'name'}"}, "shortlog") .
1038 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=log;h=$tag{'id'}"}, "log");
1049 my $head = git_read_hash
("$project/HEAD");
1051 print "<div class=\"page_nav\">\n" .
1052 $cgi->a({-href
=> "$my_uri?p=$project;a=summary"}, "summary") .
1053 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=shortlog"}, "shortlog") .
1054 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=log"}, "log") .
1055 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$head"}, "commit") .
1056 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=commitdiff;h=$head"}, "commitdiff") .
1057 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=tree;hb=$head"}, "tree") . "<br/>\n" .
1060 my $taglist = git_read_refs
("refs/heads");
1062 $cgi->a({-href
=> "$my_uri?p=$project;a=summary", -class => "title"}, " ") .
1064 print "<table cellspacing=\"0\">\n";
1066 if (defined @
$taglist) {
1067 foreach my $entry (@
$taglist) {
1070 print "<tr class=\"dark\">\n";
1072 print "<tr class=\"light\">\n";
1075 print "<td><i>$tag{'age'}</i></td>\n" .
1077 $cgi->a({-href
=> "$my_uri?p=$project;a=shortlog;h=$tag{'name'}", -class => "list"}, "<b>" . escapeHTML
($tag{'name'}) . "</b>") .
1079 "<td class=\"link\">" .
1080 $cgi->a({-href
=> "$my_uri?p=$project;a=shortlog;h=$tag{'name'}"}, "shortlog") .
1081 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=log;h=$tag{'name'}"}, "log") .
1090 sub git_get_hash_by_path
{
1092 my $path = shift || return undef;
1095 my @parts = split '/', $path;
1096 while (my $part = shift @parts) {
1097 open my $fd, "-|", "$gitbin/git-ls-tree $tree" or die_error
(undef, "Open git-ls-tree failed.");
1098 my (@entries) = map { chomp; $_ } <$fd>;
1099 close $fd or return undef;
1100 foreach my $line (@entries) {
1101 #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c'
1102 $line =~ m/^([0-9]+) (.+) ([0-9a-fA-F]{40})\t(.+)$/;
1107 if ($t_name eq $part) {
1111 if ($t_type eq "tree") {
1121 if (!defined $hash && defined $file_name) {
1122 my $base = $hash_base || git_read_hash
("$project/HEAD");
1123 $hash = git_get_hash_by_path
($base, $file_name, "blob");
1125 open my $fd, "-|", "$gitbin/git-cat-file blob $hash" or die_error
(undef, "Open failed.");
1126 my $base = $file_name || "";
1128 if (defined $hash_base && (my %co = git_read_commit
($hash_base))) {
1129 print "<div class=\"page_nav\">\n" .
1130 $cgi->a({-href
=> "$my_uri?p=$project;a=summary"}, "summary") .
1131 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=shortlog"}, "shortlog") .
1132 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=log"}, "log") .
1133 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") .
1134 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "commitdiff") .
1135 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash_base"}, "tree") . "<br/>\n";
1136 print $cgi->a({-href
=> "$my_uri?p=$project;a=blob_plain;h=$hash"}, "plain") . "<br/>\n" .
1139 $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$hash_base", -class => "title"}, escapeHTML
($co{'title'})) .
1142 print "<div class=\"page_nav\">\n" .
1143 "<br/><br/></div>\n" .
1144 "<div class=\"title\">$hash</div>\n";
1146 if (defined $file_name) {
1147 print "<div class=\"page_path\"><b>$file_name</b></div>\n";
1149 print "<div class=\"page_body\">\n";
1151 while (my $line = <$fd>) {
1154 while ((my $pos = index($line, "\t")) != -1) {
1155 if (my $count = (8 - ($pos % 8))) {
1156 my $spaces = ' ' x
$count;
1157 $line =~ s/\t/$spaces/;
1160 printf "<div class=\"pre\"><a id=\"l%i\" href=\"#l%i\" class=\"linenr\">%4i</a> %s</div>\n", $nr, $nr, $nr, escapeHTML
($line);
1162 close $fd or print "Reading blob failed.\n";
1167 sub git_blob_plain
{
1168 print $cgi->header(-type
=> "text/plain", -charset
=> 'utf-8');
1169 open my $fd, "-|", "$gitbin/git-cat-file blob $hash" or return;
1177 if (!defined $hash) {
1178 $hash = git_read_hash
("$project/HEAD");
1179 if (defined $file_name) {
1180 my $base = $hash_base || git_read_hash
("$project/HEAD");
1181 $hash = git_get_hash_by_path
($base, $file_name, "tree");
1183 if (!defined $hash_base) {
1184 $hash_base = git_read_hash
("$project/HEAD");
1187 open my $fd, "-|", "$gitbin/git-ls-tree $hash" or die_error
(undef, "Open git-ls-tree failed.");
1188 my (@entries) = map { chomp; $_ } <$fd>;
1189 close $fd or die_error
(undef, "Reading tree failed.");
1195 if (defined $hash_base && (my %co = git_read_commit
($hash_base))) {
1196 $base_key = ";hb=$hash_base";
1197 print "<div class=\"page_nav\">\n" .
1198 $cgi->a({-href
=> "$my_uri?p=$project;a=summary"}, "summary") .
1199 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=shortlog;h=$hash_base"}, "shortlog") .
1200 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=log;h=$hash_base"}, "log") .
1201 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") .
1202 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "commitdiff") .
1207 $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$hash_base", -class => "title"}, escapeHTML
($co{'title'})) . "\n" .
1210 print "<div class=\"page_nav\">\n";
1211 print "<br/><br/></div>\n";
1212 print "<div class=\"title\">$hash</div>\n";
1214 if (defined $file_name) {
1215 $base = "$file_name/";
1216 print "<div class=\"page_path\"><b>/$file_name</b></div>\n";
1218 print "<div class=\"page_path\"><b>/</b></div>\n";
1220 print "<div class=\"page_body\">\n";
1221 print "<table cellspacing=\"0\">\n";
1223 foreach my $line (@entries) {
1224 #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c'
1225 $line =~ m/^([0-9]+) (.+) ([0-9a-fA-F]{40})\t(.+)$/;
1230 $file_key = ";f=$base$t_name";
1232 print "<tr class=\"dark\">\n";
1234 print "<tr class=\"light\">\n";
1237 print "<td style=\"font-family:monospace\">" . mode_str
($t_mode) . "</td>\n";
1238 if ($t_type eq "blob") {
1239 print "<td class=\"list\">" .
1240 $cgi->a({-href
=> "$my_uri?p=$project;a=blob;h=$t_hash" . $base_key . $file_key, -class => "list"}, $t_name) .
1242 "<td class=\"link\">" .
1243 $cgi->a({-href
=> "$my_uri?p=$project;a=blob;h=$t_hash" . $base_key . $file_key}, "blob") .
1244 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=history;h=$hash_base" . $file_key}, "history") .
1246 } elsif ($t_type eq "tree") {
1247 print "<td class=\"list\">" .
1248 $cgi->a({-href
=> "$my_uri?p=$project;a=tree;h=$t_hash" . $base_key . $file_key}, $t_name) .
1250 "<td class=\"link\">" .
1251 $cgi->a({-href
=> "$my_uri?p=$project;a=tree;h=$t_hash" . $base_key . $file_key}, "tree") .
1256 print "</table>\n" .
1262 # http://www.notestips.com/80256B3A007F2692/1/NAMO5P9UPQ
1263 open my $fd, "-|", "$gitbin/git-rev-list --max-count=20 " . git_read_hash
("$project/HEAD") or die_error
(undef, "Open failed.");
1264 my (@revlist) = map { chomp; $_ } <$fd>;
1265 close $fd or die_error
(undef, "Reading rev-list failed.");
1267 print $cgi->header(-type
=> 'text/xml', -charset
=> 'utf-8');
1268 print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n".
1269 "<rss version=\"2.0\" xmlns:content=\"http://purl.org/rss/1.0/modules/content/\">\n";
1270 print "<channel>\n";
1271 print "<title>$project</title>\n".
1272 "<link>" . escapeHTML
("$my_url?p=$project;a=summary") . "</link>\n".
1273 "<description>$project log</description>\n".
1274 "<language>en</language>\n";
1276 foreach my $commit (@revlist) {
1277 my %co = git_read_commit
($commit);
1278 my %cd = date_str
($co{'committer_epoch'});
1281 sprintf("%d %s %02d:%02d", $cd{'mday'}, $cd{'month'}, $cd{'hour'}, $cd{'minute'}) . " - " . escapeHTML
($co{'title'}) .
1283 "<pubDate>$cd{'rfc2822'}</pubDate>\n" .
1284 "<link>" . escapeHTML
("$my_url?p=$project;a=commit;h=$commit") . "</link>\n" .
1285 "<description>" . escapeHTML
($co{'title'}) . "</description>\n" .
1286 "<content:encoded>" .
1288 my $comment = $co{'comment'};
1289 foreach my $line (@
$comment) {
1290 print "$line<br/>\n";
1293 "</content:encoded>\n" .
1296 print "</channel></rss>";
1300 my @list = git_read_projects
();
1302 print $cgi->header(-type
=> 'text/xml', -charset
=> 'utf-8');
1303 print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n".
1304 "<opml version=\"1.0\">\n".
1306 " <title>Git OPML Export</title>\n".
1309 "<outline text=\"git RSS feeds\">\n";
1311 foreach my $pr (@list) {
1313 my $head = git_read_hash
("$proj{'path'}/HEAD");
1314 if (!defined $head) {
1317 $ENV{'GIT_DIR'} = "$projectroot/$proj{'path'}";
1318 my %co = git_read_commit
($head);
1323 my $path = escapeHTML
(chop_str
($proj{'path'}, 25, 5));
1324 my $rss = "$my_url?p=$proj{'path'};a=rss";
1325 my $html = "$my_url?p=$proj{'path'};a=summary";
1326 print "<outline type=\"rss\" text=\"$path\" title=\"$path\" xmlUrl=\"$rss\" htmlUrl=\"$html\"/>\n";
1328 print "</outline>\n".
1334 my $head = git_read_hash
("$project/HEAD");
1335 if (!defined $hash) {
1338 if (!defined $page) {
1342 print "<div class=\"page_nav\">\n";
1343 print $cgi->a({-href
=> "$my_uri?p=$project;a=summary"}, "summary") .
1344 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=shortlog;h=$hash"}, "shortlog") .
1346 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$hash"}, "commit") .
1347 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff") .
1348 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=tree;h=$hash;hb=$hash"}, "tree") . "<br/>\n";
1350 my $limit = sprintf("--max-count=%i", (100 * ($page+1)));
1351 open my $fd, "-|", "$gitbin/git-rev-list $limit $hash" or die_error
(undef, "Open failed.");
1352 my (@revlist) = map { chomp; $_ } <$fd>;
1355 if ($hash ne $head || $page) {
1356 print $cgi->a({-href
=> "$my_uri?p=$project;a=log"}, "HEAD");
1362 $cgi->a({-href
=> "$my_uri?p=$project;a=log;h=$hash;pg=" . ($page-1), -accesskey
=> "p", -title
=> "Alt-p"}, "prev");
1364 print " ⋅ prev";
1366 if ($#revlist >= (100 * ($page+1)-1)) {
1368 $cgi->a({-href
=> "$my_uri?p=$project;a=log;h=$hash;pg=" . ($page+1), -accesskey
=> "n", -title
=> "Alt-n"}, "next");
1370 print " ⋅ next";
1376 $cgi->a({-href
=> "$my_uri?p=$project;a=summary", -class => "title"}, " ") .
1378 my %co = git_read_commit
($hash);
1379 print "<div class=\"page_body\"> Last change $co{'age_string'}.<br/><br/></div>\n";
1381 for (my $i = ($page * 100); $i <= $#revlist; $i++) {
1382 my $commit = $revlist[$i];
1383 my %co = git_read_commit
($commit);
1385 my %ad = date_str
($co{'author_epoch'});
1387 $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$commit", -class => "title"},
1388 "<span class=\"age\">$co{'age_string'}</span>" . escapeHTML
($co{'title'})) . "\n" .
1390 print "<div class=\"title_text\">\n" .
1391 "<div class=\"log_link\">\n" .
1392 $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$commit"}, "commit") .
1393 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=commitdiff;h=$commit"}, "commitdiff") .
1396 "<i>" . escapeHTML
($co{'author_name'}) . " [$ad{'rfc2822'}]</i><br/>\n" .
1398 "<div class=\"log_body\">\n";
1399 my $comment = $co{'comment'};
1401 foreach my $line (@
$comment) {
1402 if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
1413 print format_log_line_html
($line) . "<br/>\n";
1424 my %co = git_read_commit
($hash);
1426 die_error
(undef, "Unknown commit object.");
1428 my %ad = date_str
($co{'author_epoch'}, $co{'author_tz'});
1429 my %cd = date_str
($co{'committer_epoch'}, $co{'committer_tz'});
1433 if (!defined $co{'parent'}) {
1436 open my $fd, "-|", "$gitbin/git-diff-tree -r -M $root $co{'parent'} $hash" or die_error
(undef, "Open failed.");
1437 @difftree = map { chomp; $_ } <$fd>;
1438 close $fd or die_error
(undef, "Reading diff-tree failed.");
1440 print "<div class=\"page_nav\">\n" .
1441 $cgi->a({-href
=> "$my_uri?p=$project;a=summary"}, "summary") .
1442 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=shortlog;h=$hash"}, "shortlog") .
1443 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=log;h=$hash"}, "log") .
1445 if (defined $co{'parent'}) {
1446 print " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff");
1448 print " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, "tree") . "\n" .
1449 "<br/><br/></div>\n";
1450 if (defined $co{'parent'}) {
1452 $cgi->a({-href
=> "$my_uri?p=$project;a=commitdiff;h=$hash", -class => "title"}, escapeHTML
($co{'title'})) . "\n" .
1456 $cgi->a({-href
=> "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash", -class => "title"}, escapeHTML
($co{'title'})) . "\n" .
1459 print "<div class=\"title_text\">\n" .
1460 "<table cellspacing=\"0\">\n";
1461 print "<tr><td>author</td><td>" . escapeHTML
($co{'author'}) . "</td></tr>\n".
1463 "<td></td><td> $ad{'rfc2822'}";
1464 if ($ad{'hour_local'} < 6) {
1465 printf(" (<span style=\"color: #cc0000;\">%02d:%02d</span> %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
1467 printf(" (%02d:%02d %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
1471 print "<tr><td>committer</td><td>" . escapeHTML
($co{'committer'}) . "</td></tr>\n";
1472 print "<tr><td></td><td> $cd{'rfc2822'}" . sprintf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}) . "</td></tr>\n";
1473 print "<tr><td>commit</td><td style=\"font-family:monospace\">$hash</td></tr>\n";
1476 "<td style=\"font-family:monospace\">" .
1477 $cgi->a({-href
=> "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash", class => "list"}, $co{'tree'}) .
1479 "<td class=\"link\">" . $cgi->a({-href
=> "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, "tree") .
1482 my $parents = $co{'parents'};
1483 foreach my $par (@
$parents) {
1486 "<td style=\"font-family:monospace\">" . $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$par", class => "list"}, $par) . "</td>" .
1487 "<td class=\"link\">" .
1488 $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$par"}, "commit") .
1489 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=commitdiff;h=$hash;hp=$par"}, "commitdiff") .
1495 print "<div class=\"page_body\">\n";
1496 my $comment = $co{'comment'};
1499 foreach my $line (@
$comment) {
1500 # print only one empty line
1502 if ($empty || $signed) {
1509 if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
1511 print "<span style=\"color: #888888\">" . escapeHTML
($line) . "</span><br/>\n";
1514 print format_log_line_html
($line) . "<br/>\n";
1518 print "<div class=\"list_head\">\n";
1519 if ($#difftree > 10) {
1520 print(($#difftree + 1) . " files changed:\n");
1523 print "<table cellspacing=\"0\">\n";
1525 foreach my $line (@difftree) {
1526 # ':100644 100644 03b218260e99b78c6df0ed378e59ed9205ccc96d 3b93d5e7cc7f7dd4ebed13a5cc1a4ad976fc94d8 M ls-files.c'
1527 # ':100644 100644 7f9281985086971d3877aca27704f2aaf9c448ce bc190ebc71bbd923f2b728e505408f5e54bd073a M rev-tree.c'
1528 $line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)([0-9]{0,3})\t(.*)$/;
1534 my $similarity = $6;
1536 #print "$line ($status)<br/>\n";
1538 print "<tr class=\"dark\">\n";
1540 print "<tr class=\"light\">\n";
1543 if ($status eq "A") {
1545 if (S_ISREG
(oct $to_mode)) {
1546 $mode_chng = sprintf(" with mode: %04o", (oct $to_mode) & 0777);
1549 $cgi->a({-href
=> "$my_uri?p=$project;a=blob;h=$to_id;hp=$hash;f=$file", -class => "list"}, escapeHTML
($file)) . "</td>\n" .
1550 "<td><span style=\"color: #008000;\">[new " . file_type
($to_mode) . "$mode_chng]</span></td>\n" .
1551 "<td class=\"link\">" . $cgi->a({-href
=> "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"}, "blob") . "</td>\n";
1552 } elsif ($status eq "D") {
1554 $cgi->a({-href
=> "$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file", -class => "list"}, escapeHTML
($file)) . "</td>\n" .
1555 "<td><span style=\"color: #c00000;\">[deleted " . file_type
($from_mode). "]</span></td>\n" .
1556 "<td class=\"link\">" .
1557 $cgi->a({-href
=> "$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file"}, "blob") .
1558 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") .
1560 } elsif ($status eq "M" || $status eq "T") {
1561 my $mode_chnge = "";
1562 if ($from_mode != $to_mode) {
1563 $mode_chnge = " <span style=\"color: #777777;\">[changed";
1564 if (((oct $from_mode) & S_IFMT
) != ((oct $to_mode) & S_IFMT
)) {
1565 $mode_chnge .= " from " . file_type
($from_mode) . " to " . file_type
($to_mode);
1567 if (((oct $from_mode) & 0777) != ((oct $to_mode) & 0777)) {
1568 if (S_ISREG
($from_mode) && S_ISREG
($to_mode)) {
1569 $mode_chnge .= sprintf(" mode: %04o->%04o", (oct $from_mode) & 0777, (oct $to_mode) & 0777);
1570 } elsif (S_ISREG
($to_mode)) {
1571 $mode_chnge .= sprintf(" mode: %04o", (oct $to_mode) & 0777);
1574 $mode_chnge .= "]</span>\n";
1577 if ($to_id ne $from_id) {
1578 print $cgi->a({-href
=> "$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file", -class => "list"}, escapeHTML
($file));
1580 print $cgi->a({-href
=> "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file", -class => "list"}, escapeHTML
($file));
1583 "<td>$mode_chnge</td>\n" .
1584 "<td class=\"link\">";
1585 print $cgi->a({-href
=> "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"}, "blob");
1586 if ($to_id ne $from_id) {
1587 print " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file"}, "diff");
1589 print " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . "\n";
1591 } elsif ($status eq "R") {
1592 my ($from_file, $to_file) = split "\t", $file;
1594 if ($from_mode != $to_mode) {
1595 $mode_chng = sprintf(", mode: %04o", (oct $to_mode) & 0777);
1598 $cgi->a({-href
=> "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$to_file", -class => "list"}, escapeHTML
($to_file)) . "</td>\n" .
1599 "<td><span style=\"color: #777777;\">[moved from " .
1600 $cgi->a({-href
=> "$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$from_file", -class => "list"}, escapeHTML
($from_file)) .
1601 " with " . (int $similarity) . "% similarity$mode_chng]</span></td>\n" .
1602 "<td class=\"link\">" .
1603 $cgi->a({-href
=> "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$to_file"}, "blob");
1604 if ($to_id ne $from_id) {
1605 print " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$to_file"}, "diff");
1616 mkdir($git_temp, 0700);
1618 if (defined $hash_base && (my %co = git_read_commit
($hash_base))) {
1619 print "<div class=\"page_nav\">\n" .
1620 $cgi->a({-href
=> "$my_uri?p=$project;a=summary"}, "summary") .
1621 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=shortlog"}, "shortlog") .
1622 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=log"}, "log") .
1623 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") .
1624 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "commitdiff") .
1625 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash_base"}, "tree") .
1627 print $cgi->a({-href
=> "$my_uri?p=$project;a=blobdiff_plain;h=$hash;hp=$hash_parent"}, "plain") .
1630 $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$hash_base", -class => "title"}, escapeHTML
($co{'title'})) . "\n" .
1633 print "<div class=\"page_nav\">\n" .
1634 "<br/><br/></div>\n" .
1635 "<div class=\"title\">$hash vs $hash_parent</div>\n";
1637 if (defined $file_name) {
1638 print "<div class=\"page_path\"><b>/$file_name</b></div>\n";
1640 print "<div class=\"page_body\">\n" .
1641 "<div class=\"diff_info\">blob:" .
1642 $cgi->a({-href
=> "$my_uri?p=$project;a=blob;h=$hash_parent;hb=$hash_base;f=$file_name"}, $hash_parent) .
1644 $cgi->a({-href
=> "$my_uri?p=$project;a=blob;h=$hash;hb=$hash_base;f=$file_name"}, $hash) .
1646 git_diff_print
($hash_parent, $file_name || $hash_parent, $hash, $file_name || $hash);
1651 sub git_blobdiff_plain
{
1652 mkdir($git_temp, 0700);
1653 print $cgi->header(-type
=> "text/plain", -charset
=> 'utf-8');
1654 git_diff_print
($hash_parent, $file_name || $hash_parent, $hash, $file_name || $hash, "plain");
1657 sub git_commitdiff
{
1658 mkdir($git_temp, 0700);
1659 my %co = git_read_commit
($hash);
1661 die_error
(undef, "Unknown commit object.");
1663 if (!defined $hash_parent) {
1664 $hash_parent = $co{'parent'};
1666 open my $fd, "-|", "$gitbin/git-diff-tree -r $hash_parent $hash" or die_error
(undef, "Open failed.");
1667 my (@difftree) = map { chomp; $_ } <$fd>;
1668 close $fd or die_error
(undef, "Reading diff-tree failed.");
1671 print "<div class=\"page_nav\">\n" .
1672 $cgi->a({-href
=> "$my_uri?p=$project;a=summary"}, "summary") .
1673 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=shortlog;h=$hash"}, "shortlog") .
1674 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=log;h=$hash"}, "log") .
1675 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$hash"}, "commit") .
1677 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, "tree") . "<br/>\n";
1678 print $cgi->a({-href
=> "$my_uri?p=$project;a=commitdiff_plain;h=$hash;hp=$hash_parent"}, "plain") . "\n" .
1681 $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML
($co{'title'})) . "\n" .
1683 print "<div class=\"page_body\">\n";
1684 my $comment = $co{'comment'};
1687 my @log = @
$comment;
1688 # remove first and empty lines after that
1690 while (defined $log[0] && $log[0] eq "") {
1693 foreach my $line (@log) {
1694 if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
1705 print format_log_line_html
($line) . "<br/>\n";
1708 foreach my $line (@difftree) {
1709 # ':100644 100644 03b218260e99b78c6df0ed378e59ed9205ccc96d 3b93d5e7cc7f7dd4ebed13a5cc1a4ad976fc94d8 M ls-files.c'
1710 # ':100644 100644 7f9281985086971d3877aca27704f2aaf9c448ce bc190ebc71bbd923f2b728e505408f5e54bd073a M rev-tree.c'
1711 $line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$/;
1718 if ($status eq "A") {
1719 print "<div class=\"diff_info\">" . file_type
($to_mode) . ":" .
1720 $cgi->a({-href
=> "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"}, $to_id) . "(new)" .
1722 git_diff_print
(undef, "/dev/null", $to_id, "b/$file");
1723 } elsif ($status eq "D") {
1724 print "<div class=\"diff_info\">" . file_type
($from_mode) . ":" .
1725 $cgi->a({-href
=> "$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file"}, $from_id) . "(deleted)" .
1727 git_diff_print
($from_id, "a/$file", undef, "/dev/null");
1728 } elsif ($status eq "M") {
1729 if ($from_id ne $to_id) {
1730 print "<div class=\"diff_info\">" .
1731 file_type
($from_mode) . ":" . $cgi->a({-href
=> "$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file"}, $from_id) .
1733 file_type
($to_mode) . ":" . $cgi->a({-href
=> "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"}, $to_id);
1735 git_diff_print
($from_id, "a/$file", $to_id, "b/$file");
1744 sub git_commitdiff_plain
{
1745 mkdir($git_temp, 0700);
1746 open my $fd, "-|", "$gitbin/git-diff-tree -r $hash_parent $hash" or die_error
(undef, "Open failed.");
1747 my (@difftree) = map { chomp; $_ } <$fd>;
1748 close $fd or die_error
(undef, "Reading diff-tree failed.");
1750 # try to figure out the next tag after this commit
1753 my $tags = git_read_refs
("refs/tags");
1754 foreach my $entry (@
$tags) {
1756 $taghash{$tag{'id'}} = $tag{'name'};
1758 open $fd, "-|", "$gitbin/git-rev-list HEAD";
1759 while (my $commit = <$fd>) {
1761 if ($taghash{$commit}) {
1762 $tagname = $taghash{$commit};
1764 if ($commit eq $hash) {
1770 print $cgi->header(-type
=> "text/plain", -charset
=> 'utf-8');
1771 my %co = git_read_commit
($hash);
1772 my %ad = date_str
($co{'author_epoch'}, $co{'author_tz'});
1773 my $comment = $co{'comment'};
1774 print "From: $co{'author'}\n" .
1775 "Date: $ad{'rfc2822'} ($ad{'tz_local'})\n".
1776 "Subject: $co{'title'}\n";
1777 if (defined $tagname) {
1778 print "X-Git-Tag: $tagname\n";
1780 print "X-Git-Url: $my_url?p=$project;a=commitdiff;h=$hash\n" .
1783 foreach my $line (@
$comment) {;
1788 foreach my $line (@difftree) {
1789 $line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$/;
1794 if ($status eq "A") {
1795 git_diff_print
(undef, "/dev/null", $to_id, "b/$file", "plain");
1796 } elsif ($status eq "D") {
1797 git_diff_print
($from_id, "a/$file", undef, "/dev/null", "plain");
1798 } elsif ($status eq "M") {
1799 git_diff_print
($from_id, "a/$file", $to_id, "b/$file", "plain");
1805 if (!defined $hash) {
1806 $hash = git_read_hash
("$project/HEAD");
1808 my %co = git_read_commit
($hash);
1810 die_error
(undef, "Unknown commit object.");
1813 print "<div class=\"page_nav\">\n" .
1814 $cgi->a({-href
=> "$my_uri?p=$project;a=summary"}, "summary") .
1815 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=shortlog"}, "shortlog") .
1816 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=log"}, "log") .
1817 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$hash"}, "commit") .
1818 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff") .
1819 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, "tree") .
1823 $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML
($co{'title'})) . "\n" .
1825 print "<div class=\"page_path\"><b>/$file_name</b><br/></div>\n";
1827 open my $fd, "-|", "$gitbin/git-rev-list $hash | $gitbin/git-diff-tree -r --stdin $file_name";
1829 print "<table cellspacing=\"0\">\n";
1831 while (my $line = <$fd>) {
1832 if ($line =~ m/^([0-9a-fA-F]{40})/){
1836 if ($line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$/ && (defined $commit)) {
1837 my %co = git_read_commit
($commit);
1842 print "<tr class=\"dark\">\n";
1844 print "<tr class=\"light\">\n";
1847 print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
1848 "<td><i>" . escapeHTML
(chop_str
($co{'author_name'}, 15, 3)) . "</i></td>\n" .
1849 "<td>" . $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$commit", -class => "list"}, "<b>" .
1850 escapeHTML
(chop_str
($co{'title'}, 50)) . "</b>") . "</td>\n" .
1851 "<td class=\"link\">" .
1852 $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$commit"}, "commit") .
1853 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=blob;hb=$commit;f=$file_name"}, "blob");
1854 my $blob = git_get_hash_by_path
($hash, $file_name);
1855 my $blob_parent = git_get_hash_by_path
($commit, $file_name);
1856 if (defined $blob && defined $blob_parent && $blob ne $blob_parent) {
1858 $cgi->a({-href
=> "$my_uri?p=$project;a=blobdiff;h=$blob;hp=$blob_parent;hb=$commit;f=$file_name"},
1872 if (!defined $searchtext) {
1873 die_error
("", "Text field empty.");
1875 if (!defined $hash) {
1876 $hash = git_read_hash
("$project/HEAD");
1878 my %co = git_read_commit
($hash);
1880 die_error
(undef, "Unknown commit object.");
1882 # pickaxe may take all resources of your box and run for several minutes
1883 # with every query - so decide by yourself how public you make this feature :)
1884 my $commit_search = 1;
1885 my $author_search = 0;
1886 my $committer_search = 0;
1887 my $pickaxe_search = 0;
1888 if ($searchtext =~ s/^author\\://i) {
1890 } elsif ($searchtext =~ s/^committer\\://i) {
1891 $committer_search = 1;
1892 } elsif ($searchtext =~ s/^pickaxe\\://i) {
1894 $pickaxe_search = 1;
1897 print "<div class=\"page_nav\">\n" .
1898 $cgi->a({-href
=> "$my_uri?p=$project;a=summary;h=$hash"}, "summary") .
1899 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=shortlog"}, "shortlog") .
1900 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=log;h=$hash"}, "log") .
1901 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$hash"}, "commit") .
1902 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff") .
1903 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, "tree") .
1908 $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML
($co{'title'})) . "\n" .
1910 print "<table cellspacing=\"0\">\n";
1912 if ($commit_search) {
1914 open my $fd, "-|", "$gitbin/git-rev-list --header $hash";
1915 while (my $commit_text = <$fd>) {
1916 if (!grep m/$searchtext/i, $commit_text) {
1919 if ($author_search && !grep m/\nauthor .*$searchtext/i, $commit_text) {
1922 if ($committer_search && !grep m/\ncommitter .*$searchtext/i, $commit_text) {
1925 my @commit_lines = split "\n", $commit_text;
1926 my $commit = shift @commit_lines;
1927 my %co = git_read_commit
($commit, \
@commit_lines);
1932 print "<tr class=\"dark\">\n";
1934 print "<tr class=\"light\">\n";
1937 print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
1938 "<td><i>" . escapeHTML
(chop_str
($co{'author_name'}, 15, 5)) . "</i></td>\n" .
1940 $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$commit", -class => "list"}, "<b>" . escapeHTML
(chop_str
($co{'title'}, 50)) . "</b><br/>");
1941 my $comment = $co{'comment'};
1942 foreach my $line (@
$comment) {
1943 if ($line =~ m/^(.*)($searchtext)(.*)$/i) {
1944 my $lead = escapeHTML
($1) || "";
1945 $lead = chop_str
($lead, 30, 10);
1946 my $match = escapeHTML
($2) || "";
1947 my $trail = escapeHTML
($3) || "";
1948 $trail = chop_str
($trail, 30, 10);
1949 my $text = "$lead<span style=\"color:#e00000\">$match</span>$trail";
1950 print chop_str
($text, 80, 5) . "<br/>\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=tree;h=$co{'tree'};hb=$commit"}, "tree");
1963 if ($pickaxe_search) {
1965 open my $fd, "-|", "$gitbin/git-rev-list $hash | $gitbin/git-diff-tree -r --stdin -S$searchtext";
1968 while (my $line = <$fd>) {
1969 if (%co && $line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$/) {
1972 $set{'from_id'} = $3;
1974 $set{'id'} = $set{'to_id'};
1975 if ($set{'id'} =~ m/0{40}/) {
1976 $set{'id'} = $set{'from_id'};
1978 if ($set{'id'} =~ m/0{40}/) {
1982 } elsif ($line =~ m/^([0-9a-fA-F]{40}) /){
1985 print "<tr class=\"dark\">\n";
1987 print "<tr class=\"light\">\n";
1990 print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
1991 "<td><i>" . escapeHTML
(chop_str
($co{'author_name'}, 15, 5)) . "</i></td>\n" .
1993 $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$co{'id'}", -class => "list"}, "<b>" .
1994 escapeHTML
(chop_str
($co{'title'}, 50)) . "</b><br/>");
1995 while (my $setref = shift @files) {
1997 print $cgi->a({-href
=> "$my_uri?p=$project;a=blob;h=$set{'id'};hb=$co{'id'};f=$set{'file'}", class => "list"},
1998 "<span style=\"color:#e00000\">" . escapeHTML
($set{'file'}) . "</span>") .
2002 "<td class=\"link\">" .
2003 $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$co{'id'}"}, "commit") .
2004 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$co{'id'}"}, "tree");
2008 %co = git_read_commit
($1);
2018 my $head = git_read_hash
("$project/HEAD");
2019 if (!defined $hash) {
2022 if (!defined $page) {
2026 print "<div class=\"page_nav\">\n" .
2027 $cgi->a({-href
=> "$my_uri?p=$project;a=summary"}, "summary") .
2029 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=log;h=$hash"}, "log") .
2030 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$hash"}, "commit") .
2031 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff") .
2032 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=tree;h=$hash;hb=$hash"}, "tree") . "<br/>\n";
2034 my $limit = sprintf("--max-count=%i", (100 * ($page+1)));
2035 open my $fd, "-|", "$gitbin/git-rev-list $limit $hash" or die_error
(undef, "Open failed.");
2036 my (@revlist) = map { chomp; $_ } <$fd>;
2039 if ($hash ne $head || $page) {
2040 print $cgi->a({-href
=> "$my_uri?p=$project;a=shortlog"}, "HEAD");
2046 $cgi->a({-href
=> "$my_uri?p=$project;a=shortlog;h=$hash;pg=" . ($page-1), -accesskey
=> "p", -title
=> "Alt-p"}, "prev");
2048 print " ⋅ prev";
2050 if ($#revlist >= (100 * ($page+1)-1)) {
2052 $cgi->a({-href
=> "$my_uri?p=$project;a=shortlog;h=$hash;pg=" . ($page+1), -accesskey
=> "n", -title
=> "Alt-n"}, "next");
2054 print " ⋅ next";
2059 $cgi->a({-href
=> "$my_uri?p=$project;a=summary", -class => "title"}, " ") .
2061 print "<table cellspacing=\"0\">\n";
2063 for (my $i = ($page * 100); $i <= $#revlist; $i++) {
2064 my $commit = $revlist[$i];
2065 my %co = git_read_commit
($commit);
2066 my %ad = date_str
($co{'author_epoch'});
2068 print "<tr class=\"dark\">\n";
2070 print "<tr class=\"light\">\n";
2073 print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
2074 "<td><i>" . escapeHTML
(chop_str
($co{'author_name'}, 10)) . "</i></td>\n" .
2075 "<td>" . $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$commit", -class => "list"}, "<b>" .
2076 escapeHTML
($co{'title_short'}) . "</b>") . "</td>\n" .
2077 "<td class=\"link\">" .
2078 $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$commit"}, "commit") .
2079 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=commitdiff;h=$commit"}, "commitdiff") .
2083 if ($#revlist >= (100 * ($page+1)-1)) {
2086 $cgi->a({-href
=> "$my_uri?p=$project;a=shortlog;h=$hash;pg=" . ($page+1), -title
=> "Alt-n"}, "next") .