3 # gitweb - simple web interface to track changes in git repositories
5 # (C) 2005-2006, Kay Sievers <kay.sievers@vrfy.org>
6 # (C) 2005, Christian Gierke
8 # This program is licensed under the GPLv2
12 use CGI
qw(:standard :escapeHTML -nosticky);
13 use CGI
::Util
qw(unescape);
14 use CGI
::Carp
qw(fatalsToBrowser);
17 binmode STDOUT
, ':utf8';
21 our $my_url = $cgi->url();
22 our $my_uri = $cgi->url(-absolute
=> 1);
25 # location of the git-core binaries
26 our $gitbin = "/usr/bin";
28 # absolute fs-path which will be prepended to the project path
29 #our $projectroot = "/pub/scm";
30 our $projectroot = "/home/kay/public_html/pub/scm";
32 # version of the git-core binaries
33 our $git_version = qx($gitbin/git
--version
);
34 if ($git_version =~ m/git version (.*)$/) {
37 $git_version = "unknown";
40 # location for temporary files needed for diffs
41 our $git_temp = "/tmp/gitweb";
43 mkdir($git_temp, 0700) || die_error
("Couldn't mkdir $git_temp");
46 # target of the home link on top of all pages
47 our $home_link = $my_uri;
49 # name of your site or organization to appear in page titles
50 # replace this with something more descriptive for clearer bookmarks
51 our $site_name = $ENV{'SERVER_NAME'} || "Untitled";
53 # html text to include at home page
54 our $home_text = "indextext.html";
56 # URI of default stylesheet
57 our $stylesheet = "gitweb.css";
59 # source of projects list
60 #our $projects_list = $projectroot;
61 our $projects_list = "index/index.aux";
63 # default blob_plain mimetype and default charset for text/plain blob
64 our $default_blob_plain_mimetype = 'text/plain';
65 our $default_text_plain_charset = undef;
67 # file to use for guessing MIME types before trying /etc/mime.types
68 # (relative to the current git repository)
69 our $mimetypes_file = undef;
71 # input validation and dispatch
72 our $action = $cgi->param('a');
73 if (defined $action) {
74 if ($action =~ m/[^0-9a-zA-Z\.\-_]/) {
76 die_error
(undef, "Invalid action parameter.");
78 if ($action eq "git-logo.png") {
81 } elsif ($action eq "opml") {
87 our $order = $cgi->param('o');
89 if ($order =~ m/[^0-9a-zA-Z_]/) {
91 die_error
(undef, "Invalid order parameter.");
95 our $project = ($cgi->param('p') || $ENV{'PATH_INFO'});
96 if (defined $project) {
97 $project =~ s
|^/||; $project =~ s|/$||;
98 $project = validate_input
($project);
99 if (!defined($project)) {
100 die_error
(undef, "Invalid project parameter.");
102 if (!(-d
"$projectroot/$project")) {
104 die_error
(undef, "No such directory.");
106 if (!(-e
"$projectroot/$project/HEAD")) {
108 die_error
(undef, "No such project.");
110 $rss_link = "<link rel=\"alternate\" title=\"" . esc_param
($project) . " log\" href=\"" .
111 "$my_uri?" . esc_param
("p=$project;a=rss") . "\" type=\"application/rss+xml\"/>";
112 $ENV{'GIT_DIR'} = "$projectroot/$project";
118 our $file_name = $cgi->param('f');
119 if (defined $file_name) {
120 $file_name = validate_input
($file_name);
121 if (!defined($file_name)) {
122 die_error
(undef, "Invalid file parameter.");
126 our $hash = $cgi->param('h');
128 $hash = validate_input
($hash);
129 if (!defined($hash)) {
130 die_error
(undef, "Invalid hash parameter.");
134 our $hash_parent = $cgi->param('hp');
135 if (defined $hash_parent) {
136 $hash_parent = validate_input
($hash_parent);
137 if (!defined($hash_parent)) {
138 die_error
(undef, "Invalid hash parent parameter.");
142 our $hash_base = $cgi->param('hb');
143 if (defined $hash_base) {
144 $hash_base = validate_input
($hash_base);
145 if (!defined($hash_base)) {
146 die_error
(undef, "Invalid hash base parameter.");
150 our $page = $cgi->param('pg');
152 if ($page =~ m/[^0-9]$/) {
154 die_error
(undef, "Invalid page parameter.");
158 our $searchtext = $cgi->param('s');
159 if (defined $searchtext) {
160 if ($searchtext =~ m/[^a-zA-Z0-9_\.\/\
-\
+\
:\@
]/) {
162 die_error
(undef, "Invalid search parameter.");
164 $searchtext = quotemeta $searchtext;
170 if ($input =~ m/^[0-9a-fA-F]{40}$/) {
173 if ($input =~ m/(^|\/)(|\
.|\
.\
.)($|\
/)/) {
176 if ($input =~ m/[^a-zA-Z0-9_\x80-\xff\ \t\.\/\
-\
+\#\
~\
%]/) {
182 if (!defined $action || $action eq "summary") {
185 } elsif ($action eq "heads") {
188 } elsif ($action eq "tags") {
191 } elsif ($action eq "blob") {
194 } elsif ($action eq "blob_plain") {
197 } elsif ($action eq "tree") {
200 } elsif ($action eq "rss") {
203 } elsif ($action eq "commit") {
206 } elsif ($action eq "log") {
209 } elsif ($action eq "blobdiff") {
212 } elsif ($action eq "blobdiff_plain") {
213 git_blobdiff_plain
();
215 } elsif ($action eq "commitdiff") {
218 } elsif ($action eq "commitdiff_plain") {
219 git_commitdiff_plain
();
221 } elsif ($action eq "history") {
224 } elsif ($action eq "search") {
227 } elsif ($action eq "shortlog") {
230 } elsif ($action eq "tag") {
233 } elsif ($action eq "blame") {
238 die_error
(undef, "Unknown action.");
242 # quote unsafe chars, but keep the slash, even when it's not
243 # correct, but quoted slashes look too horrible in bookmarks
246 $str =~ s/([^A-Za-z0-9\-_.~();\/;?:@&=])/sprintf
("%%%02X", ord($1))/eg
;
252 # replace invalid utf8 character with SUBSTITUTION sequence
255 $str = decode
("utf8", $str, Encode
::FB_DEFAULT
);
256 $str = escapeHTML
($str);
260 # git may return quoted and escaped filenames
263 if ($str =~ m/^"(.*)"$/) {
265 $str =~ s/\\([0-7]{1,3})/chr(oct($1))/eg;
270 # CSS class for given age value (in seconds)
274 if ($age < 60*60*2) {
276 } elsif ($age < 60*60*24*2) {
283 sub git_header_html
{
284 my $status = shift || "200 OK";
287 my $title = "$site_name git";
288 if (defined $project) {
289 $title .= " - $project";
290 if (defined $action) {
291 $title .= "/$action";
292 if (defined $file_name) {
293 $title .= " - $file_name";
294 if ($action eq "tree" && $file_name !~ m
|/$|) {
301 # require explicit support from the UA if we are to send the page as
302 # 'application/xhtml+xml', otherwise send it as plain old 'text/html'.
303 # we have to do this because MSIE sometimes globs '*/*', pretending to
304 # support xhtml+xml but choking when it gets what it asked for.
305 if ($cgi->http('HTTP_ACCEPT') =~ m/(,|;|\s|^)application\/xhtml\
+xml
(,|;|\s
|$)/ && $cgi->Accept('application/xhtml
+xml
') != 0) {
306 $content_type = 'application
/xhtml
+xml
';
308 $content_type = 'text
/html
';
310 print $cgi->header(-type=>$content_type, -charset => 'utf
-8', -status=> $status, -expires => $expires);
312 <?xml version="1.0" encoding="utf-8"?>
313 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
314 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
315 <!-- git web interface v$version, (C) 2005-2006, Kay Sievers <kay.sievers\@vrfy.org>, Christian Gierke -->
316 <!-- git core binaries version $git_version -->
318 <meta http-equiv="content-type" content="$content_type; charset=utf-8"/>
319 <meta name="robots" content="index, nofollow"/>
320 <title>$title</title>
321 <link rel="stylesheet" type="text/css" href="$stylesheet"/>
326 print "<div class=\"page_header\">\n" .
327 "<a href=\"http://www.kernel.org/pub/software/scm/git/docs/\" title=\"git documentation\">" .
328 "<img src=\"$my_uri?" . esc_param
("a=git-logo.png") . "\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/>" .
330 print $cgi->a({-href
=> esc_param
($home_link)}, "projects") . " / ";
331 if (defined $project) {
332 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary")}, esc_html
($project));
333 if (defined $action) {
337 if (!defined $searchtext) {
341 if (defined $hash_base) {
342 $search_hash = $hash_base;
343 } elsif (defined $hash) {
344 $search_hash = $hash;
346 $search_hash = "HEAD";
348 $cgi->param("a", "search");
349 $cgi->param("h", $search_hash);
350 print $cgi->startform(-method
=> "get", -action
=> $my_uri) .
351 "<div class=\"search\">\n" .
352 $cgi->hidden(-name
=> "p") . "\n" .
353 $cgi->hidden(-name
=> "a") . "\n" .
354 $cgi->hidden(-name
=> "h") . "\n" .
355 $cgi->textfield(-name
=> "s", -value
=> $searchtext) . "\n" .
357 $cgi->end_form() . "\n";
362 sub git_footer_html
{
363 print "<div class=\"page_footer\">\n";
364 if (defined $project) {
365 my $descr = git_read_description
($project);
366 if (defined $descr) {
367 print "<div class=\"page_footer_text\">" . esc_html
($descr) . "</div>\n";
369 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=rss"), -class => "rss_logo"}, "RSS") . "\n";
371 print $cgi->a({-href
=> "$my_uri?" . esc_param
("a=opml"), -class => "rss_logo"}, "OPML") . "\n";
379 my $status = shift || "403 Forbidden";
380 my $error = shift || "Malformed query, file missing or permission denied";
382 git_header_html
($status);
383 print "<div class=\"page_body\">\n" .
385 "$status - $error\n" .
395 open my $fd, "-|", "$gitbin/git-cat-file -t $hash" or return;
404 my $oENV = $ENV{'GIT_DIR'};
406 $ENV{'GIT_DIR'} = "$projectroot/$project";
407 if (open my $fd, "-|", "$gitbin/git-rev-parse", "--verify", "HEAD") {
410 if (defined $head && $head =~ /^([0-9a-fA-F]{40})$/) {
415 $ENV{'GIT_DIR'} = $oENV;
423 open my $fd, "$projectroot/$path" or return undef;
427 if ($head =~ m/^[0-9a-fA-F]{40}$/) {
432 sub git_read_description
{
435 open my $fd, "$projectroot/$path/description" or return undef;
447 open my $fd, "-|", "$gitbin/git-cat-file tag $tag_id" or return;
448 $tag{'id'} = $tag_id;
449 while (my $line = <$fd>) {
451 if ($line =~ m/^object ([0-9a-fA-F]{40})$/) {
453 } elsif ($line =~ m/^type (.+)$/) {
455 } elsif ($line =~ m/^tag (.+)$/) {
457 } elsif ($line =~ m/^tagger (.*) ([0-9]+) (.*)$/) {
461 } elsif ($line =~ m/--BEGIN/) {
462 push @comment, $line;
464 } elsif ($line eq "") {
468 push @comment, <$fd>;
469 $tag{'comment'} = \
@comment;
471 if (!defined $tag{'name'}) {
481 if ($age > 60*60*24*365*2) {
482 $age_str = (int $age/60/60/24/365);
483 $age_str .= " years ago";
484 } elsif ($age > 60*60*24*(365/12)*2) {
485 $age_str = int $age/60/60/24/(365/12);
486 $age_str .= " months ago";
487 } elsif ($age > 60*60*24*7*2) {
488 $age_str = int $age/60/60/24/7;
489 $age_str .= " weeks ago";
490 } elsif ($age > 60*60*24*2) {
491 $age_str = int $age/60/60/24;
492 $age_str .= " days ago";
493 } elsif ($age > 60*60*2) {
494 $age_str = int $age/60/60;
495 $age_str .= " hours ago";
496 } elsif ($age > 60*2) {
497 $age_str = int $age/60;
498 $age_str .= " min ago";
501 $age_str .= " sec ago";
503 $age_str .= " right now";
508 sub git_read_commit
{
509 my $commit_id = shift;
510 my $commit_text = shift;
515 if (defined $commit_text) {
516 @commit_lines = @
$commit_text;
519 open my $fd, "-|", "$gitbin/git-rev-list --header --parents --max-count=1 $commit_id" or return;
520 @commit_lines = split '\n', <$fd>;
525 my $header = shift @commit_lines;
526 if (!($header =~ m/^[0-9a-fA-F]{40}/)) {
529 ($co{'id'}, my @parents) = split ' ', $header;
530 $co{'parents'} = \
@parents;
531 $co{'parent'} = $parents[0];
532 while (my $line = shift @commit_lines) {
533 last if $line eq "\n";
534 if ($line =~ m/^tree ([0-9a-fA-F]{40})$/) {
536 } elsif ($line =~ m/^author (.*) ([0-9]+) (.*)$/) {
538 $co{'author_epoch'} = $2;
539 $co{'author_tz'} = $3;
540 if ($co{'author'} =~ m/^([^<]+) </) {
541 $co{'author_name'} = $1;
543 $co{'author_name'} = $co{'author'};
545 } elsif ($line =~ m/^committer (.*) ([0-9]+) (.*)$/) {
546 $co{'committer'} = $1;
547 $co{'committer_epoch'} = $2;
548 $co{'committer_tz'} = $3;
549 $co{'committer_name'} = $co{'committer'};
550 $co{'committer_name'} =~ s/ <.*//;
553 if (!defined $co{'tree'}) {
557 foreach my $title (@commit_lines) {
560 $co{'title'} = chop_str
($title, 80, 5);
561 # remove leading stuff of merges to make the interesting part visible
562 if (length($title) > 50) {
563 $title =~ s/^Automatic //;
564 $title =~ s/^merge (of|with) /Merge ... /i;
565 if (length($title) > 50) {
566 $title =~ s/(http|rsync):\/\///;
568 if (length($title) > 50) {
569 $title =~ s/(master|www|rsync)\.//;
571 if (length($title) > 50) {
572 $title =~ s/kernel.org:?//;
574 if (length($title) > 50) {
575 $title =~ s/\/pub\/scm//;
578 $co{'title_short'} = chop_str
($title, 50, 5);
582 # remove added spaces
583 foreach my $line (@commit_lines) {
586 $co{'comment'} = \
@commit_lines;
588 my $age = time - $co{'committer_epoch'};
590 $co{'age_string'} = age_string
($age);
591 my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($co{'committer_epoch'});
592 if ($age > 60*60*24*7*2) {
593 $co{'age_string_date'} = sprintf "%4i-%02u-%02i", 1900 + $year, $mon+1, $mday;
594 $co{'age_string_age'} = $co{'age_string'};
596 $co{'age_string_date'} = $co{'age_string'};
597 $co{'age_string_age'} = sprintf "%4i-%02u-%02i", 1900 + $year, $mon+1, $mday;
604 my $from_name = shift;
607 my $format = shift || "html";
609 my $from_tmp = "/dev/null";
610 my $to_tmp = "/dev/null";
613 # create tmp from-file
615 $from_tmp = "$git_temp/gitweb_" . $$ . "_from";
616 open my $fd2, "> $from_tmp";
617 open my $fd, "-|", "$gitbin/git-cat-file blob $from";
626 $to_tmp = "$git_temp/gitweb_" . $$ . "_to";
627 open my $fd2, "> $to_tmp";
628 open my $fd, "-|", "$gitbin/git-cat-file blob $to";
635 open my $fd, "-|", "/usr/bin/diff -u -p -L \'$from_name\' -L \'$to_name\' $from_tmp $to_tmp";
636 if ($format eq "plain") {
641 while (my $line = <$fd>) {
643 my $char = substr($line, 0, 1);
646 $diff_class = " add";
647 } elsif ($char eq "-") {
648 $diff_class = " rem";
649 } elsif ($char eq "@") {
650 $diff_class = " chunk_header";
651 } elsif ($char eq "\\") {
655 while ((my $pos = index($line, "\t")) != -1) {
656 if (my $count = (8 - (($pos-1) % 8))) {
657 my $spaces = ' ' x
$count;
658 $line =~ s/\t/$spaces/;
661 print "<div class=\"diff$diff_class\">" . esc_html
($line) . "</div>\n";
675 my $mode = oct shift;
677 if (S_ISDIR
($mode & S_IFMT
)) {
679 } elsif (S_ISLNK
($mode)) {
681 } elsif (S_ISREG
($mode)) {
682 # git cares only about the executable bit
683 if ($mode & S_IXUSR
) {
696 my $add_len = shift || 10;
698 # allow only $len chars, but don't cut a word if it would fit in $add_len
699 # if it doesn't fit, cut it if it's still longer than the dots we would add
700 $str =~ m/^(.{0,$len}[^ \/\
-_
:\
.@
]{0,$add_len})(.*)/;
703 if (length($tail) > 4) {
710 my $mode = oct shift;
712 if (S_ISDIR
($mode & S_IFMT
)) {
714 } elsif (S_ISLNK
($mode)) {
716 } elsif (S_ISREG
($mode)) {
723 sub format_log_line_html
{
726 $line = esc_html
($line);
727 $line =~ s/ / /g;
728 if ($line =~ m/([0-9a-fA-F]{40})/) {
730 if (git_get_type
($hash_text) eq "commit") {
731 my $link = $cgi->a({-class => "text", -href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash_text")}, $hash_text);
732 $line =~ s/$hash_text/$link/;
740 my $tz = shift || "-0000";
743 my @months = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
744 my @days = ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
745 my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($epoch);
746 $date{'hour'} = $hour;
747 $date{'minute'} = $min;
748 $date{'mday'} = $mday;
749 $date{'day'} = $days[$wday];
750 $date{'month'} = $months[$mon];
751 $date{'rfc2822'} = sprintf "%s, %d %s %4d %02d:%02d:%02d +0000", $days[$wday], $mday, $months[$mon], 1900+$year, $hour ,$min, $sec;
752 $date{'mday-time'} = sprintf "%d %s %02d:%02d", $mday, $months[$mon], $hour ,$min;
754 $tz =~ m/^([+\-][0-9][0-9])([0-9][0-9])$/;
755 my $local = $epoch + ((int $1 + ($2/60)) * 3600);
756 ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($local);
757 $date{'hour_local'} = $hour;
758 $date{'minute_local'} = $min;
759 $date{'tz_local'} = $tz;
763 # git-logo (cached in browser for one day)
765 binmode STDOUT
, ':raw';
766 print $cgi->header(-type
=> 'image/png', -expires
=> '+1d');
767 # cat git-logo.png | hexdump -e '16/1 " %02x" "\n"' | sed 's/ /\\x/g'
768 print "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52" .
769 "\x00\x00\x00\x48\x00\x00\x00\x1b\x04\x03\x00\x00\x00\x2d\xd9\xd4" .
770 "\x2d\x00\x00\x00\x18\x50\x4c\x54\x45\xff\xff\xff\x60\x60\x5d\xb0" .
771 "\xaf\xaa\x00\x80\x00\xce\xcd\xc7\xc0\x00\x00\xe8\xe8\xe6\xf7\xf7" .
772 "\xf6\x95\x0c\xa7\x47\x00\x00\x00\x73\x49\x44\x41\x54\x28\xcf\x63" .
773 "\x48\x67\x20\x04\x4a\x5c\x18\x0a\x08\x2a\x62\x53\x61\x20\x02\x08" .
774 "\x0d\x69\x45\xac\xa1\xa1\x01\x30\x0c\x93\x60\x36\x26\x52\x91\xb1" .
775 "\x01\x11\xd6\xe1\x55\x64\x6c\x6c\xcc\x6c\x6c\x0c\xa2\x0c\x70\x2a" .
776 "\x62\x06\x2a\xc1\x62\x1d\xb3\x01\x02\x53\xa4\x08\xe8\x00\x03\x18" .
777 "\x26\x56\x11\xd4\xe1\x20\x97\x1b\xe0\xb4\x0e\x35\x24\x71\x29\x82" .
778 "\x99\x30\xb8\x93\x0a\x11\xb9\x45\x88\xc1\x8d\xa0\xa2\x44\x21\x06" .
779 "\x27\x41\x82\x40\x85\xc1\x45\x89\x20\x70\x01\x00\xa4\x3d\x21\xc5" .
780 "\x12\x1c\x9a\xfe\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82";
786 my ($dev, $ino, $mode, $nlink, $st_uid, $st_gid, $rdev, $size) = stat($path);
787 my ($name, $passwd, $uid, $gid, $quota, $comment, $gcos, $dir, $shell) = getpwuid($st_uid);
788 if (!defined $gcos) {
792 $owner =~ s/[,;].*$//;
793 return decode
("utf8", $owner, Encode
::FB_DEFAULT
);
796 sub git_read_projects
{
799 if (-d
$projects_list) {
800 # search in directory
801 my $dir = $projects_list;
802 opendir my $dh, $dir or return undef;
803 while (my $dir = readdir($dh)) {
804 if (-e
"$projectroot/$dir/HEAD") {
812 } elsif (-f
$projects_list) {
813 # read from file(url-encoded):
814 # 'git%2Fgit.git Linus+Torvalds'
815 # 'libs%2Fklibc%2Fklibc.git H.+Peter+Anvin'
816 # 'linux%2Fhotplug%2Fudev.git Greg+Kroah-Hartman'
817 open my $fd , $projects_list or return undef;
818 while (my $line = <$fd>) {
820 my ($path, $owner) = split ' ', $line;
821 $path = unescape
($path);
822 $owner = unescape
($owner);
823 if (!defined $path) {
826 if (-e
"$projectroot/$path/HEAD") {
829 owner
=> decode
("utf8", $owner, Encode
::FB_DEFAULT
),
836 @list = sort {$a->{'path'} cmp $b->{'path'}} @list;
840 sub git_get_project_config
{
843 return unless ($key);
844 $key =~ s/^gitweb\.//;
845 return if ($key =~ m/\W/);
847 my $val = qx($gitbin/git
-repo
-config
--get gitweb
.$key);
851 sub git_get_project_config_bool
{
852 my $val = git_get_project_config
(@_);
853 if ($val and $val =~ m/true|yes|on/) {
856 return; # implicit false
859 sub git_project_list
{
860 my @list = git_read_projects
();
863 die_error
(undef, "No project found.");
865 foreach my $pr (@list) {
866 my $head = git_read_head
($pr->{'path'});
867 if (!defined $head) {
870 $ENV{'GIT_DIR'} = "$projectroot/$pr->{'path'}";
871 my %co = git_read_commit
($head);
875 $pr->{'commit'} = \
%co;
876 if (!defined $pr->{'descr'}) {
877 my $descr = git_read_description
($pr->{'path'}) || "";
878 $pr->{'descr'} = chop_str
($descr, 25, 5);
880 if (!defined $pr->{'owner'}) {
881 $pr->{'owner'} = get_file_owner
("$projectroot/$pr->{'path'}") || "";
887 print "<div class=\"index_include\">\n";
888 open (my $fd, $home_text);
893 print "<table class=\"project_list\">\n" .
895 if (!defined($order) || (defined($order) && ($order eq "project"))) {
896 @projects = sort {$a->{'path'} cmp $b->{'path'}} @projects;
897 print "<th>Project</th>\n";
899 print "<th>" . $cgi->a({-class => "header", -href
=> "$my_uri?" . esc_param
("o=project")}, "Project") . "</th>\n";
901 if (defined($order) && ($order eq "descr")) {
902 @projects = sort {$a->{'descr'} cmp $b->{'descr'}} @projects;
903 print "<th>Description</th>\n";
905 print "<th>" . $cgi->a({-class => "header", -href
=> "$my_uri?" . esc_param
("o=descr")}, "Description") . "</th>\n";
907 if (defined($order) && ($order eq "owner")) {
908 @projects = sort {$a->{'owner'} cmp $b->{'owner'}} @projects;
909 print "<th>Owner</th>\n";
911 print "<th>" . $cgi->a({-class => "header", -href
=> "$my_uri?" . esc_param
("o=owner")}, "Owner") . "</th>\n";
913 if (defined($order) && ($order eq "age")) {
914 @projects = sort {$a->{'commit'}{'age'} <=> $b->{'commit'}{'age'}} @projects;
915 print "<th>Last Change</th>\n";
917 print "<th>" . $cgi->a({-class => "header", -href
=> "$my_uri?" . esc_param
("o=age")}, "Last Change") . "</th>\n";
919 print "<th></th>\n" .
922 foreach my $pr (@projects) {
924 print "<tr class=\"dark\">\n";
926 print "<tr class=\"light\">\n";
929 print "<td>" . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$pr->{'path'};a=summary"), -class => "list"}, esc_html
($pr->{'path'})) . "</td>\n" .
930 "<td>$pr->{'descr'}</td>\n" .
931 "<td><i>" . chop_str
($pr->{'owner'}, 15) . "</i></td>\n";
932 print "<td class=\"". age_class
($pr->{'commit'}{'age'}) . "\">" . $pr->{'commit'}{'age_string'} . "</td>\n" .
933 "<td class=\"link\">" .
934 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$pr->{'path'};a=summary")}, "summary") .
935 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$pr->{'path'};a=shortlog")}, "shortlog") .
936 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$pr->{'path'};a=log")}, "log") .
945 my $type = shift || "";
947 # 5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c refs/tags/v2.6.11
948 # c39ae07f393806ccf406ef966e9a15afc43cc36a refs/tags/v2.6.11^{}
949 open my $fd, "$projectroot/$project/info/refs" or return;
950 while (my $line = <$fd>) {
952 if ($line =~ m/^([0-9a-fA-F]{40})\t.*$type\/([^\
^]+)/) {
953 if (defined $refs{$1}) {
954 $refs{$1} .= " / $2";
969 opendir my $dh, "$projectroot/$project/$ref_dir";
970 while (my $dir = readdir($dh)) {
971 if ($dir =~ m/^\./) {
974 if (-d
"$projectroot/$project/$ref_dir/$dir") {
975 opendir my $dh2, "$projectroot/$project/$ref_dir/$dir";
976 my @subdirs = grep !m/^\./, readdir $dh2;
978 foreach my $subdir (@subdirs) {
979 push @refs, "$dir/$subdir"
986 foreach my $ref_file (@refs) {
987 my $ref_id = git_read_hash
("$project/$ref_dir/$ref_file");
988 my $type = git_get_type
($ref_id) || next;
991 $ref_item{'type'} = $type;
992 $ref_item{'id'} = $ref_id;
993 $ref_item{'epoch'} = 0;
994 $ref_item{'age'} = "unknown";
995 if ($type eq "tag") {
996 my %tag = git_read_tag
($ref_id);
997 $ref_item{'comment'} = $tag{'comment'};
998 if ($tag{'type'} eq "commit") {
999 %co = git_read_commit
($tag{'object'});
1000 $ref_item{'epoch'} = $co{'committer_epoch'};
1001 $ref_item{'age'} = $co{'age_string'};
1002 } elsif (defined($tag{'epoch'})) {
1003 my $age = time - $tag{'epoch'};
1004 $ref_item{'epoch'} = $tag{'epoch'};
1005 $ref_item{'age'} = age_string
($age);
1007 $ref_item{'reftype'} = $tag{'type'};
1008 $ref_item{'name'} = $tag{'name'};
1009 $ref_item{'refid'} = $tag{'object'};
1010 } elsif ($type eq "commit"){
1011 %co = git_read_commit
($ref_id);
1012 $ref_item{'reftype'} = "commit";
1013 $ref_item{'name'} = $ref_file;
1014 $ref_item{'title'} = $co{'title'};
1015 $ref_item{'refid'} = $ref_id;
1016 $ref_item{'epoch'} = $co{'committer_epoch'};
1017 $ref_item{'age'} = $co{'age_string'};
1020 push @reflist, \
%ref_item;
1023 @reflist = sort {$b->{'epoch'} <=> $a->{'epoch'}} @reflist;
1028 my $descr = git_read_description
($project) || "none";
1029 my $head = git_read_head
($project);
1030 my %co = git_read_commit
($head);
1031 my %cd = date_str
($co{'committer_epoch'}, $co{'committer_tz'});
1034 if (-f
$projects_list) {
1035 open (my $fd , $projects_list);
1036 while (my $line = <$fd>) {
1038 my ($pr, $ow) = split ' ', $line;
1039 $pr = unescape
($pr);
1040 $ow = unescape
($ow);
1041 if ($pr eq $project) {
1042 $owner = decode
("utf8", $ow, Encode
::FB_DEFAULT
);
1048 if (!defined $owner) {
1049 $owner = get_file_owner
("$projectroot/$project");
1052 my $refs = read_info_ref
();
1054 print "<div class=\"page_nav\">\n" .
1056 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog")}, "shortlog") .
1057 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log")}, "log") .
1058 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$head")}, "commit") .
1059 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$head")}, "commitdiff") .
1060 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree")}, "tree") .
1063 print "<div class=\"title\"> </div>\n";
1064 print "<table cellspacing=\"0\">\n" .
1065 "<tr><td>description</td><td>" . esc_html
($descr) . "</td></tr>\n" .
1066 "<tr><td>owner</td><td>$owner</td></tr>\n" .
1067 "<tr><td>last change</td><td>$cd{'rfc2822'}</td></tr>\n" .
1069 open my $fd, "-|", "$gitbin/git-rev-list --max-count=17 " . git_read_head
($project) or die_error
(undef, "Open failed.");
1070 my (@revlist) = map { chomp; $_ } <$fd>;
1073 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog"), -class => "title"}, "shortlog") .
1076 print "<table cellspacing=\"0\">\n";
1078 foreach my $commit (@revlist) {
1079 my %co = git_read_commit
($commit);
1080 my %ad = date_str
($co{'author_epoch'});
1082 print "<tr class=\"dark\">\n";
1084 print "<tr class=\"light\">\n";
1089 if (defined $refs->{$commit}) {
1090 $ref = " <span class=\"tag\">" . esc_html
($refs->{$commit}) . "</span>";
1092 print "<td><i>$co{'age_string'}</i></td>\n" .
1093 "<td><i>" . esc_html
(chop_str
($co{'author_name'}, 10)) . "</i></td>\n" .
1095 if (length($co{'title_short'}) < length($co{'title'})) {
1096 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$commit"), -class => "list", -title
=> "$co{'title'}"},
1097 "<b>" . esc_html
($co{'title_short'}) . "$ref</b>");
1099 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$commit"), -class => "list"},
1100 "<b>" . esc_html
($co{'title'}) . "$ref</b>");
1103 "<td class=\"link\">" .
1104 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$commit")}, "commit") .
1105 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$commit")}, "commitdiff") .
1109 print "<td>" . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog")}, "...") . "</td>\n" .
1116 my $taglist = git_read_refs
("refs/tags");
1117 if (defined @
$taglist) {
1119 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tags"), -class => "title"}, "tags") .
1122 print "<table cellspacing=\"0\">\n";
1124 foreach my $entry (@
$taglist) {
1126 my $comment_lines = $tag{'comment'};
1127 my $comment = shift @
$comment_lines;
1128 if (defined($comment)) {
1129 $comment = chop_str
($comment, 30, 5);
1132 print "<tr class=\"dark\">\n";
1134 print "<tr class=\"light\">\n";
1138 print "<td><i>$tag{'age'}</i></td>\n" .
1140 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=$tag{'reftype'};h=$tag{'refid'}"), -class => "list"},
1141 "<b>" . esc_html
($tag{'name'}) . "</b>") .
1144 if (defined($comment)) {
1145 print $cgi->a({-class => "list", -href
=> "$my_uri?" . esc_param
("p=$project;a=tag;h=$tag{'id'}")}, $comment);
1148 "<td class=\"link\">";
1149 if ($tag{'type'} eq "tag") {
1150 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tag;h=$tag{'id'}")}, "tag") . " | ";
1152 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=$tag{'reftype'};h=$tag{'refid'}")}, $tag{'reftype'});
1153 if ($tag{'reftype'} eq "commit") {
1154 print " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog;h=$tag{'name'}")}, "shortlog") .
1155 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log;h=$tag{'refid'}")}, "log");
1160 print "<td>" . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tags")}, "...") . "</td>\n" .
1168 my $headlist = git_read_refs
("refs/heads");
1169 if (defined @
$headlist) {
1171 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=heads"), -class => "title"}, "heads") .
1174 print "<table cellspacing=\"0\">\n";
1176 foreach my $entry (@
$headlist) {
1179 print "<tr class=\"dark\">\n";
1181 print "<tr class=\"light\">\n";
1185 print "<td><i>$tag{'age'}</i></td>\n" .
1187 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog;h=$tag{'name'}"), -class => "list"},
1188 "<b>" . esc_html
($tag{'name'}) . "</b>") .
1190 "<td class=\"link\">" .
1191 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog;h=$tag{'name'}")}, "shortlog") .
1192 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log;h=$tag{'name'}")}, "log") .
1196 print "<td>" . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=heads")}, "...") . "</td>\n" .
1207 my $head = git_read_head
($project);
1209 print "<div class=\"page_nav\">\n" .
1210 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary")}, "summary") .
1211 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog")}, "shortlog") .
1212 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log")}, "log") .
1213 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$head")}, "commit") .
1214 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$head")}, "commitdiff") .
1215 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;hb=$head")}, "tree") . "<br/>\n" .
1218 my %tag = git_read_tag
($hash);
1220 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash"), -class => "title"}, esc_html
($tag{'name'})) . "\n" .
1222 print "<div class=\"title_text\">\n" .
1223 "<table cellspacing=\"0\">\n" .
1225 "<td>object</td>\n" .
1226 "<td>" . $cgi->a({-class => "list", -href
=> "$my_uri?" . esc_param
("p=$project;a=$tag{'type'};h=$tag{'object'}")}, $tag{'object'}) . "</td>\n" .
1227 "<td class=\"link\">" . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=$tag{'type'};h=$tag{'object'}")}, $tag{'type'}) . "</td>\n" .
1229 if (defined($tag{'author'})) {
1230 my %ad = date_str
($tag{'epoch'}, $tag{'tz'});
1231 print "<tr><td>author</td><td>" . esc_html
($tag{'author'}) . "</td></tr>\n";
1232 print "<tr><td></td><td>" . $ad{'rfc2822'} . sprintf(" (%02d:%02d %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'}) . "</td></tr>\n";
1234 print "</table>\n\n" .
1236 print "<div class=\"page_body\">";
1237 my $comment = $tag{'comment'};
1238 foreach my $line (@
$comment) {
1239 print esc_html
($line) . "<br/>\n";
1247 die_error
('403 Permission denied', "Permission denied.") if (!git_get_project_config_bool
('blame'));
1248 die_error
('404 Not Found', "What file will it be, master?") if (!$file_name);
1249 $hash_base ||= git_read_head
($project);
1250 die_error
(undef, "Reading commit failed.") unless ($hash_base);
1251 my %co = git_read_commit
($hash_base)
1252 or die_error
(undef, "Reading commit failed.");
1253 if (!defined $hash) {
1254 $hash = git_get_hash_by_path
($hash_base, $file_name, "blob")
1255 or die_error
(undef, "Error lookup file.");
1257 open ($fd, "-|", "$gitbin/git-annotate", '-l', '-t', '-r', $file_name, $hash_base)
1258 or die_error
(undef, "Open failed.");
1260 print "<div class=\"page_nav\">\n" .
1261 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary")}, "summary") .
1262 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog")}, "shortlog") .
1263 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log")}, "log") .
1264 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash_base")}, "commit") .
1265 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$hash_base")}, "commitdiff") .
1266 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;h=$co{'tree'};hb=$hash_base")}, "tree") . "<br/>\n";
1267 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;h=$hash;hb=$hash_base;f=$file_name")}, "blob") .
1268 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blame;f=$file_name")}, "head") . "<br/>\n";
1271 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash_base"), -class => "title"}, esc_html
($co{'title'})) .
1273 print "<div class=\"page_path\"><b>" . esc_html
($file_name) . "</b></div>\n";
1274 print "<div class=\"page_body\">\n";
1276 <table class="blame">
1285 my @line_class = (qw(light dark));
1286 my $line_class_len = scalar (@line_class);
1287 my $line_class_num = $#line_class;
1288 while (my $line = <$fd>) {
1300 $line_class_num = ($line_class_num + 1) % $line_class_len;
1302 if ($line =~ m/^([0-9a-fA-F]{40})\t\(\s*([^\t]+)\t(\d+) \+\d\d\d\d\t(\d+)\)(.*)$/) {
1309 print qq( <tr
><td colspan
="5" class="error">Unable to parse
: $line</td></tr
>\n);
1312 $short_rev = substr ($long_rev, 0, 8);
1313 $age = time () - $time;
1314 $age_str = age_string
($age);
1315 $age_str =~ s/ / /g;
1316 $age_class = age_class
($age);
1317 $author = esc_html
($author);
1318 $author =~ s/ / /g;
1320 while ((my $pos = index($data, "\t")) != -1) {
1321 if (my $count = (8 - ($pos % 8))) {
1322 my $spaces = ' ' x
$count;
1323 $data =~ s/\t/$spaces/;
1326 $data = esc_html
($data);
1329 <tr class="$line_class[$line_class_num]">
1330 <td class="sha1"><a href="$my_uri?${\esc_param ("p=$project;a=commit;h=$long_rev")}" class="text">$short_rev..</a></td>
1331 <td class="$age_class">$age_str</td>
1333 <td class="linenr"><a id="$lineno" href="#$lineno" class="linenr">$lineno</a></td>
1334 <td class="pre">$data</td>
1337 } # while (my $line = <$fd>)
1338 print "</table>\n\n";
1339 close $fd or print "Reading blob failed.\n";
1345 my $head = git_read_head
($project);
1347 print "<div class=\"page_nav\">\n" .
1348 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary")}, "summary") .
1349 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog")}, "shortlog") .
1350 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log")}, "log") .
1351 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$head")}, "commit") .
1352 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$head")}, "commitdiff") .
1353 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;hb=$head")}, "tree") . "<br/>\n" .
1356 my $taglist = git_read_refs
("refs/tags");
1358 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary"), -class => "title"}, " ") .
1360 print "<table cellspacing=\"0\">\n";
1362 if (defined @
$taglist) {
1363 foreach my $entry (@
$taglist) {
1365 my $comment_lines = $tag{'comment'};
1366 my $comment = shift @
$comment_lines;
1367 if (defined($comment)) {
1368 $comment = chop_str
($comment, 30, 5);
1371 print "<tr class=\"dark\">\n";
1373 print "<tr class=\"light\">\n";
1376 print "<td><i>$tag{'age'}</i></td>\n" .
1378 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=$tag{'reftype'};h=$tag{'refid'}"), -class => "list"},
1379 "<b>" . esc_html
($tag{'name'}) . "</b>") .
1382 if (defined($comment)) {
1383 print $cgi->a({-class => "list", -href
=> "$my_uri?" . esc_param
("p=$project;a=tag;h=$tag{'id'}")}, $comment);
1386 "<td class=\"link\">";
1387 if ($tag{'type'} eq "tag") {
1388 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tag;h=$tag{'id'}")}, "tag") . " | ";
1390 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=$tag{'reftype'};h=$tag{'refid'}")}, $tag{'reftype'});
1391 if ($tag{'reftype'} eq "commit") {
1392 print " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog;h=$tag{'name'}")}, "shortlog") .
1393 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log;h=$tag{'refid'}")}, "log");
1404 my $head = git_read_head
($project);
1406 print "<div class=\"page_nav\">\n" .
1407 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary")}, "summary") .
1408 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog")}, "shortlog") .
1409 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log")}, "log") .
1410 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$head")}, "commit") .
1411 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$head")}, "commitdiff") .
1412 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;hb=$head")}, "tree") . "<br/>\n" .
1415 my $taglist = git_read_refs
("refs/heads");
1417 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary"), -class => "title"}, " ") .
1419 print "<table cellspacing=\"0\">\n";
1421 if (defined @
$taglist) {
1422 foreach my $entry (@
$taglist) {
1425 print "<tr class=\"dark\">\n";
1427 print "<tr class=\"light\">\n";
1430 print "<td><i>$tag{'age'}</i></td>\n" .
1432 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog;h=$tag{'name'}"), -class => "list"}, "<b>" . esc_html
($tag{'name'}) . "</b>") .
1434 "<td class=\"link\">" .
1435 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog;h=$tag{'name'}")}, "shortlog") .
1436 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log;h=$tag{'name'}")}, "log") .
1445 sub git_get_hash_by_path
{
1447 my $path = shift || return undef;
1450 my @parts = split '/', $path;
1451 while (my $part = shift @parts) {
1452 open my $fd, "-|", "$gitbin/git-ls-tree $tree" or die_error
(undef, "Open git-ls-tree failed.");
1453 my (@entries) = map { chomp; $_ } <$fd>;
1454 close $fd or return undef;
1455 foreach my $line (@entries) {
1456 #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c'
1457 $line =~ m/^([0-9]+) (.+) ([0-9a-fA-F]{40})\t(.+)$/;
1461 my $t_name = validate_input
(unquote
($4));
1462 if ($t_name eq $part) {
1466 if ($t_type eq "tree") {
1475 sub mimetype_guess_file
{
1476 my $filename = shift;
1477 my $mimemap = shift;
1478 -r
$mimemap or return undef;
1481 open(MIME
, $mimemap) or return undef;
1483 my ($mime, $exts) = split(/\t+/);
1484 my @exts = split(/\s+/, $exts);
1485 foreach my $ext (@exts) {
1486 $mimemap{$ext} = $mime;
1491 $filename =~ /\.(.*?)$/;
1492 return $mimemap{$1};
1495 sub mimetype_guess
{
1496 my $filename = shift;
1498 $filename =~ /\./ or return undef;
1500 if ($mimetypes_file) {
1501 my $file = $mimetypes_file;
1502 #$file =~ m#^/# or $file = "$projectroot/$path/$file";
1503 $mime = mimetype_guess_file
($filename, $file);
1505 $mime ||= mimetype_guess_file
($filename, '/etc/mime.types');
1509 sub git_blob_plain_mimetype
{
1511 my $filename = shift;
1514 my $mime = mimetype_guess
($filename);
1515 $mime and return $mime;
1519 return $default_blob_plain_mimetype unless $fd;
1522 return 'text/plain' .
1523 ($default_text_plain_charset ?
'; charset='.$default_text_plain_charset : '');
1524 } elsif (! $filename) {
1525 return 'application/octet-stream';
1526 } elsif ($filename =~ m/\.png$/i) {
1528 } elsif ($filename =~ m/\.gif$/i) {
1530 } elsif ($filename =~ m/\.jpe?g$/i) {
1531 return 'image/jpeg';
1533 return 'application/octet-stream';
1537 sub git_blob_plain
{
1539 open my $fd, "-|", "$gitbin/git-cat-file blob $hash" or die_error
("Couldn't cat $file_name, $hash");
1541 $type ||= git_blob_plain_mimetype
($fd, $file_name);
1543 # save as filename, even when no $file_name is given
1544 my $save_as = "$hash";
1545 if (defined $file_name) {
1546 $save_as = $file_name;
1547 } elsif ($type =~ m/^text\//) {
1551 print $cgi->header(-type
=> "$type", '-content-disposition' => "inline; filename=\"$save_as\"");
1553 binmode STDOUT
, ':raw';
1555 binmode STDOUT
, ':utf8'; # as set at the beginning of gitweb.cgi
1561 if (!defined $hash && defined $file_name) {
1562 my $base = $hash_base || git_read_head
($project);
1563 $hash = git_get_hash_by_path
($base, $file_name, "blob") || die_error
(undef, "Error lookup file.");
1565 my $have_blame = git_get_project_config_bool
('blame');
1566 open my $fd, "-|", "$gitbin/git-cat-file blob $hash" or die_error
(undef, "Open failed.");
1567 my $mimetype = git_blob_plain_mimetype
($fd, $file_name);
1568 if ($mimetype !~ m/^text\//) {
1570 return git_blob_plain
($mimetype);
1573 if (defined $hash_base && (my %co = git_read_commit
($hash_base))) {
1574 print "<div class=\"page_nav\">\n" .
1575 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary")}, "summary") .
1576 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog")}, "shortlog") .
1577 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log")}, "log") .
1578 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash_base")}, "commit") .
1579 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$hash_base")}, "commitdiff") .
1580 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;h=$co{'tree'};hb=$hash_base")}, "tree") . "<br/>\n";
1581 if (defined $file_name) {
1583 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blame;h=$hash;hb=$hash_base;f=$file_name")}, "blame") . " | ";
1585 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob_plain;h=$hash;f=$file_name")}, "plain") .
1586 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;hb=HEAD;f=$file_name")}, "head") . "<br/>\n";
1588 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob_plain;h=$hash")}, "plain") . "<br/>\n";
1592 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash_base"), -class => "title"}, esc_html
($co{'title'})) .
1595 print "<div class=\"page_nav\">\n" .
1596 "<br/><br/></div>\n" .
1597 "<div class=\"title\">$hash</div>\n";
1599 if (defined $file_name) {
1600 print "<div class=\"page_path\"><b>" . esc_html
($file_name) . "</b></div>\n";
1602 print "<div class=\"page_body\">\n";
1604 while (my $line = <$fd>) {
1607 while ((my $pos = index($line, "\t")) != -1) {
1608 if (my $count = (8 - ($pos % 8))) {
1609 my $spaces = ' ' x
$count;
1610 $line =~ s/\t/$spaces/;
1613 printf "<div class=\"pre\"><a id=\"l%i\" href=\"#l%i\" class=\"linenr\">%4i</a> %s</div>\n", $nr, $nr, $nr, esc_html
($line);
1615 close $fd or print "Reading blob failed.\n";
1621 if (!defined $hash) {
1622 $hash = git_read_head
($project);
1623 if (defined $file_name) {
1624 my $base = $hash_base || $hash;
1625 $hash = git_get_hash_by_path
($base, $file_name, "tree");
1627 if (!defined $hash_base) {
1632 open my $fd, "-|", "$gitbin/git-ls-tree -z $hash" or die_error
(undef, "Open git-ls-tree failed.");
1633 chomp (my (@entries) = <$fd>);
1634 close $fd or die_error
(undef, "Reading tree failed.");
1637 my $refs = read_info_ref
();
1639 if (defined $refs->{$hash_base}) {
1640 $ref = " <span class=\"tag\">" . esc_html
($refs->{$hash_base}) . "</span>";
1645 if (defined $hash_base && (my %co = git_read_commit
($hash_base))) {
1646 $base_key = ";hb=$hash_base";
1647 print "<div class=\"page_nav\">\n" .
1648 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary")}, "summary") .
1649 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog;h=$hash_base")}, "shortlog") .
1650 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log;h=$hash_base")}, "log") .
1651 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash_base")}, "commit") .
1652 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$hash_base")}, "commitdiff") .
1657 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash_base"), -class => "title"}, esc_html
($co{'title'}) . $ref) . "\n" .
1660 print "<div class=\"page_nav\">\n";
1661 print "<br/><br/></div>\n";
1662 print "<div class=\"title\">$hash</div>\n";
1664 if (defined $file_name) {
1665 $base = esc_html
("$file_name/");
1666 print "<div class=\"page_path\"><b>/" . esc_html
($file_name) . "</b></div>\n";
1668 print "<div class=\"page_path\"><b>/</b></div>\n";
1670 print "<div class=\"page_body\">\n";
1671 print "<table cellspacing=\"0\">\n";
1673 foreach my $line (@entries) {
1674 #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c'
1675 $line =~ m/^([0-9]+) (.+) ([0-9a-fA-F]{40})\t(.+)$/;
1679 my $t_name = validate_input
($4);
1681 print "<tr class=\"dark\">\n";
1683 print "<tr class=\"light\">\n";
1686 print "<td class=\"mode\">" . mode_str
($t_mode) . "</td>\n";
1687 if ($t_type eq "blob") {
1688 print "<td class=\"list\">" .
1689 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;h=$t_hash$base_key;f=$base$t_name"), -class => "list"}, esc_html
($t_name)) .
1691 "<td class=\"link\">" .
1692 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;h=$t_hash$base_key;f=$base$t_name")}, "blob") .
1693 # " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blame;h=$t_hash$base_key;f=$base$t_name")}, "blame") .
1694 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=history;h=$hash_base;f=$base$t_name")}, "history") .
1695 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob_plain;h=$t_hash;f=$base$t_name")}, "raw") .
1697 } elsif ($t_type eq "tree") {
1698 print "<td class=\"list\">" .
1699 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;h=$t_hash$base_key;f=$base$t_name")}, esc_html
($t_name)) .
1701 "<td class=\"link\">" .
1702 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;h=$t_hash$base_key;f=$base$t_name")}, "tree") .
1703 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=history;h=$hash_base;f=$base$t_name")}, "history") .
1708 print "</table>\n" .
1714 # http://www.notestips.com/80256B3A007F2692/1/NAMO5P9UPQ
1715 open my $fd, "-|", "$gitbin/git-rev-list --max-count=150 " . git_read_head
($project) or die_error
(undef, "Open failed.");
1716 my (@revlist) = map { chomp; $_ } <$fd>;
1717 close $fd or die_error
(undef, "Reading rev-list failed.");
1718 print $cgi->header(-type
=> 'text/xml', -charset
=> 'utf-8');
1719 print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n".
1720 "<rss version=\"2.0\" xmlns:content=\"http://purl.org/rss/1.0/modules/content/\">\n";
1721 print "<channel>\n";
1722 print "<title>$project</title>\n".
1723 "<link>" . esc_html
("$my_url?p=$project;a=summary") . "</link>\n".
1724 "<description>$project log</description>\n".
1725 "<language>en</language>\n";
1727 for (my $i = 0; $i <= $#revlist; $i++) {
1728 my $commit = $revlist[$i];
1729 my %co = git_read_commit
($commit);
1730 # we read 150, we always show 30 and the ones more recent than 48 hours
1731 if (($i >= 20) && ((time - $co{'committer_epoch'}) > 48*60*60)) {
1734 my %cd = date_str
($co{'committer_epoch'});
1735 open $fd, "-|", "$gitbin/git-diff-tree -r $co{'parent'} $co{'id'}" or next;
1736 my @difftree = map { chomp; $_ } <$fd>;
1740 sprintf("%d %s %02d:%02d", $cd{'mday'}, $cd{'month'}, $cd{'hour'}, $cd{'minute'}) . " - " . esc_html
($co{'title'}) .
1742 "<author>" . esc_html
($co{'author'}) . "</author>\n" .
1743 "<pubDate>$cd{'rfc2822'}</pubDate>\n" .
1744 "<guid isPermaLink=\"true\">" . esc_html
("$my_url?p=$project;a=commit;h=$commit") . "</guid>\n" .
1745 "<link>" . esc_html
("$my_url?p=$project;a=commit;h=$commit") . "</link>\n" .
1746 "<description>" . esc_html
($co{'title'}) . "</description>\n" .
1747 "<content:encoded>" .
1749 my $comment = $co{'comment'};
1750 foreach my $line (@
$comment) {
1751 $line = decode
("utf8", $line, Encode
::FB_DEFAULT
);
1752 print "$line<br/>\n";
1755 foreach my $line (@difftree) {
1756 if (!($line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)([0-9]{0,3})\t(.*)$/)) {
1759 my $file = validate_input
(unquote
($7));
1760 $file = decode
("utf8", $file, Encode
::FB_DEFAULT
);
1761 print "$file<br/>\n";
1764 "</content:encoded>\n" .
1767 print "</channel></rss>";
1771 my @list = git_read_projects
();
1773 print $cgi->header(-type
=> 'text/xml', -charset
=> 'utf-8');
1774 print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n".
1775 "<opml version=\"1.0\">\n".
1777 " <title>$site_name Git OPML Export</title>\n".
1780 "<outline text=\"git RSS feeds\">\n";
1782 foreach my $pr (@list) {
1784 my $head = git_read_head
($proj{'path'});
1785 if (!defined $head) {
1788 $ENV{'GIT_DIR'} = "$projectroot/$proj{'path'}";
1789 my %co = git_read_commit
($head);
1794 my $path = esc_html
(chop_str
($proj{'path'}, 25, 5));
1795 my $rss = "$my_url?p=$proj{'path'};a=rss";
1796 my $html = "$my_url?p=$proj{'path'};a=summary";
1797 print "<outline type=\"rss\" text=\"$path\" title=\"$path\" xmlUrl=\"$rss\" htmlUrl=\"$html\"/>\n";
1799 print "</outline>\n".
1805 my $head = git_read_head
($project);
1806 if (!defined $hash) {
1809 if (!defined $page) {
1812 my $refs = read_info_ref
();
1814 print "<div class=\"page_nav\">\n";
1815 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary")}, "summary") .
1816 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog;h=$hash")}, "shortlog") .
1818 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash")}, "commit") .
1819 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$hash")}, "commitdiff") .
1820 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;h=$hash;hb=$hash")}, "tree") . "<br/>\n";
1822 my $limit = sprintf("--max-count=%i", (100 * ($page+1)));
1823 open my $fd, "-|", "$gitbin/git-rev-list $limit $hash" or die_error
(undef, "Open failed.");
1824 my (@revlist) = map { chomp; $_ } <$fd>;
1827 if ($hash ne $head || $page) {
1828 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log")}, "HEAD");
1834 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log;h=$hash;pg=" . ($page-1)), -accesskey
=> "p", -title
=> "Alt-p"}, "prev");
1836 print " ⋅ prev";
1838 if ($#revlist >= (100 * ($page+1)-1)) {
1840 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log;h=$hash;pg=" . ($page+1)), -accesskey
=> "n", -title
=> "Alt-n"}, "next");
1842 print " ⋅ next";
1848 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary"), -class => "title"}, " ") .
1850 my %co = git_read_commit
($hash);
1851 print "<div class=\"page_body\"> Last change $co{'age_string'}.<br/><br/></div>\n";
1853 for (my $i = ($page * 100); $i <= $#revlist; $i++) {
1854 my $commit = $revlist[$i];
1856 if (defined $refs->{$commit}) {
1857 $ref = " <span class=\"tag\">" . esc_html
($refs->{$commit}) . "</span>";
1859 my %co = git_read_commit
($commit);
1861 my %ad = date_str
($co{'author_epoch'});
1863 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$commit"), -class => "title"},
1864 "<span class=\"age\">$co{'age_string'}</span>" . esc_html
($co{'title'}) . $ref) . "\n";
1866 print "<div class=\"title_text\">\n" .
1867 "<div class=\"log_link\">\n" .
1868 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$commit")}, "commit") .
1869 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$commit")}, "commitdiff") .
1872 "<i>" . esc_html
($co{'author_name'}) . " [$ad{'rfc2822'}]</i><br/>\n" .
1874 "<div class=\"log_body\">\n";
1875 my $comment = $co{'comment'};
1877 foreach my $line (@
$comment) {
1878 if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
1889 print format_log_line_html
($line) . "<br/>\n";
1900 my %co = git_read_commit
($hash);
1902 die_error
(undef, "Unknown commit object.");
1904 my %ad = date_str
($co{'author_epoch'}, $co{'author_tz'});
1905 my %cd = date_str
($co{'committer_epoch'}, $co{'committer_tz'});
1909 my $parent = $co{'parent'};
1910 if (!defined $parent) {
1914 open my $fd, "-|", "$gitbin/git-diff-tree -r -M $root $parent $hash" or die_error
(undef, "Open failed.");
1915 @difftree = map { chomp; $_ } <$fd>;
1916 close $fd or die_error
(undef, "Reading diff-tree failed.");
1918 # non-textual hash id's can be cached
1920 if ($hash =~ m/^[0-9a-fA-F]{40}$/) {
1923 my $refs = read_info_ref
();
1925 if (defined $refs->{$co{'id'}}) {
1926 $ref = " <span class=\"tag\">" . esc_html
($refs->{$co{'id'}}) . "</span>";
1928 git_header_html
(undef, $expires);
1929 print "<div class=\"page_nav\">\n" .
1930 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary")}, "summary") .
1931 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog;h=$hash")}, "shortlog") .
1932 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log;h=$hash")}, "log") .
1934 if (defined $co{'parent'}) {
1935 print " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$hash")}, "commitdiff");
1937 print " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") . "\n" .
1938 "<br/><br/></div>\n";
1939 if (defined $co{'parent'}) {
1941 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$hash"), -class => "title"}, esc_html
($co{'title'}) . $ref) . "\n" .
1945 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;h=$co{'tree'};hb=$hash"), -class => "title"}, esc_html
($co{'title'})) . "\n" .
1948 print "<div class=\"title_text\">\n" .
1949 "<table cellspacing=\"0\">\n";
1950 print "<tr><td>author</td><td>" . esc_html
($co{'author'}) . "</td></tr>\n".
1952 "<td></td><td> $ad{'rfc2822'}";
1953 if ($ad{'hour_local'} < 6) {
1954 printf(" (<span class=\"atnight\">%02d:%02d</span> %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
1956 printf(" (%02d:%02d %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
1960 print "<tr><td>committer</td><td>" . esc_html
($co{'committer'}) . "</td></tr>\n";
1961 print "<tr><td></td><td> $cd{'rfc2822'}" . sprintf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}) . "</td></tr>\n";
1962 print "<tr><td>commit</td><td class=\"sha1\">$co{'id'}</td></tr>\n";
1965 "<td class=\"sha1\">" .
1966 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;h=$co{'tree'};hb=$hash"), class => "list"}, $co{'tree'}) .
1968 "<td class=\"link\">" . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") .
1971 my $parents = $co{'parents'};
1972 foreach my $par (@
$parents) {
1975 "<td class=\"sha1\">" . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$par"), class => "list"}, $par) . "</td>" .
1976 "<td class=\"link\">" .
1977 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$par")}, "commit") .
1978 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$hash;hp=$par")}, "commitdiff") .
1984 print "<div class=\"page_body\">\n";
1985 my $comment = $co{'comment'};
1988 foreach my $line (@
$comment) {
1989 # print only one empty line
1991 if ($empty || $signed) {
1998 if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
2000 print "<span class=\"signoff\">" . esc_html
($line) . "</span><br/>\n";
2003 print format_log_line_html
($line) . "<br/>\n";
2007 print "<div class=\"list_head\">\n";
2008 if ($#difftree > 10) {
2009 print(($#difftree + 1) . " files changed:\n");
2012 print "<table class=\"diff_tree\">\n";
2014 foreach my $line (@difftree) {
2015 # ':100644 100644 03b218260e99b78c6df0ed378e59ed9205ccc96d 3b93d5e7cc7f7dd4ebed13a5cc1a4ad976fc94d8 M ls-files.c'
2016 # ':100644 100644 7f9281985086971d3877aca27704f2aaf9c448ce bc190ebc71bbd923f2b728e505408f5e54bd073a M rev-tree.c'
2017 if (!($line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)([0-9]{0,3})\t(.*)$/)) {
2025 my $similarity = $6;
2026 my $file = validate_input
(unquote
($7));
2028 print "<tr class=\"dark\">\n";
2030 print "<tr class=\"light\">\n";
2033 if ($status eq "A") {
2035 if (S_ISREG
(oct $to_mode)) {
2036 $mode_chng = sprintf(" with mode: %04o", (oct $to_mode) & 0777);
2039 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;h=$to_id;hb=$hash;f=$file"), -class => "list"}, esc_html
($file)) . "</td>\n" .
2040 "<td><span class=\"file_status new\">[new " . file_type
($to_mode) . "$mode_chng]</span></td>\n" .
2041 "<td class=\"link\">" . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, "blob") . "</td>\n";
2042 } elsif ($status eq "D") {
2044 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;h=$from_id;hb=$hash;f=$file"), -class => "list"}, esc_html
($file)) . "</td>\n" .
2045 "<td><span class=\"file_status deleted\">[deleted " . file_type
($from_mode). "]</span></td>\n" .
2046 "<td class=\"link\">" .
2047 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;h=$from_id;hb=$hash;f=$file")}, "blob") .
2048 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=history;h=$hash;f=$file")}, "history") .
2050 } elsif ($status eq "M" || $status eq "T") {
2051 my $mode_chnge = "";
2052 if ($from_mode != $to_mode) {
2053 $mode_chnge = " <span class=\"file_status mode_chnge\">[changed";
2054 if (((oct $from_mode) & S_IFMT
) != ((oct $to_mode) & S_IFMT
)) {
2055 $mode_chnge .= " from " . file_type
($from_mode) . " to " . file_type
($to_mode);
2057 if (((oct $from_mode) & 0777) != ((oct $to_mode) & 0777)) {
2058 if (S_ISREG
($from_mode) && S_ISREG
($to_mode)) {
2059 $mode_chnge .= sprintf(" mode: %04o->%04o", (oct $from_mode) & 0777, (oct $to_mode) & 0777);
2060 } elsif (S_ISREG
($to_mode)) {
2061 $mode_chnge .= sprintf(" mode: %04o", (oct $to_mode) & 0777);
2064 $mode_chnge .= "]</span>\n";
2067 if ($to_id ne $from_id) {
2068 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file"), -class => "list"}, esc_html
($file));
2070 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;h=$to_id;hb=$hash;f=$file"), -class => "list"}, esc_html
($file));
2073 "<td>$mode_chnge</td>\n" .
2074 "<td class=\"link\">";
2075 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, "blob");
2076 if ($to_id ne $from_id) {
2077 print " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file")}, "diff");
2079 print " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=history;h=$hash;f=$file")}, "history") . "\n";
2081 } elsif ($status eq "R") {
2082 my ($from_file, $to_file) = split "\t", $file;
2084 if ($from_mode != $to_mode) {
2085 $mode_chng = sprintf(", mode: %04o", (oct $to_mode) & 0777);
2088 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;h=$to_id;hb=$hash;f=$to_file"), -class => "list"}, esc_html
($to_file)) . "</td>\n" .
2089 "<td><span class=\"file_status moved\">[moved from " .
2090 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;h=$from_id;hb=$hash;f=$from_file"), -class => "list"}, esc_html
($from_file)) .
2091 " with " . (int $similarity) . "% similarity$mode_chng]</span></td>\n" .
2092 "<td class=\"link\">" .
2093 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;h=$to_id;hb=$hash;f=$to_file")}, "blob");
2094 if ($to_id ne $from_id) {
2095 print " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$to_file")}, "diff");
2106 mkdir($git_temp, 0700);
2108 if (defined $hash_base && (my %co = git_read_commit
($hash_base))) {
2109 print "<div class=\"page_nav\">\n" .
2110 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary")}, "summary") .
2111 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog")}, "shortlog") .
2112 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log")}, "log") .
2113 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash_base")}, "commit") .
2114 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$hash_base")}, "commitdiff") .
2115 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;h=$co{'tree'};hb=$hash_base")}, "tree") .
2117 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blobdiff_plain;h=$hash;hp=$hash_parent")}, "plain") .
2120 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash_base"), -class => "title"}, esc_html
($co{'title'})) . "\n" .
2123 print "<div class=\"page_nav\">\n" .
2124 "<br/><br/></div>\n" .
2125 "<div class=\"title\">$hash vs $hash_parent</div>\n";
2127 if (defined $file_name) {
2128 print "<div class=\"page_path\"><b>/" . esc_html
($file_name) . "</b></div>\n";
2130 print "<div class=\"page_body\">\n" .
2131 "<div class=\"diff_info\">blob:" .
2132 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;h=$hash_parent;hb=$hash_base;f=$file_name")}, $hash_parent) .
2134 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;h=$hash;hb=$hash_base;f=$file_name")}, $hash) .
2136 git_diff_print
($hash_parent, $file_name || $hash_parent, $hash, $file_name || $hash);
2141 sub git_blobdiff_plain
{
2142 mkdir($git_temp, 0700);
2143 print $cgi->header(-type
=> "text/plain", -charset
=> 'utf-8');
2144 git_diff_print
($hash_parent, $file_name || $hash_parent, $hash, $file_name || $hash, "plain");
2147 sub git_commitdiff
{
2148 mkdir($git_temp, 0700);
2149 my %co = git_read_commit
($hash);
2151 die_error
(undef, "Unknown commit object.");
2153 if (!defined $hash_parent) {
2154 $hash_parent = $co{'parent'};
2156 open my $fd, "-|", "$gitbin/git-diff-tree -r $hash_parent $hash" or die_error
(undef, "Open failed.");
2157 my (@difftree) = map { chomp; $_ } <$fd>;
2158 close $fd or die_error
(undef, "Reading diff-tree failed.");
2160 # non-textual hash id's can be cached
2162 if ($hash =~ m/^[0-9a-fA-F]{40}$/) {
2165 my $refs = read_info_ref
();
2167 if (defined $refs->{$co{'id'}}) {
2168 $ref = " <span class=\"tag\">" . esc_html
($refs->{$co{'id'}}) . "</span>";
2170 git_header_html
(undef, $expires);
2171 print "<div class=\"page_nav\">\n" .
2172 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary")}, "summary") .
2173 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog;h=$hash")}, "shortlog") .
2174 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log;h=$hash")}, "log") .
2175 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash")}, "commit") .
2177 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") . "<br/>\n";
2178 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff_plain;h=$hash;hp=$hash_parent")}, "plain") . "\n" .
2181 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash"), -class => "title"}, esc_html
($co{'title'}) . $ref) . "\n" .
2183 print "<div class=\"page_body\">\n";
2184 my $comment = $co{'comment'};
2187 my @log = @
$comment;
2188 # remove first and empty lines after that
2190 while (defined $log[0] && $log[0] eq "") {
2193 foreach my $line (@log) {
2194 if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
2205 print format_log_line_html
($line) . "<br/>\n";
2208 foreach my $line (@difftree) {
2209 # ':100644 100644 03b218260e99b78c6df0ed378e59ed9205ccc96d 3b93d5e7cc7f7dd4ebed13a5cc1a4ad976fc94d8 M ls-files.c'
2210 # ':100644 100644 7f9281985086971d3877aca27704f2aaf9c448ce bc190ebc71bbd923f2b728e505408f5e54bd073a M rev-tree.c'
2211 $line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$/;
2217 my $file = validate_input
(unquote
($6));
2218 if ($status eq "A") {
2219 print "<div class=\"diff_info\">" . file_type
($to_mode) . ":" .
2220 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, $to_id) . "(new)" .
2222 git_diff_print
(undef, "/dev/null", $to_id, "b/$file");
2223 } elsif ($status eq "D") {
2224 print "<div class=\"diff_info\">" . file_type
($from_mode) . ":" .
2225 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;h=$from_id;hb=$hash;f=$file")}, $from_id) . "(deleted)" .
2227 git_diff_print
($from_id, "a/$file", undef, "/dev/null");
2228 } elsif ($status eq "M") {
2229 if ($from_id ne $to_id) {
2230 print "<div class=\"diff_info\">" .
2231 file_type
($from_mode) . ":" . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;h=$from_id;hb=$hash;f=$file")}, $from_id) .
2233 file_type
($to_mode) . ":" . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, $to_id);
2235 git_diff_print
($from_id, "a/$file", $to_id, "b/$file");
2244 sub git_commitdiff_plain
{
2245 mkdir($git_temp, 0700);
2246 open my $fd, "-|", "$gitbin/git-diff-tree -r $hash_parent $hash" or die_error
(undef, "Open failed.");
2247 my (@difftree) = map { chomp; $_ } <$fd>;
2248 close $fd or die_error
(undef, "Reading diff-tree failed.");
2250 # try to figure out the next tag after this commit
2252 my $refs = read_info_ref
("tags");
2253 open $fd, "-|", "$gitbin/git-rev-list HEAD";
2254 chomp (my (@commits) = <$fd>);
2256 foreach my $commit (@commits) {
2257 if (defined $refs->{$commit}) {
2258 $tagname = $refs->{$commit}
2260 if ($commit eq $hash) {
2265 print $cgi->header(-type
=> "text/plain", -charset
=> 'utf-8', '-content-disposition' => "inline; filename=\"git-$hash.patch\"");
2266 my %co = git_read_commit
($hash);
2267 my %ad = date_str
($co{'author_epoch'}, $co{'author_tz'});
2268 my $comment = $co{'comment'};
2269 print "From: $co{'author'}\n" .
2270 "Date: $ad{'rfc2822'} ($ad{'tz_local'})\n".
2271 "Subject: $co{'title'}\n";
2272 if (defined $tagname) {
2273 print "X-Git-Tag: $tagname\n";
2275 print "X-Git-Url: $my_url?p=$project;a=commitdiff;h=$hash\n" .
2278 foreach my $line (@
$comment) {;
2283 foreach my $line (@difftree) {
2284 $line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$/;
2289 if ($status eq "A") {
2290 git_diff_print
(undef, "/dev/null", $to_id, "b/$file", "plain");
2291 } elsif ($status eq "D") {
2292 git_diff_print
($from_id, "a/$file", undef, "/dev/null", "plain");
2293 } elsif ($status eq "M") {
2294 git_diff_print
($from_id, "a/$file", $to_id, "b/$file", "plain");
2300 if (!defined $hash) {
2301 $hash = git_read_head
($project);
2303 my %co = git_read_commit
($hash);
2305 die_error
(undef, "Unknown commit object.");
2307 my $refs = read_info_ref
();
2309 print "<div class=\"page_nav\">\n" .
2310 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary")}, "summary") .
2311 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog")}, "shortlog") .
2312 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log")}, "log") .
2313 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash")}, "commit") .
2314 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$hash")}, "commitdiff") .
2315 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") .
2319 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash"), -class => "title"}, esc_html
($co{'title'})) . "\n" .
2321 print "<div class=\"page_path\"><b>/" . esc_html
($file_name) . "</b><br/></div>\n";
2324 "$gitbin/git-rev-list --full-history $hash -- \'$file_name\'";
2325 print "<table cellspacing=\"0\">\n";
2327 while (my $line = <$fd>) {
2328 if ($line =~ m/^([0-9a-fA-F]{40})/){
2330 my %co = git_read_commit
($commit);
2335 if (defined $refs->{$commit}) {
2336 $ref = " <span class=\"tag\">" . esc_html
($refs->{$commit}) . "</span>";
2339 print "<tr class=\"dark\">\n";
2341 print "<tr class=\"light\">\n";
2344 print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
2345 "<td><i>" . esc_html
(chop_str
($co{'author_name'}, 15, 3)) . "</i></td>\n" .
2346 "<td>" . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$commit"), -class => "list"}, "<b>" .
2347 esc_html
(chop_str
($co{'title'}, 50)) . "$ref</b>") . "</td>\n" .
2348 "<td class=\"link\">" .
2349 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$commit")}, "commit") .
2350 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$commit")}, "commitdiff") .
2351 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;hb=$commit;f=$file_name")}, "blob");
2352 my $blob = git_get_hash_by_path
($hash, $file_name);
2353 my $blob_parent = git_get_hash_by_path
($commit, $file_name);
2354 if (defined $blob && defined $blob_parent && $blob ne $blob_parent) {
2356 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blobdiff;h=$blob;hp=$blob_parent;hb=$commit;f=$file_name")},
2369 if (!defined $searchtext) {
2370 die_error
("", "Text field empty.");
2372 if (!defined $hash) {
2373 $hash = git_read_head
($project);
2375 my %co = git_read_commit
($hash);
2377 die_error
(undef, "Unknown commit object.");
2379 # pickaxe may take all resources of your box and run for several minutes
2380 # with every query - so decide by yourself how public you make this feature :)
2381 my $commit_search = 1;
2382 my $author_search = 0;
2383 my $committer_search = 0;
2384 my $pickaxe_search = 0;
2385 if ($searchtext =~ s/^author\\://i) {
2387 } elsif ($searchtext =~ s/^committer\\://i) {
2388 $committer_search = 1;
2389 } elsif ($searchtext =~ s/^pickaxe\\://i) {
2391 $pickaxe_search = 1;
2394 print "<div class=\"page_nav\">\n" .
2395 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary;h=$hash")}, "summary") .
2396 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog")}, "shortlog") .
2397 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log;h=$hash")}, "log") .
2398 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash")}, "commit") .
2399 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$hash")}, "commitdiff") .
2400 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") .
2405 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash"), -class => "title"}, esc_html
($co{'title'})) . "\n" .
2407 print "<table cellspacing=\"0\">\n";
2409 if ($commit_search) {
2411 open my $fd, "-|", "$gitbin/git-rev-list --header --parents $hash" or next;
2412 while (my $commit_text = <$fd>) {
2413 if (!grep m/$searchtext/i, $commit_text) {
2416 if ($author_search && !grep m/\nauthor .*$searchtext/i, $commit_text) {
2419 if ($committer_search && !grep m/\ncommitter .*$searchtext/i, $commit_text) {
2422 my @commit_lines = split "\n", $commit_text;
2423 my %co = git_read_commit
(undef, \
@commit_lines);
2428 print "<tr class=\"dark\">\n";
2430 print "<tr class=\"light\">\n";
2433 print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
2434 "<td><i>" . esc_html
(chop_str
($co{'author_name'}, 15, 5)) . "</i></td>\n" .
2436 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$co{'id'}"), -class => "list"}, "<b>" . esc_html
(chop_str
($co{'title'}, 50)) . "</b><br/>");
2437 my $comment = $co{'comment'};
2438 foreach my $line (@
$comment) {
2439 if ($line =~ m/^(.*)($searchtext)(.*)$/i) {
2440 my $lead = esc_html
($1) || "";
2441 $lead = chop_str
($lead, 30, 10);
2442 my $match = esc_html
($2) || "";
2443 my $trail = esc_html
($3) || "";
2444 $trail = chop_str
($trail, 30, 10);
2445 my $text = "$lead<span class=\"match\">$match</span>$trail";
2446 print chop_str
($text, 80, 5) . "<br/>\n";
2450 "<td class=\"link\">" .
2451 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$co{'id'}")}, "commit") .
2452 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;h=$co{'tree'};hb=$co{'id'}")}, "tree");
2459 if ($pickaxe_search) {
2461 open my $fd, "-|", "$gitbin/git-rev-list $hash | $gitbin/git-diff-tree -r --stdin -S\'$searchtext\'";
2464 while (my $line = <$fd>) {
2465 if (%co && $line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$/) {
2468 $set{'from_id'} = $3;
2470 $set{'id'} = $set{'to_id'};
2471 if ($set{'id'} =~ m/0{40}/) {
2472 $set{'id'} = $set{'from_id'};
2474 if ($set{'id'} =~ m/0{40}/) {
2478 } elsif ($line =~ m/^([0-9a-fA-F]{40})$/){
2481 print "<tr class=\"dark\">\n";
2483 print "<tr class=\"light\">\n";
2486 print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
2487 "<td><i>" . esc_html
(chop_str
($co{'author_name'}, 15, 5)) . "</i></td>\n" .
2489 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$co{'id'}"), -class => "list"}, "<b>" .
2490 esc_html
(chop_str
($co{'title'}, 50)) . "</b><br/>");
2491 while (my $setref = shift @files) {
2493 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;h=$set{'id'};hb=$co{'id'};f=$set{'file'}"), class => "list"},
2494 "<span class=\"match\">" . esc_html
($set{'file'}) . "</span>") .
2498 "<td class=\"link\">" .
2499 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$co{'id'}")}, "commit") .
2500 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;h=$co{'tree'};hb=$co{'id'}")}, "tree");
2504 %co = git_read_commit
($1);
2514 my $head = git_read_head
($project);
2515 if (!defined $hash) {
2518 if (!defined $page) {
2521 my $refs = read_info_ref
();
2523 print "<div class=\"page_nav\">\n" .
2524 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary")}, "summary") .
2526 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log;h=$hash")}, "log") .
2527 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash")}, "commit") .
2528 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$hash")}, "commitdiff") .
2529 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;h=$hash;hb=$hash")}, "tree") . "<br/>\n";
2531 my $limit = sprintf("--max-count=%i", (100 * ($page+1)));
2532 open my $fd, "-|", "$gitbin/git-rev-list $limit $hash" or die_error
(undef, "Open failed.");
2533 my (@revlist) = map { chomp; $_ } <$fd>;
2536 if ($hash ne $head || $page) {
2537 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog")}, "HEAD");
2543 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog;h=$hash;pg=" . ($page-1)), -accesskey
=> "p", -title
=> "Alt-p"}, "prev");
2545 print " ⋅ prev";
2547 if ($#revlist >= (100 * ($page+1)-1)) {
2549 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog;h=$hash;pg=" . ($page+1)), -accesskey
=> "n", -title
=> "Alt-n"}, "next");
2551 print " ⋅ next";
2556 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary"), -class => "title"}, " ") .
2558 print "<table cellspacing=\"0\">\n";
2560 for (my $i = ($page * 100); $i <= $#revlist; $i++) {
2561 my $commit = $revlist[$i];
2563 if (defined $refs->{$commit}) {
2564 $ref = " <span class=\"tag\">" . esc_html
($refs->{$commit}) . "</span>";
2566 my %co = git_read_commit
($commit);
2567 my %ad = date_str
($co{'author_epoch'});
2569 print "<tr class=\"dark\">\n";
2571 print "<tr class=\"light\">\n";
2574 print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
2575 "<td><i>" . esc_html
(chop_str
($co{'author_name'}, 10)) . "</i></td>\n" .
2577 if (length($co{'title_short'}) < length($co{'title'})) {
2578 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$commit"), -class => "list", -title
=> "$co{'title'}"},
2579 "<b>" . esc_html
($co{'title_short'}) . "$ref</b>");
2581 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$commit"), -class => "list"},
2582 "<b>" . esc_html
($co{'title_short'}) . "$ref</b>");
2585 "<td class=\"link\">" .
2586 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$commit")}, "commit") .
2587 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$commit")}, "commitdiff") .
2591 if ($#revlist >= (100 * ($page+1)-1)) {
2594 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog;h=$hash;pg=" . ($page+1)), -title
=> "Alt-n"}, "next") .