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 # core git executable to use
26 # this can just be "git" if your webserver has a sensible PATH
27 our $GIT = "/usr/bin/git";
29 # absolute fs-path which will be prepended to the project path
30 #our $projectroot = "/pub/scm";
31 our $projectroot = "/home/kay/public_html/pub/scm";
33 # version of the core git binary
34 our $git_version = qx($GIT --version) =~ m/git version (.*)$/ ? $1 : "unknown";
36 # location for temporary files needed for diffs
37 our $git_temp = "/tmp/gitweb";
39 mkdir($git_temp, 0700) || die_error
("Couldn't mkdir $git_temp");
42 # target of the home link on top of all pages
43 our $home_link = $my_uri;
45 # name of your site or organization to appear in page titles
46 # replace this with something more descriptive for clearer bookmarks
47 our $site_name = $ENV{'SERVER_NAME'} || "Untitled";
49 # html text to include at home page
50 our $home_text = "indextext.html";
52 # URI of default stylesheet
53 our $stylesheet = "gitweb.css";
55 # source of projects list
56 #our $projects_list = $projectroot;
57 our $projects_list = "index/index.aux";
59 # default blob_plain mimetype and default charset for text/plain blob
60 our $default_blob_plain_mimetype = 'text/plain';
61 our $default_text_plain_charset = undef;
63 # file to use for guessing MIME types before trying /etc/mime.types
64 # (relative to the current git repository)
65 our $mimetypes_file = undef;
67 # input validation and dispatch
68 our $action = $cgi->param('a');
69 if (defined $action) {
70 if ($action =~ m/[^0-9a-zA-Z\.\-_]/) {
72 die_error
(undef, "Invalid action parameter.");
74 if ($action eq "git-logo.png") {
77 } elsif ($action eq "opml") {
83 our $order = $cgi->param('o');
85 if ($order =~ m/[^0-9a-zA-Z_]/) {
87 die_error
(undef, "Invalid order parameter.");
91 our $project = ($cgi->param('p') || $ENV{'PATH_INFO'});
92 if (defined $project) {
93 $project =~ s
|^/||; $project =~ s|/$||;
94 $project = validate_input
($project);
95 if (!defined($project)) {
96 die_error
(undef, "Invalid project parameter.");
98 if (!(-d
"$projectroot/$project")) {
100 die_error
(undef, "No such directory.");
102 if (!(-e
"$projectroot/$project/HEAD")) {
104 die_error
(undef, "No such project.");
106 $rss_link = "<link rel=\"alternate\" title=\"" . esc_param
($project) . " log\" href=\"" .
107 "$my_uri?" . esc_param
("p=$project;a=rss") . "\" type=\"application/rss+xml\"/>";
108 $ENV{'GIT_DIR'} = "$projectroot/$project";
114 our $file_name = $cgi->param('f');
115 if (defined $file_name) {
116 $file_name = validate_input
($file_name);
117 if (!defined($file_name)) {
118 die_error
(undef, "Invalid file parameter.");
122 our $hash = $cgi->param('h');
124 $hash = validate_input
($hash);
125 if (!defined($hash)) {
126 die_error
(undef, "Invalid hash parameter.");
130 our $hash_parent = $cgi->param('hp');
131 if (defined $hash_parent) {
132 $hash_parent = validate_input
($hash_parent);
133 if (!defined($hash_parent)) {
134 die_error
(undef, "Invalid hash parent parameter.");
138 our $hash_base = $cgi->param('hb');
139 if (defined $hash_base) {
140 $hash_base = validate_input
($hash_base);
141 if (!defined($hash_base)) {
142 die_error
(undef, "Invalid hash base parameter.");
146 our $page = $cgi->param('pg');
148 if ($page =~ m/[^0-9]$/) {
150 die_error
(undef, "Invalid page parameter.");
154 our $searchtext = $cgi->param('s');
155 if (defined $searchtext) {
156 if ($searchtext =~ m/[^a-zA-Z0-9_\.\/\
-\
+\
:\
@ ]/) {
158 die_error
(undef, "Invalid search parameter.");
160 $searchtext = quotemeta $searchtext;
166 if ($input =~ m/^[0-9a-fA-F]{40}$/) {
169 if ($input =~ m/(^|\/)(|\
.|\
.\
.)($|\
/)/) {
172 if ($input =~ m/[^a-zA-Z0-9_\x80-\xff\ \t\.\/\
-\
+\#\
~\
%]/) {
178 if (!defined $action || $action eq "summary") {
181 } elsif ($action eq "heads") {
184 } elsif ($action eq "tags") {
187 } elsif ($action eq "blob") {
190 } elsif ($action eq "blob_plain") {
193 } elsif ($action eq "tree") {
196 } elsif ($action eq "rss") {
199 } elsif ($action eq "commit") {
202 } elsif ($action eq "log") {
205 } elsif ($action eq "blobdiff") {
208 } elsif ($action eq "blobdiff_plain") {
209 git_blobdiff_plain
();
211 } elsif ($action eq "commitdiff") {
214 } elsif ($action eq "commitdiff_plain") {
215 git_commitdiff_plain
();
217 } elsif ($action eq "history") {
220 } elsif ($action eq "search") {
223 } elsif ($action eq "shortlog") {
226 } elsif ($action eq "tag") {
229 } elsif ($action eq "blame") {
234 die_error
(undef, "Unknown action.");
238 # quote unsafe chars, but keep the slash, even when it's not
239 # correct, but quoted slashes look too horrible in bookmarks
242 $str =~ s/([^A-Za-z0-9\-_.~();\/;?:@&=])/sprintf
("%%%02X", ord($1))/eg
;
248 # replace invalid utf8 character with SUBSTITUTION sequence
251 $str = decode
("utf8", $str, Encode
::FB_DEFAULT
);
252 $str = escapeHTML
($str);
256 # git may return quoted and escaped filenames
259 if ($str =~ m/^"(.*)"$/) {
261 $str =~ s/\\([0-7]{1,3})/chr(oct($1))/eg;
266 # CSS class for given age value (in seconds)
270 if ($age < 60*60*2) {
272 } elsif ($age < 60*60*24*2) {
279 sub git_header_html
{
280 my $status = shift || "200 OK";
283 my $title = "$site_name git";
284 if (defined $project) {
285 $title .= " - $project";
286 if (defined $action) {
287 $title .= "/$action";
288 if (defined $file_name) {
289 $title .= " - $file_name";
290 if ($action eq "tree" && $file_name !~ m
|/$|) {
297 # require explicit support from the UA if we are to send the page as
298 # 'application/xhtml+xml', otherwise send it as plain old 'text/html'.
299 # we have to do this because MSIE sometimes globs '*/*', pretending to
300 # support xhtml+xml but choking when it gets what it asked for.
301 if ($cgi->http('HTTP_ACCEPT') =~ m/(,|;|\s|^)application\/xhtml\
+xml
(,|;|\s
|$)/ && $cgi->Accept('application/xhtml
+xml
') != 0) {
302 $content_type = 'application
/xhtml
+xml
';
304 $content_type = 'text
/html
';
306 print $cgi->header(-type=>$content_type, -charset => 'utf-8
', -status=> $status, -expires => $expires);
308 <?xml version="1.0" encoding="utf-8"?>
309 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
310 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
311 <!-- git web interface v$version, (C) 2005-2006, Kay Sievers <kay.sievers\@vrfy.org>, Christian Gierke -->
312 <!-- git core binaries version $git_version -->
314 <meta http-equiv="content-type" content="$content_type; charset=utf-8"/>
315 <meta name="robots" content="index, nofollow"/>
316 <title>$title</title>
317 <link rel="stylesheet" type="text/css" href="$stylesheet"/>
322 print "<div class=\"page_header\">\n" .
323 "<a href=\"http://www.kernel.org/pub/software/scm/git/docs/\" title=\"git documentation\">" .
324 "<img src=\"$my_uri?" . esc_param
("a=git-logo.png") . "\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/>" .
326 print $cgi->a({-href
=> esc_param
($home_link)}, "projects") . " / ";
327 if (defined $project) {
328 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary")}, esc_html
($project));
329 if (defined $action) {
333 if (!defined $searchtext) {
337 if (defined $hash_base) {
338 $search_hash = $hash_base;
339 } elsif (defined $hash) {
340 $search_hash = $hash;
342 $search_hash = "HEAD";
344 $cgi->param("a", "search");
345 $cgi->param("h", $search_hash);
346 print $cgi->startform(-method => "get", -action
=> $my_uri) .
347 "<div class=\"search\">\n" .
348 $cgi->hidden(-name
=> "p") . "\n" .
349 $cgi->hidden(-name
=> "a") . "\n" .
350 $cgi->hidden(-name
=> "h") . "\n" .
351 $cgi->textfield(-name
=> "s", -value
=> $searchtext) . "\n" .
353 $cgi->end_form() . "\n";
358 sub git_footer_html
{
359 print "<div class=\"page_footer\">\n";
360 if (defined $project) {
361 my $descr = git_read_description
($project);
362 if (defined $descr) {
363 print "<div class=\"page_footer_text\">" . esc_html
($descr) . "</div>\n";
365 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=rss"), -class => "rss_logo"}, "RSS") . "\n";
367 print $cgi->a({-href
=> "$my_uri?" . esc_param
("a=opml"), -class => "rss_logo"}, "OPML") . "\n";
375 my $status = shift || "403 Forbidden";
376 my $error = shift || "Malformed query, file missing or permission denied";
378 git_header_html
($status);
379 print "<div class=\"page_body\">\n" .
381 "$status - $error\n" .
391 open my $fd, "-|", "$GIT cat-file -t $hash" or return;
400 my $oENV = $ENV{'GIT_DIR'};
402 $ENV{'GIT_DIR'} = "$projectroot/$project";
403 if (open my $fd, "-|", $GIT, "rev-parse", "--verify", "HEAD") {
406 if (defined $head && $head =~ /^([0-9a-fA-F]{40})$/) {
411 $ENV{'GIT_DIR'} = $oENV;
419 open my $fd, "$projectroot/$path" or return undef;
423 if ($head =~ m/^[0-9a-fA-F]{40}$/) {
428 sub git_read_description
{
431 open my $fd, "$projectroot/$path/description" or return undef;
443 open my $fd, "-|", "$GIT cat-file tag $tag_id" or return;
444 $tag{'id'} = $tag_id;
445 while (my $line = <$fd>) {
447 if ($line =~ m/^object ([0-9a-fA-F]{40})$/) {
449 } elsif ($line =~ m/^type (.+)$/) {
451 } elsif ($line =~ m/^tag (.+)$/) {
453 } elsif ($line =~ m/^tagger (.*) ([0-9]+) (.*)$/) {
457 } elsif ($line =~ m/--BEGIN/) {
458 push @comment, $line;
460 } elsif ($line eq "") {
464 push @comment, <$fd>;
465 $tag{'comment'} = \
@comment;
467 if (!defined $tag{'name'}) {
477 if ($age > 60*60*24*365*2) {
478 $age_str = (int $age/60/60/24/365);
479 $age_str .= " years ago";
480 } elsif ($age > 60*60*24*(365/12)*2) {
481 $age_str = int $age/60/60/24/(365/12);
482 $age_str .= " months ago";
483 } elsif ($age > 60*60*24*7*2) {
484 $age_str = int $age/60/60/24/7;
485 $age_str .= " weeks ago";
486 } elsif ($age > 60*60*24*2) {
487 $age_str = int $age/60/60/24;
488 $age_str .= " days ago";
489 } elsif ($age > 60*60*2) {
490 $age_str = int $age/60/60;
491 $age_str .= " hours ago";
492 } elsif ($age > 60*2) {
493 $age_str = int $age/60;
494 $age_str .= " min ago";
497 $age_str .= " sec ago";
499 $age_str .= " right now";
504 sub git_read_commit
{
505 my $commit_id = shift;
506 my $commit_text = shift;
511 if (defined $commit_text) {
512 @commit_lines = @$commit_text;
515 open my $fd, "-|", "$GIT rev-list --header --parents --max-count=1 $commit_id" or return;
516 @commit_lines = split '\n', <$fd>;
521 my $header = shift @commit_lines;
522 if (!($header =~ m/^[0-9a-fA-F]{40}/)) {
525 ($co{'id'}, my @parents) = split ' ', $header;
526 $co{'parents'} = \
@parents;
527 $co{'parent'} = $parents[0];
528 while (my $line = shift @commit_lines) {
529 last if $line eq "\n";
530 if ($line =~ m/^tree ([0-9a-fA-F]{40})$/) {
532 } elsif ($line =~ m/^author (.*) ([0-9]+) (.*)$/) {
534 $co{'author_epoch'} = $2;
535 $co{'author_tz'} = $3;
536 if ($co{'author'} =~ m/^([^<]+) </) {
537 $co{'author_name'} = $1;
539 $co{'author_name'} = $co{'author'};
541 } elsif ($line =~ m/^committer (.*) ([0-9]+) (.*)$/) {
542 $co{'committer'} = $1;
543 $co{'committer_epoch'} = $2;
544 $co{'committer_tz'} = $3;
545 $co{'committer_name'} = $co{'committer'};
546 $co{'committer_name'} =~ s/ <.*//;
549 if (!defined $co{'tree'}) {
553 foreach my $title (@commit_lines) {
556 $co{'title'} = chop_str
($title, 80, 5);
557 # remove leading stuff of merges to make the interesting part visible
558 if (length($title) > 50) {
559 $title =~ s/^Automatic //;
560 $title =~ s/^merge (of|with) /Merge ... /i;
561 if (length($title) > 50) {
562 $title =~ s/(http|rsync):\/\///;
564 if (length($title) > 50) {
565 $title =~ s/(master|www|rsync)\.//;
567 if (length($title) > 50) {
568 $title =~ s/kernel.org:?//;
570 if (length($title) > 50) {
571 $title =~ s/\/pub\/scm//;
574 $co{'title_short'} = chop_str
($title, 50, 5);
578 # remove added spaces
579 foreach my $line (@commit_lines) {
582 $co{'comment'} = \
@commit_lines;
584 my $age = time - $co{'committer_epoch'};
586 $co{'age_string'} = age_string
($age);
587 my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($co{'committer_epoch'});
588 if ($age > 60*60*24*7*2) {
589 $co{'age_string_date'} = sprintf "%4i-%02u-%02i", 1900 + $year, $mon+1, $mday;
590 $co{'age_string_age'} = $co{'age_string'};
592 $co{'age_string_date'} = $co{'age_string'};
593 $co{'age_string_age'} = sprintf "%4i-%02u-%02i", 1900 + $year, $mon+1, $mday;
600 my $from_name = shift;
603 my $format = shift || "html";
605 my $from_tmp = "/dev/null";
606 my $to_tmp = "/dev/null";
609 # create tmp from-file
611 $from_tmp = "$git_temp/gitweb_" . $$ . "_from";
612 open my $fd2, "> $from_tmp";
613 open my $fd, "-|", "$GIT cat-file blob $from";
622 $to_tmp = "$git_temp/gitweb_" . $$ . "_to";
623 open my $fd2, "> $to_tmp";
624 open my $fd, "-|", "$GIT cat-file blob $to";
631 open my $fd, "-|", "/usr/bin/diff -u -p -L \'$from_name\' -L \'$to_name\' $from_tmp $to_tmp";
632 if ($format eq "plain") {
637 while (my $line = <$fd>) {
639 my $char = substr($line, 0, 1);
642 $diff_class = " add";
643 } elsif ($char eq "-") {
644 $diff_class = " rem";
645 } elsif ($char eq "@") {
646 $diff_class = " chunk_header";
647 } elsif ($char eq "\\") {
651 while ((my $pos = index($line, "\t")) != -1) {
652 if (my $count = (8 - (($pos-1) % 8))) {
653 my $spaces = ' ' x
$count;
654 $line =~ s/\t/$spaces/;
657 print "<div class=\"diff$diff_class\">" . esc_html
($line) . "</div>\n";
671 my $mode = oct shift;
673 if (S_ISDIR
($mode & S_IFMT
)) {
675 } elsif (S_ISLNK
($mode)) {
677 } elsif (S_ISREG
($mode)) {
678 # git cares only about the executable bit
679 if ($mode & S_IXUSR
) {
692 my $add_len = shift || 10;
694 # allow only $len chars, but don't cut a word if it would fit in $add_len
695 # if it doesn't fit, cut it if it's still longer than the dots we would add
696 $str =~ m/^(.{0,$len}[^ \/\
-_
:\
.@]{0,$add_len})(.*)/;
699 if (length($tail) > 4) {
706 my $mode = oct shift;
708 if (S_ISDIR
($mode & S_IFMT
)) {
710 } elsif (S_ISLNK
($mode)) {
712 } elsif (S_ISREG
($mode)) {
719 sub format_log_line_html
{
722 $line = esc_html
($line);
723 $line =~ s/ / /g;
724 if ($line =~ m/([0-9a-fA-F]{40})/) {
726 if (git_get_type
($hash_text) eq "commit") {
727 my $link = $cgi->a({-class => "text", -href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash_text")}, $hash_text);
728 $line =~ s/$hash_text/$link/;
736 my $tz = shift || "-0000";
739 my @months = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
740 my @days = ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
741 my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($epoch);
742 $date{'hour'} = $hour;
743 $date{'minute'} = $min;
744 $date{'mday'} = $mday;
745 $date{'day'} = $days[$wday];
746 $date{'month'} = $months[$mon];
747 $date{'rfc2822'} = sprintf "%s, %d %s %4d %02d:%02d:%02d +0000", $days[$wday], $mday, $months[$mon], 1900+$year, $hour ,$min, $sec;
748 $date{'mday-time'} = sprintf "%d %s %02d:%02d", $mday, $months[$mon], $hour ,$min;
750 $tz =~ m/^([+\-][0-9][0-9])([0-9][0-9])$/;
751 my $local = $epoch + ((int $1 + ($2/60)) * 3600);
752 ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($local);
753 $date{'hour_local'} = $hour;
754 $date{'minute_local'} = $min;
755 $date{'tz_local'} = $tz;
759 # git-logo (cached in browser for one day)
761 binmode STDOUT
, ':raw';
762 print $cgi->header(-type
=> 'image/png', -expires
=> '+1d');
763 # cat git-logo.png | hexdump -e '16/1 " %02x" "\n"' | sed 's/ /\\x/g'
764 print "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52" .
765 "\x00\x00\x00\x48\x00\x00\x00\x1b\x04\x03\x00\x00\x00\x2d\xd9\xd4" .
766 "\x2d\x00\x00\x00\x18\x50\x4c\x54\x45\xff\xff\xff\x60\x60\x5d\xb0" .
767 "\xaf\xaa\x00\x80\x00\xce\xcd\xc7\xc0\x00\x00\xe8\xe8\xe6\xf7\xf7" .
768 "\xf6\x95\x0c\xa7\x47\x00\x00\x00\x73\x49\x44\x41\x54\x28\xcf\x63" .
769 "\x48\x67\x20\x04\x4a\x5c\x18\x0a\x08\x2a\x62\x53\x61\x20\x02\x08" .
770 "\x0d\x69\x45\xac\xa1\xa1\x01\x30\x0c\x93\x60\x36\x26\x52\x91\xb1" .
771 "\x01\x11\xd6\xe1\x55\x64\x6c\x6c\xcc\x6c\x6c\x0c\xa2\x0c\x70\x2a" .
772 "\x62\x06\x2a\xc1\x62\x1d\xb3\x01\x02\x53\xa4\x08\xe8\x00\x03\x18" .
773 "\x26\x56\x11\xd4\xe1\x20\x97\x1b\xe0\xb4\x0e\x35\x24\x71\x29\x82" .
774 "\x99\x30\xb8\x93\x0a\x11\xb9\x45\x88\xc1\x8d\xa0\xa2\x44\x21\x06" .
775 "\x27\x41\x82\x40\x85\xc1\x45\x89\x20\x70\x01\x00\xa4\x3d\x21\xc5" .
776 "\x12\x1c\x9a\xfe\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82";
782 my ($dev, $ino, $mode, $nlink, $st_uid, $st_gid, $rdev, $size) = stat($path);
783 my ($name, $passwd, $uid, $gid, $quota, $comment, $gcos, $dir, $shell) = getpwuid($st_uid);
784 if (!defined $gcos) {
788 $owner =~ s/[,;].*$//;
789 return decode
("utf8", $owner, Encode
::FB_DEFAULT
);
792 sub git_read_projects
{
795 if (-d
$projects_list) {
796 # search in directory
797 my $dir = $projects_list;
798 opendir my $dh, $dir or return undef;
799 while (my $dir = readdir($dh)) {
800 if (-e
"$projectroot/$dir/HEAD") {
808 } elsif (-f
$projects_list) {
809 # read from file(url-encoded):
810 # 'git%2Fgit.git Linus+Torvalds'
811 # 'libs%2Fklibc%2Fklibc.git H.+Peter+Anvin'
812 # 'linux%2Fhotplug%2Fudev.git Greg+Kroah-Hartman'
813 open my $fd , $projects_list or return undef;
814 while (my $line = <$fd>) {
816 my ($path, $owner) = split ' ', $line;
817 $path = unescape
($path);
818 $owner = unescape
($owner);
819 if (!defined $path) {
822 if (-e
"$projectroot/$path/HEAD") {
825 owner
=> decode
("utf8", $owner, Encode
::FB_DEFAULT
),
832 @list = sort {$a->{'path'} cmp $b->{'path'}} @list;
836 sub git_get_project_config
{
839 return unless ($key);
840 $key =~ s/^gitweb\.//;
841 return if ($key =~ m/\W/);
843 my $val = qx($GIT repo-config --get gitweb.$key);
847 sub git_get_project_config_bool
{
848 my $val = git_get_project_config
(@_);
849 if ($val and $val =~ m/true|yes|on/) {
852 return; # implicit false
855 sub git_project_list
{
856 my @list = git_read_projects
();
859 die_error
(undef, "No project found.");
861 foreach my $pr (@list) {
862 my $head = git_read_head
($pr->{'path'});
863 if (!defined $head) {
866 $ENV{'GIT_DIR'} = "$projectroot/$pr->{'path'}";
867 my %co = git_read_commit
($head);
871 $pr->{'commit'} = \
%co;
872 if (!defined $pr->{'descr'}) {
873 my $descr = git_read_description
($pr->{'path'}) || "";
874 $pr->{'descr'} = chop_str
($descr, 25, 5);
876 if (!defined $pr->{'owner'}) {
877 $pr->{'owner'} = get_file_owner
("$projectroot/$pr->{'path'}") || "";
883 print "<div class=\"index_include\">\n";
884 open (my $fd, $home_text);
889 print "<table class=\"project_list\">\n" .
891 if (!defined($order) || (defined($order) && ($order eq "project"))) {
892 @projects = sort {$a->{'path'} cmp $b->{'path'}} @projects;
893 print "<th>Project</th>\n";
895 print "<th>" . $cgi->a({-class => "header", -href
=> "$my_uri?" . esc_param
("o=project")}, "Project") . "</th>\n";
897 if (defined($order) && ($order eq "descr")) {
898 @projects = sort {$a->{'descr'} cmp $b->{'descr'}} @projects;
899 print "<th>Description</th>\n";
901 print "<th>" . $cgi->a({-class => "header", -href
=> "$my_uri?" . esc_param
("o=descr")}, "Description") . "</th>\n";
903 if (defined($order) && ($order eq "owner")) {
904 @projects = sort {$a->{'owner'} cmp $b->{'owner'}} @projects;
905 print "<th>Owner</th>\n";
907 print "<th>" . $cgi->a({-class => "header", -href
=> "$my_uri?" . esc_param
("o=owner")}, "Owner") . "</th>\n";
909 if (defined($order) && ($order eq "age")) {
910 @projects = sort {$a->{'commit'}{'age'} <=> $b->{'commit'}{'age'}} @projects;
911 print "<th>Last Change</th>\n";
913 print "<th>" . $cgi->a({-class => "header", -href
=> "$my_uri?" . esc_param
("o=age")}, "Last Change") . "</th>\n";
915 print "<th></th>\n" .
918 foreach my $pr (@projects) {
920 print "<tr class=\"dark\">\n";
922 print "<tr class=\"light\">\n";
925 print "<td>" . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$pr->{'path'};a=summary"), -class => "list"}, esc_html
($pr->{'path'})) . "</td>\n" .
926 "<td>$pr->{'descr'}</td>\n" .
927 "<td><i>" . chop_str
($pr->{'owner'}, 15) . "</i></td>\n";
928 print "<td class=\"". age_class
($pr->{'commit'}{'age'}) . "\">" . $pr->{'commit'}{'age_string'} . "</td>\n" .
929 "<td class=\"link\">" .
930 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$pr->{'path'};a=summary")}, "summary") .
931 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$pr->{'path'};a=shortlog")}, "shortlog") .
932 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$pr->{'path'};a=log")}, "log") .
941 my $type = shift || "";
943 # 5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c refs/tags/v2.6.11
944 # c39ae07f393806ccf406ef966e9a15afc43cc36a refs/tags/v2.6.11^{}
945 open my $fd, "$projectroot/$project/info/refs" or return;
946 while (my $line = <$fd>) {
948 if ($line =~ m/^([0-9a-fA-F]{40})\t.*$type\/([^\
^]+)/) {
949 if (defined $refs{$1}) {
950 $refs{$1} .= " / $2";
965 opendir my $dh, "$projectroot/$project/$ref_dir";
966 while (my $dir = readdir($dh)) {
967 if ($dir =~ m/^\./) {
970 if (-d
"$projectroot/$project/$ref_dir/$dir") {
971 opendir my $dh2, "$projectroot/$project/$ref_dir/$dir";
972 my @subdirs = grep !m/^\./, readdir $dh2;
974 foreach my $subdir (@subdirs) {
975 push @refs, "$dir/$subdir"
982 foreach my $ref_file (@refs) {
983 my $ref_id = git_read_hash
("$project/$ref_dir/$ref_file");
984 my $type = git_get_type
($ref_id) || next;
987 $ref_item{'type'} = $type;
988 $ref_item{'id'} = $ref_id;
989 $ref_item{'epoch'} = 0;
990 $ref_item{'age'} = "unknown";
991 if ($type eq "tag") {
992 my %tag = git_read_tag
($ref_id);
993 $ref_item{'comment'} = $tag{'comment'};
994 if ($tag{'type'} eq "commit") {
995 %co = git_read_commit
($tag{'object'});
996 $ref_item{'epoch'} = $co{'committer_epoch'};
997 $ref_item{'age'} = $co{'age_string'};
998 } elsif (defined($tag{'epoch'})) {
999 my $age = time - $tag{'epoch'};
1000 $ref_item{'epoch'} = $tag{'epoch'};
1001 $ref_item{'age'} = age_string
($age);
1003 $ref_item{'reftype'} = $tag{'type'};
1004 $ref_item{'name'} = $tag{'name'};
1005 $ref_item{'refid'} = $tag{'object'};
1006 } elsif ($type eq "commit"){
1007 %co = git_read_commit
($ref_id);
1008 $ref_item{'reftype'} = "commit";
1009 $ref_item{'name'} = $ref_file;
1010 $ref_item{'title'} = $co{'title'};
1011 $ref_item{'refid'} = $ref_id;
1012 $ref_item{'epoch'} = $co{'committer_epoch'};
1013 $ref_item{'age'} = $co{'age_string'};
1016 push @reflist, \
%ref_item;
1019 @reflist = sort {$b->{'epoch'} <=> $a->{'epoch'}} @reflist;
1024 my $descr = git_read_description
($project) || "none";
1025 my $head = git_read_head
($project);
1026 my %co = git_read_commit
($head);
1027 my %cd = date_str
($co{'committer_epoch'}, $co{'committer_tz'});
1030 if (-f
$projects_list) {
1031 open (my $fd , $projects_list);
1032 while (my $line = <$fd>) {
1034 my ($pr, $ow) = split ' ', $line;
1035 $pr = unescape
($pr);
1036 $ow = unescape
($ow);
1037 if ($pr eq $project) {
1038 $owner = decode
("utf8", $ow, Encode
::FB_DEFAULT
);
1044 if (!defined $owner) {
1045 $owner = get_file_owner
("$projectroot/$project");
1048 my $refs = read_info_ref
();
1050 print "<div class=\"page_nav\">\n" .
1052 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog")}, "shortlog") .
1053 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log")}, "log") .
1054 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$head")}, "commit") .
1055 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$head")}, "commitdiff") .
1056 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree")}, "tree") .
1059 print "<div class=\"title\"> </div>\n";
1060 print "<table cellspacing=\"0\">\n" .
1061 "<tr><td>description</td><td>" . esc_html
($descr) . "</td></tr>\n" .
1062 "<tr><td>owner</td><td>$owner</td></tr>\n" .
1063 "<tr><td>last change</td><td>$cd{'rfc2822'}</td></tr>\n" .
1065 open my $fd, "-|", "$GIT rev-list --max-count=17 " . git_read_head
($project) or die_error
(undef, "Open failed.");
1066 my (@revlist) = map { chomp; $_ } <$fd>;
1069 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog"), -class => "title"}, "shortlog") .
1072 print "<table cellspacing=\"0\">\n";
1074 foreach my $commit (@revlist) {
1075 my %co = git_read_commit
($commit);
1076 my %ad = date_str
($co{'author_epoch'});
1078 print "<tr class=\"dark\">\n";
1080 print "<tr class=\"light\">\n";
1085 if (defined $refs->{$commit}) {
1086 $ref = " <span class=\"tag\">" . esc_html
($refs->{$commit}) . "</span>";
1088 print "<td><i>$co{'age_string'}</i></td>\n" .
1089 "<td><i>" . esc_html
(chop_str
($co{'author_name'}, 10)) . "</i></td>\n" .
1091 if (length($co{'title_short'}) < length($co{'title'})) {
1092 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$commit"), -class => "list", -title
=> "$co{'title'}"},
1093 "<b>" . esc_html
($co{'title_short'}) . "$ref</b>");
1095 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$commit"), -class => "list"},
1096 "<b>" . esc_html
($co{'title'}) . "$ref</b>");
1099 "<td class=\"link\">" .
1100 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$commit")}, "commit") .
1101 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$commit")}, "commitdiff") .
1105 print "<td>" . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog")}, "...") . "</td>\n" .
1112 my $taglist = git_read_refs
("refs/tags");
1113 if (defined @$taglist) {
1115 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tags"), -class => "title"}, "tags") .
1118 print "<table cellspacing=\"0\">\n";
1120 foreach my $entry (@$taglist) {
1122 my $comment_lines = $tag{'comment'};
1123 my $comment = shift @$comment_lines;
1124 if (defined($comment)) {
1125 $comment = chop_str
($comment, 30, 5);
1128 print "<tr class=\"dark\">\n";
1130 print "<tr class=\"light\">\n";
1134 print "<td><i>$tag{'age'}</i></td>\n" .
1136 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=$tag{'reftype'};h=$tag{'refid'}"), -class => "list"},
1137 "<b>" . esc_html
($tag{'name'}) . "</b>") .
1140 if (defined($comment)) {
1141 print $cgi->a({-class => "list", -href
=> "$my_uri?" . esc_param
("p=$project;a=tag;h=$tag{'id'}")}, $comment);
1144 "<td class=\"link\">";
1145 if ($tag{'type'} eq "tag") {
1146 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tag;h=$tag{'id'}")}, "tag") . " | ";
1148 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=$tag{'reftype'};h=$tag{'refid'}")}, $tag{'reftype'});
1149 if ($tag{'reftype'} eq "commit") {
1150 print " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog;h=$tag{'name'}")}, "shortlog") .
1151 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log;h=$tag{'refid'}")}, "log");
1156 print "<td>" . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tags")}, "...") . "</td>\n" .
1164 my $headlist = git_read_refs
("refs/heads");
1165 if (defined @$headlist) {
1167 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=heads"), -class => "title"}, "heads") .
1170 print "<table cellspacing=\"0\">\n";
1172 foreach my $entry (@$headlist) {
1175 print "<tr class=\"dark\">\n";
1177 print "<tr class=\"light\">\n";
1181 print "<td><i>$tag{'age'}</i></td>\n" .
1183 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog;h=$tag{'name'}"), -class => "list"},
1184 "<b>" . esc_html
($tag{'name'}) . "</b>") .
1186 "<td class=\"link\">" .
1187 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog;h=$tag{'name'}")}, "shortlog") .
1188 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log;h=$tag{'name'}")}, "log") .
1192 print "<td>" . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=heads")}, "...") . "</td>\n" .
1203 my $head = git_read_head
($project);
1205 print "<div class=\"page_nav\">\n" .
1206 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary")}, "summary") .
1207 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog")}, "shortlog") .
1208 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log")}, "log") .
1209 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$head")}, "commit") .
1210 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$head")}, "commitdiff") .
1211 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;hb=$head")}, "tree") . "<br/>\n" .
1214 my %tag = git_read_tag
($hash);
1216 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash"), -class => "title"}, esc_html
($tag{'name'})) . "\n" .
1218 print "<div class=\"title_text\">\n" .
1219 "<table cellspacing=\"0\">\n" .
1221 "<td>object</td>\n" .
1222 "<td>" . $cgi->a({-class => "list", -href
=> "$my_uri?" . esc_param
("p=$project;a=$tag{'type'};h=$tag{'object'}")}, $tag{'object'}) . "</td>\n" .
1223 "<td class=\"link\">" . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=$tag{'type'};h=$tag{'object'}")}, $tag{'type'}) . "</td>\n" .
1225 if (defined($tag{'author'})) {
1226 my %ad = date_str
($tag{'epoch'}, $tag{'tz'});
1227 print "<tr><td>author</td><td>" . esc_html
($tag{'author'}) . "</td></tr>\n";
1228 print "<tr><td></td><td>" . $ad{'rfc2822'} . sprintf(" (%02d:%02d %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'}) . "</td></tr>\n";
1230 print "</table>\n\n" .
1232 print "<div class=\"page_body\">";
1233 my $comment = $tag{'comment'};
1234 foreach my $line (@$comment) {
1235 print esc_html
($line) . "<br/>\n";
1241 sub git_read_blame_line
{
1245 ($bl{'hash'}, $bl{'lineno'}, $bl{'data'}) = /^([0-9a-fA-F]{40}).*?(\d+)\)\s{1}(\s*.*)/;
1253 die_error
(undef, "Permission denied.") if (!git_get_project_config_bool
('blame'));
1254 die_error
('404 Not Found', "File name not defined") if (!$file_name);
1255 $hash_base ||= git_read_head
($project);
1256 die_error
(undef, "Reading commit failed") unless ($hash_base);
1257 my %co = git_read_commit
($hash_base)
1258 or die_error
(undef, "Reading commit failed");
1259 if (!defined $hash) {
1260 $hash = git_get_hash_by_path
($hash_base, $file_name, "blob")
1261 or die_error
(undef, "Error looking up file");
1263 $ftype = git_get_type
($hash);
1264 if ($ftype !~ "blob") {
1265 die_error
("400 Bad Request", "object is not a blob");
1267 open ($fd, "-|", $GIT, "blame", '-l', $file_name, $hash_base)
1268 or die_error
(undef, "Open failed");
1270 print "<div class=\"page_nav\">\n" .
1271 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary")}, "summary") .
1272 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog")}, "shortlog") .
1273 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log")}, "log") .
1274 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash_base")}, "commit") .
1275 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$hash_base")}, "commitdiff") .
1276 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;h=$co{'tree'};hb=$hash_base")}, "tree") . "<br/>\n";
1277 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;h=$hash;hb=$hash_base;f=$file_name")}, "blob") .
1278 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blame;f=$file_name")}, "head") . "<br/>\n";
1281 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash_base"), -class => "title"}, esc_html
($co{'title'})) .
1283 git_print_page_path
($file_name, $ftype);
1284 my @rev_color = (qw(light dark));
1285 my $num_colors = scalar(@rev_color);
1286 my $current_color = 0;
1288 print "<div class=\"page_body\">\n";
1289 print "<table class=\"blame\">\n";
1290 print "<tr><th>Commit</th><th>Line</th><th>Data</th></tr>\n";
1291 while (my $line = <$fd>) {
1292 my %blame_line = git_read_blame_line
($line);
1293 my $full_rev = $blame_line{'hash'};
1294 my $rev = substr($full_rev, 0, 8);
1295 my $lineno = $blame_line{'lineno'};
1296 my $data = $blame_line{'data'};
1298 if (!defined $last_rev) {
1299 $last_rev = $full_rev;
1300 } elsif ($last_rev ne $full_rev) {
1301 $last_rev = $full_rev;
1302 $current_color = ++$current_color % $num_colors;
1304 print "<tr class=\"$rev_color[$current_color]\">\n";
1305 print "<td class=\"sha1\">" .
1306 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$full_rev;f=$file_name")}, esc_html
($rev)) . "</td>\n";
1307 print "<td class=\"linenr\"><a id=\"l$lineno\" href=\"#l$lineno\" class=\"linenr\">" . esc_html
($lineno) . "</a></td>\n";
1308 print "<td class=\"pre\">" . esc_html
($data) . "</td>\n";
1313 close $fd or print "Reading blob failed\n";
1319 die_error
('403 Permission denied', "Permission denied.") if (!git_get_project_config_bool
('blame'));
1320 die_error
('404 Not Found', "What file will it be, master?") if (!$file_name);
1321 $hash_base ||= git_read_head
($project);
1322 die_error
(undef, "Reading commit failed.") unless ($hash_base);
1323 my %co = git_read_commit
($hash_base)
1324 or die_error
(undef, "Reading commit failed.");
1325 if (!defined $hash) {
1326 $hash = git_get_hash_by_path
($hash_base, $file_name, "blob")
1327 or die_error
(undef, "Error lookup file.");
1329 open ($fd, "-|", $GIT, "annotate", '-l', '-t', '-r', $file_name, $hash_base)
1330 or die_error
(undef, "Open failed.");
1332 print "<div class=\"page_nav\">\n" .
1333 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary")}, "summary") .
1334 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog")}, "shortlog") .
1335 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log")}, "log") .
1336 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash_base")}, "commit") .
1337 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$hash_base")}, "commitdiff") .
1338 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;h=$co{'tree'};hb=$hash_base")}, "tree") . "<br/>\n";
1339 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;h=$hash;hb=$hash_base;f=$file_name")}, "blob") .
1340 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blame;f=$file_name")}, "head") . "<br/>\n";
1343 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash_base"), -class => "title"}, esc_html
($co{'title'})) .
1345 print "<div class=\"page_path\"><b>" . esc_html
($file_name) . "</b></div>\n";
1346 print "<div class=\"page_body\">\n";
1348 <table class="blame">
1357 my @line_class = (qw(light dark));
1358 my $line_class_len = scalar (@line_class);
1359 my $line_class_num = $#line_class;
1360 while (my $line = <$fd>) {
1372 $line_class_num = ($line_class_num + 1) % $line_class_len;
1374 if ($line =~ m/^([0-9a-fA-F]{40})\t\(\s*([^\t]+)\t(\d+) \+\d\d\d\d\t(\d+)\)(.*)$/) {
1381 print qq( <tr><td colspan="5" class="error">Unable to parse: $line</td></tr>\n);
1384 $short_rev = substr ($long_rev, 0, 8);
1385 $age = time () - $time;
1386 $age_str = age_string
($age);
1387 $age_str =~ s/ / /g;
1388 $age_class = age_class
($age);
1389 $author = esc_html
($author);
1390 $author =~ s/ / /g;
1392 while ((my $pos = index($data, "\t")) != -1) {
1393 if (my $count = (8 - ($pos % 8))) {
1394 my $spaces = ' ' x
$count;
1395 $data =~ s/\t/$spaces/;
1398 $data = esc_html
($data);
1401 <tr class="$line_class[$line_class_num]">
1402 <td class="sha1"><a href="$my_uri?${\esc_param ("p=$project;a=commit;h=$long_rev")}" class="text">$short_rev..</a></td>
1403 <td class="$age_class">$age_str</td>
1405 <td class="linenr"><a id="$lineno" href="#$lineno" class="linenr">$lineno</a></td>
1406 <td class="pre">$data</td>
1409 } # while (my $line = <$fd>)
1410 print "</table>\n\n";
1411 close $fd or print "Reading blob failed.\n";
1417 my $head = git_read_head
($project);
1419 print "<div class=\"page_nav\">\n" .
1420 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary")}, "summary") .
1421 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog")}, "shortlog") .
1422 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log")}, "log") .
1423 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$head")}, "commit") .
1424 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$head")}, "commitdiff") .
1425 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;hb=$head")}, "tree") . "<br/>\n" .
1428 my $taglist = git_read_refs
("refs/tags");
1430 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary"), -class => "title"}, " ") .
1432 print "<table cellspacing=\"0\">\n";
1434 if (defined @$taglist) {
1435 foreach my $entry (@$taglist) {
1437 my $comment_lines = $tag{'comment'};
1438 my $comment = shift @$comment_lines;
1439 if (defined($comment)) {
1440 $comment = chop_str
($comment, 30, 5);
1443 print "<tr class=\"dark\">\n";
1445 print "<tr class=\"light\">\n";
1448 print "<td><i>$tag{'age'}</i></td>\n" .
1450 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=$tag{'reftype'};h=$tag{'refid'}"), -class => "list"},
1451 "<b>" . esc_html
($tag{'name'}) . "</b>") .
1454 if (defined($comment)) {
1455 print $cgi->a({-class => "list", -href
=> "$my_uri?" . esc_param
("p=$project;a=tag;h=$tag{'id'}")}, $comment);
1458 "<td class=\"link\">";
1459 if ($tag{'type'} eq "tag") {
1460 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tag;h=$tag{'id'}")}, "tag") . " | ";
1462 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=$tag{'reftype'};h=$tag{'refid'}")}, $tag{'reftype'});
1463 if ($tag{'reftype'} eq "commit") {
1464 print " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog;h=$tag{'name'}")}, "shortlog") .
1465 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log;h=$tag{'refid'}")}, "log");
1476 my $head = git_read_head
($project);
1478 print "<div class=\"page_nav\">\n" .
1479 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary")}, "summary") .
1480 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog")}, "shortlog") .
1481 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log")}, "log") .
1482 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$head")}, "commit") .
1483 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$head")}, "commitdiff") .
1484 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;hb=$head")}, "tree") . "<br/>\n" .
1487 my $taglist = git_read_refs
("refs/heads");
1489 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary"), -class => "title"}, " ") .
1491 print "<table cellspacing=\"0\">\n";
1493 if (defined @$taglist) {
1494 foreach my $entry (@$taglist) {
1497 print "<tr class=\"dark\">\n";
1499 print "<tr class=\"light\">\n";
1502 print "<td><i>$tag{'age'}</i></td>\n" .
1504 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog;h=$tag{'name'}"), -class => "list"}, "<b>" . esc_html
($tag{'name'}) . "</b>") .
1506 "<td class=\"link\">" .
1507 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog;h=$tag{'name'}")}, "shortlog") .
1508 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log;h=$tag{'name'}")}, "log") .
1517 sub git_get_hash_by_path
{
1519 my $path = shift || return undef;
1522 my @parts = split '/', $path;
1523 while (my $part = shift @parts) {
1524 open my $fd, "-|", "$GIT ls-tree $tree" or die_error
(undef, "Open git-ls-tree failed.");
1525 my (@entries) = map { chomp; $_ } <$fd>;
1526 close $fd or return undef;
1527 foreach my $line (@entries) {
1528 #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c'
1529 $line =~ m/^([0-9]+) (.+) ([0-9a-fA-F]{40})\t(.+)$/;
1533 my $t_name = validate_input
(unquote
($4));
1534 if ($t_name eq $part) {
1538 if ($t_type eq "tree") {
1547 sub mimetype_guess_file
{
1548 my $filename = shift;
1549 my $mimemap = shift;
1550 -r
$mimemap or return undef;
1553 open(MIME
, $mimemap) or return undef;
1555 my ($mime, $exts) = split(/\t+/);
1556 my @exts = split(/\s+/, $exts);
1557 foreach my $ext (@exts) {
1558 $mimemap{$ext} = $mime;
1563 $filename =~ /\.(.*?)$/;
1564 return $mimemap{$1};
1567 sub mimetype_guess
{
1568 my $filename = shift;
1570 $filename =~ /\./ or return undef;
1572 if ($mimetypes_file) {
1573 my $file = $mimetypes_file;
1574 #$file =~ m#^/# or $file = "$projectroot/$path/$file";
1575 $mime = mimetype_guess_file
($filename, $file);
1577 $mime ||= mimetype_guess_file
($filename, '/etc/mime.types');
1581 sub git_blob_plain_mimetype
{
1583 my $filename = shift;
1586 my $mime = mimetype_guess
($filename);
1587 $mime and return $mime;
1591 return $default_blob_plain_mimetype unless $fd;
1594 return 'text/plain' .
1595 ($default_text_plain_charset ? '; charset='.$default_text_plain_charset : '');
1596 } elsif (! $filename) {
1597 return 'application/octet-stream';
1598 } elsif ($filename =~ m/\.png$/i) {
1600 } elsif ($filename =~ m/\.gif$/i) {
1602 } elsif ($filename =~ m/\.jpe?g$/i) {
1603 return 'image/jpeg';
1605 return 'application/octet-stream';
1609 sub git_blob_plain
{
1610 if (!defined $hash) {
1611 if (defined $file_name) {
1612 my $base = $hash_base || git_read_head
($project);
1613 $hash = git_get_hash_by_path
($base, $file_name, "blob") || die_error
(undef, "Error lookup file.");
1615 die_error
(undef, "No file name defined.");
1619 open my $fd, "-|", "$GIT cat-file blob $hash" or die_error
("Couldn't cat $file_name, $hash");
1621 $type ||= git_blob_plain_mimetype
($fd, $file_name);
1623 # save as filename, even when no $file_name is given
1624 my $save_as = "$hash";
1625 if (defined $file_name) {
1626 $save_as = $file_name;
1627 } elsif ($type =~ m/^text\//) {
1631 print $cgi->header(-type
=> "$type", '-content-disposition' => "inline; filename=\"$save_as\"");
1633 binmode STDOUT
, ':raw';
1635 binmode STDOUT
, ':utf8'; # as set at the beginning of gitweb.cgi
1641 if (!defined $hash) {
1642 if (defined $file_name) {
1643 my $base = $hash_base || git_read_head
($project);
1644 $hash = git_get_hash_by_path
($base, $file_name, "blob") || die_error
(undef, "Error lookup file.");
1646 die_error
(undef, "No file name defined.");
1649 my $have_blame = git_get_project_config_bool
('blame');
1650 open my $fd, "-|", "$GIT cat-file blob $hash" or die_error
(undef, "Open failed.");
1651 my $mimetype = git_blob_plain_mimetype
($fd, $file_name);
1652 if ($mimetype !~ m/^text\//) {
1654 return git_blob_plain
($mimetype);
1657 if (defined $hash_base && (my %co = git_read_commit
($hash_base))) {
1658 print "<div class=\"page_nav\">\n" .
1659 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary")}, "summary") .
1660 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog")}, "shortlog") .
1661 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log")}, "log") .
1662 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash_base")}, "commit") .
1663 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$hash_base")}, "commitdiff") .
1664 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;h=$co{'tree'};hb=$hash_base")}, "tree") . "<br/>\n";
1665 if (defined $file_name) {
1667 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blame;h=$hash;hb=$hash_base;f=$file_name")}, "blame") . " | ";
1669 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob_plain;h=$hash;f=$file_name")}, "plain") .
1670 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;hb=HEAD;f=$file_name")}, "head") . "<br/>\n";
1672 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob_plain;h=$hash")}, "plain") . "<br/>\n";
1676 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash_base"), -class => "title"}, esc_html
($co{'title'})) .
1679 print "<div class=\"page_nav\">\n" .
1680 "<br/><br/></div>\n" .
1681 "<div class=\"title\">$hash</div>\n";
1683 if (defined $file_name) {
1684 print "<div class=\"page_path\"><b>" . esc_html
($file_name) . "</b></div>\n";
1686 print "<div class=\"page_body\">\n";
1688 while (my $line = <$fd>) {
1691 while ((my $pos = index($line, "\t")) != -1) {
1692 if (my $count = (8 - ($pos % 8))) {
1693 my $spaces = ' ' x
$count;
1694 $line =~ s/\t/$spaces/;
1697 printf "<div class=\"pre\"><a id=\"l%i\" href=\"#l%i\" class=\"linenr\">%4i</a> %s</div>\n", $nr, $nr, $nr, esc_html
($line);
1699 close $fd or print "Reading blob failed.\n";
1705 if (!defined $hash) {
1706 $hash = git_read_head
($project);
1707 if (defined $file_name) {
1708 my $base = $hash_base || $hash;
1709 $hash = git_get_hash_by_path
($base, $file_name, "tree");
1711 if (!defined $hash_base) {
1716 open my $fd, "-|", "$GIT ls-tree -z $hash" or die_error
(undef, "Open git-ls-tree failed.");
1717 chomp (my (@entries) = <$fd>);
1718 close $fd or die_error
(undef, "Reading tree failed.");
1721 my $refs = read_info_ref
();
1723 if (defined $refs->{$hash_base}) {
1724 $ref = " <span class=\"tag\">" . esc_html
($refs->{$hash_base}) . "</span>";
1729 if (defined $hash_base && (my %co = git_read_commit
($hash_base))) {
1730 $base_key = ";hb=$hash_base";
1731 print "<div class=\"page_nav\">\n" .
1732 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary")}, "summary") .
1733 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog;h=$hash_base")}, "shortlog") .
1734 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log;h=$hash_base")}, "log") .
1735 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash_base")}, "commit") .
1736 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$hash_base")}, "commitdiff") .
1741 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash_base"), -class => "title"}, esc_html
($co{'title'}) . $ref) . "\n" .
1744 print "<div class=\"page_nav\">\n";
1745 print "<br/><br/></div>\n";
1746 print "<div class=\"title\">$hash</div>\n";
1748 if (defined $file_name) {
1749 $base = esc_html
("$file_name/");
1750 print "<div class=\"page_path\"><b>/" . esc_html
($file_name) . "</b></div>\n";
1752 print "<div class=\"page_path\"><b>/</b></div>\n";
1754 print "<div class=\"page_body\">\n";
1755 print "<table cellspacing=\"0\">\n";
1757 foreach my $line (@entries) {
1758 #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c'
1759 $line =~ m/^([0-9]+) (.+) ([0-9a-fA-F]{40})\t(.+)$/;
1763 my $t_name = validate_input
($4);
1765 print "<tr class=\"dark\">\n";
1767 print "<tr class=\"light\">\n";
1770 print "<td class=\"mode\">" . mode_str
($t_mode) . "</td>\n";
1771 if ($t_type eq "blob") {
1772 print "<td class=\"list\">" .
1773 $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)) .
1775 "<td class=\"link\">" .
1776 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;h=$t_hash$base_key;f=$base$t_name")}, "blob") .
1777 # " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blame;h=$t_hash$base_key;f=$base$t_name")}, "blame") .
1778 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=history;h=$t_hash;hb=$hash_base;f=$base$t_name")}, "history") .
1779 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob_plain;h=$t_hash;f=$base$t_name")}, "raw") .
1781 } elsif ($t_type eq "tree") {
1782 print "<td class=\"list\">" .
1783 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;h=$t_hash$base_key;f=$base$t_name")}, esc_html
($t_name)) .
1785 "<td class=\"link\">" .
1786 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;h=$t_hash$base_key;f=$base$t_name")}, "tree") .
1787 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=history;hb=$hash_base;f=$base$t_name")}, "history") .
1792 print "</table>\n" .
1798 # http://www.notestips.com/80256B3A007F2692/1/NAMO5P9UPQ
1799 open my $fd, "-|", "$GIT rev-list --max-count=150 " . git_read_head
($project) or die_error
(undef, "Open failed.");
1800 my (@revlist) = map { chomp; $_ } <$fd>;
1801 close $fd or die_error
(undef, "Reading rev-list failed.");
1802 print $cgi->header(-type
=> 'text/xml', -charset
=> 'utf-8');
1803 print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n".
1804 "<rss version=\"2.0\" xmlns:content=\"http://purl.org/rss/1.0/modules/content/\">\n";
1805 print "<channel>\n";
1806 print "<title>$project</title>\n".
1807 "<link>" . esc_html
("$my_url?p=$project;a=summary") . "</link>\n".
1808 "<description>$project log</description>\n".
1809 "<language>en</language>\n";
1811 for (my $i = 0; $i <= $#revlist; $i++) {
1812 my $commit = $revlist[$i];
1813 my %co = git_read_commit
($commit);
1814 # we read 150, we always show 30 and the ones more recent than 48 hours
1815 if (($i >= 20) && ((time - $co{'committer_epoch'}) > 48*60*60)) {
1818 my %cd = date_str
($co{'committer_epoch'});
1819 open $fd, "-|", "$GIT diff-tree -r $co{'parent'} $co{'id'}" or next;
1820 my @difftree = map { chomp; $_ } <$fd>;
1824 sprintf("%d %s %02d:%02d", $cd{'mday'}, $cd{'month'}, $cd{'hour'}, $cd{'minute'}) . " - " . esc_html
($co{'title'}) .
1826 "<author>" . esc_html
($co{'author'}) . "</author>\n" .
1827 "<pubDate>$cd{'rfc2822'}</pubDate>\n" .
1828 "<guid isPermaLink=\"true\">" . esc_html
("$my_url?p=$project;a=commit;h=$commit") . "</guid>\n" .
1829 "<link>" . esc_html
("$my_url?p=$project;a=commit;h=$commit") . "</link>\n" .
1830 "<description>" . esc_html
($co{'title'}) . "</description>\n" .
1831 "<content:encoded>" .
1833 my $comment = $co{'comment'};
1834 foreach my $line (@$comment) {
1835 $line = decode
("utf8", $line, Encode
::FB_DEFAULT
);
1836 print "$line<br/>\n";
1839 foreach my $line (@difftree) {
1840 if (!($line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)([0-9]{0,3})\t(.*)$/)) {
1843 my $file = validate_input
(unquote
($7));
1844 $file = decode
("utf8", $file, Encode
::FB_DEFAULT
);
1845 print "$file<br/>\n";
1848 "</content:encoded>\n" .
1851 print "</channel></rss>";
1855 my @list = git_read_projects
();
1857 print $cgi->header(-type
=> 'text/xml', -charset
=> 'utf-8');
1858 print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n".
1859 "<opml version=\"1.0\">\n".
1861 " <title>$site_name Git OPML Export</title>\n".
1864 "<outline text=\"git RSS feeds\">\n";
1866 foreach my $pr (@list) {
1868 my $head = git_read_head
($proj{'path'});
1869 if (!defined $head) {
1872 $ENV{'GIT_DIR'} = "$projectroot/$proj{'path'}";
1873 my %co = git_read_commit
($head);
1878 my $path = esc_html
(chop_str
($proj{'path'}, 25, 5));
1879 my $rss = "$my_url?p=$proj{'path'};a=rss";
1880 my $html = "$my_url?p=$proj{'path'};a=summary";
1881 print "<outline type=\"rss\" text=\"$path\" title=\"$path\" xmlUrl=\"$rss\" htmlUrl=\"$html\"/>\n";
1883 print "</outline>\n".
1889 my $head = git_read_head
($project);
1890 if (!defined $hash) {
1893 if (!defined $page) {
1896 my $refs = read_info_ref
();
1898 print "<div class=\"page_nav\">\n";
1899 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary")}, "summary") .
1900 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog;h=$hash")}, "shortlog") .
1902 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash")}, "commit") .
1903 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$hash")}, "commitdiff") .
1904 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;h=$hash;hb=$hash")}, "tree") . "<br/>\n";
1906 my $limit = sprintf("--max-count=%i", (100 * ($page+1)));
1907 open my $fd, "-|", "$GIT rev-list $limit $hash" or die_error
(undef, "Open failed.");
1908 my (@revlist) = map { chomp; $_ } <$fd>;
1911 if ($hash ne $head || $page) {
1912 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log")}, "HEAD");
1918 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log;h=$hash;pg=" . ($page-1)), -accesskey
=> "p", -title
=> "Alt-p"}, "prev");
1920 print " ⋅ prev";
1922 if ($#revlist >= (100 * ($page+1)-1)) {
1924 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log;h=$hash;pg=" . ($page+1)), -accesskey
=> "n", -title
=> "Alt-n"}, "next");
1926 print " ⋅ next";
1932 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary"), -class => "title"}, " ") .
1934 my %co = git_read_commit
($hash);
1935 print "<div class=\"page_body\"> Last change $co{'age_string'}.<br/><br/></div>\n";
1937 for (my $i = ($page * 100); $i <= $#revlist; $i++) {
1938 my $commit = $revlist[$i];
1940 if (defined $refs->{$commit}) {
1941 $ref = " <span class=\"tag\">" . esc_html
($refs->{$commit}) . "</span>";
1943 my %co = git_read_commit
($commit);
1945 my %ad = date_str
($co{'author_epoch'});
1947 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$commit"), -class => "title"},
1948 "<span class=\"age\">$co{'age_string'}</span>" . esc_html
($co{'title'}) . $ref) . "\n";
1950 print "<div class=\"title_text\">\n" .
1951 "<div class=\"log_link\">\n" .
1952 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$commit")}, "commit") .
1953 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$commit")}, "commitdiff") .
1956 "<i>" . esc_html
($co{'author_name'}) . " [$ad{'rfc2822'}]</i><br/>\n" .
1958 "<div class=\"log_body\">\n";
1959 my $comment = $co{'comment'};
1961 foreach my $line (@$comment) {
1962 if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
1973 print format_log_line_html
($line) . "<br/>\n";
1984 my %co = git_read_commit
($hash);
1986 die_error
(undef, "Unknown commit object.");
1988 my %ad = date_str
($co{'author_epoch'}, $co{'author_tz'});
1989 my %cd = date_str
($co{'committer_epoch'}, $co{'committer_tz'});
1993 my $parent = $co{'parent'};
1994 if (!defined $parent) {
1998 open my $fd, "-|", "$GIT diff-tree -r -M $root $parent $hash" or die_error
(undef, "Open failed.");
1999 @difftree = map { chomp; $_ } <$fd>;
2000 close $fd or die_error
(undef, "Reading diff-tree failed.");
2002 # non-textual hash id's can be cached
2004 if ($hash =~ m/^[0-9a-fA-F]{40}$/) {
2007 my $refs = read_info_ref
();
2009 if (defined $refs->{$co{'id'}}) {
2010 $ref = " <span class=\"tag\">" . esc_html
($refs->{$co{'id'}}) . "</span>";
2012 git_header_html
(undef, $expires);
2013 print "<div class=\"page_nav\">\n" .
2014 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary")}, "summary") .
2015 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog;h=$hash")}, "shortlog") .
2016 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log;h=$hash")}, "log") .
2018 if (defined $co{'parent'}) {
2019 print " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$hash")}, "commitdiff");
2021 print " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") . "\n" .
2023 if (defined $file_name && defined $co{'parent'}) {
2024 my $parent = $co{'parent'};
2025 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blame;hb=$parent;f=$file_name")}, "blame") . "\n";
2027 print "<br/></div>\n";
2029 if (defined $co{'parent'}) {
2031 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$hash"), -class => "title"}, esc_html
($co{'title'}) . $ref) . "\n" .
2035 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;h=$co{'tree'};hb=$hash"), -class => "title"}, esc_html
($co{'title'})) . "\n" .
2038 print "<div class=\"title_text\">\n" .
2039 "<table cellspacing=\"0\">\n";
2040 print "<tr><td>author</td><td>" . esc_html
($co{'author'}) . "</td></tr>\n".
2042 "<td></td><td> $ad{'rfc2822'}";
2043 if ($ad{'hour_local'} < 6) {
2044 printf(" (<span class=\"atnight\">%02d:%02d</span> %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
2046 printf(" (%02d:%02d %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
2050 print "<tr><td>committer</td><td>" . esc_html
($co{'committer'}) . "</td></tr>\n";
2051 print "<tr><td></td><td> $cd{'rfc2822'}" . sprintf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}) . "</td></tr>\n";
2052 print "<tr><td>commit</td><td class=\"sha1\">$co{'id'}</td></tr>\n";
2055 "<td class=\"sha1\">" .
2056 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;h=$co{'tree'};hb=$hash"), class => "list"}, $co{'tree'}) .
2058 "<td class=\"link\">" . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") .
2061 my $parents = $co{'parents'};
2062 foreach my $par (@$parents) {
2065 "<td class=\"sha1\">" . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$par"), class => "list"}, $par) . "</td>" .
2066 "<td class=\"link\">" .
2067 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$par")}, "commit") .
2068 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$hash;hp=$par")}, "commitdiff") .
2074 print "<div class=\"page_body\">\n";
2075 my $comment = $co{'comment'};
2078 foreach my $line (@$comment) {
2079 # print only one empty line
2081 if ($empty || $signed) {
2088 if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
2090 print "<span class=\"signoff\">" . esc_html
($line) . "</span><br/>\n";
2093 print format_log_line_html
($line) . "<br/>\n";
2097 print "<div class=\"list_head\">\n";
2098 if ($#difftree > 10) {
2099 print(($#difftree + 1) . " files changed:\n");
2102 print "<table class=\"diff_tree\">\n";
2104 foreach my $line (@difftree) {
2105 # ':100644 100644 03b218260e99b78c6df0ed378e59ed9205ccc96d 3b93d5e7cc7f7dd4ebed13a5cc1a4ad976fc94d8 M ls-files.c'
2106 # ':100644 100644 7f9281985086971d3877aca27704f2aaf9c448ce bc190ebc71bbd923f2b728e505408f5e54bd073a M rev-tree.c'
2107 if (!($line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)([0-9]{0,3})\t(.*)$/)) {
2115 my $similarity = $6;
2116 my $file = validate_input
(unquote
($7));
2118 print "<tr class=\"dark\">\n";
2120 print "<tr class=\"light\">\n";
2123 if ($status eq "A") {
2125 if (S_ISREG
(oct $to_mode)) {
2126 $mode_chng = sprintf(" with mode: %04o", (oct $to_mode) & 0777);
2129 $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" .
2130 "<td><span class=\"file_status new\">[new " . file_type
($to_mode) . "$mode_chng]</span></td>\n" .
2131 "<td class=\"link\">" . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, "blob") . "</td>\n";
2132 } elsif ($status eq "D") {
2134 $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" .
2135 "<td><span class=\"file_status deleted\">[deleted " . file_type
($from_mode). "]</span></td>\n" .
2136 "<td class=\"link\">" .
2137 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;h=$from_id;hb=$hash;f=$file")}, "blob") .
2138 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=history;hb=$hash;f=$file")}, "history") .
2140 } elsif ($status eq "M" || $status eq "T") {
2141 my $mode_chnge = "";
2142 if ($from_mode != $to_mode) {
2143 $mode_chnge = " <span class=\"file_status mode_chnge\">[changed";
2144 if (((oct $from_mode) & S_IFMT
) != ((oct $to_mode) & S_IFMT
)) {
2145 $mode_chnge .= " from " . file_type
($from_mode) . " to " . file_type
($to_mode);
2147 if (((oct $from_mode) & 0777) != ((oct $to_mode) & 0777)) {
2148 if (S_ISREG
($from_mode) && S_ISREG
($to_mode)) {
2149 $mode_chnge .= sprintf(" mode: %04o->%04o", (oct $from_mode) & 0777, (oct $to_mode) & 0777);
2150 } elsif (S_ISREG
($to_mode)) {
2151 $mode_chnge .= sprintf(" mode: %04o", (oct $to_mode) & 0777);
2154 $mode_chnge .= "]</span>\n";
2157 if ($to_id ne $from_id) {
2158 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));
2160 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;h=$to_id;hb=$hash;f=$file"), -class => "list"}, esc_html
($file));
2163 "<td>$mode_chnge</td>\n" .
2164 "<td class=\"link\">";
2165 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, "blob");
2166 if ($to_id ne $from_id) {
2167 print " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file")}, "diff");
2169 print " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=history;hb=$hash;f=$file")}, "history") . "\n";
2171 } elsif ($status eq "R") {
2172 my ($from_file, $to_file) = split "\t", $file;
2174 if ($from_mode != $to_mode) {
2175 $mode_chng = sprintf(", mode: %04o", (oct $to_mode) & 0777);
2178 $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" .
2179 "<td><span class=\"file_status moved\">[moved from " .
2180 $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)) .
2181 " with " . (int $similarity) . "% similarity$mode_chng]</span></td>\n" .
2182 "<td class=\"link\">" .
2183 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;h=$to_id;hb=$hash;f=$to_file")}, "blob");
2184 if ($to_id ne $from_id) {
2185 print " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$to_file")}, "diff");
2196 mkdir($git_temp, 0700);
2198 if (defined $hash_base && (my %co = git_read_commit
($hash_base))) {
2199 print "<div class=\"page_nav\">\n" .
2200 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary")}, "summary") .
2201 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog")}, "shortlog") .
2202 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log")}, "log") .
2203 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash_base")}, "commit") .
2204 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$hash_base")}, "commitdiff") .
2205 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;h=$co{'tree'};hb=$hash_base")}, "tree") .
2207 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blobdiff_plain;h=$hash;hp=$hash_parent")}, "plain") .
2210 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash_base"), -class => "title"}, esc_html
($co{'title'})) . "\n" .
2213 print "<div class=\"page_nav\">\n" .
2214 "<br/><br/></div>\n" .
2215 "<div class=\"title\">$hash vs $hash_parent</div>\n";
2217 if (defined $file_name) {
2218 print "<div class=\"page_path\"><b>/" . esc_html
($file_name) . "</b></div>\n";
2220 print "<div class=\"page_body\">\n" .
2221 "<div class=\"diff_info\">blob:" .
2222 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;h=$hash_parent;hb=$hash_base;f=$file_name")}, $hash_parent) .
2224 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;h=$hash;hb=$hash_base;f=$file_name")}, $hash) .
2226 git_diff_print
($hash_parent, $file_name || $hash_parent, $hash, $file_name || $hash);
2231 sub git_blobdiff_plain
{
2232 mkdir($git_temp, 0700);
2233 print $cgi->header(-type
=> "text/plain", -charset
=> 'utf-8');
2234 git_diff_print
($hash_parent, $file_name || $hash_parent, $hash, $file_name || $hash, "plain");
2237 sub git_commitdiff
{
2238 mkdir($git_temp, 0700);
2239 my %co = git_read_commit
($hash);
2241 die_error
(undef, "Unknown commit object.");
2243 if (!defined $hash_parent) {
2244 $hash_parent = $co{'parent'};
2246 open my $fd, "-|", "$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 # non-textual hash id's can be cached
2252 if ($hash =~ m/^[0-9a-fA-F]{40}$/) {
2255 my $refs = read_info_ref
();
2257 if (defined $refs->{$co{'id'}}) {
2258 $ref = " <span class=\"tag\">" . esc_html
($refs->{$co{'id'}}) . "</span>";
2260 git_header_html
(undef, $expires);
2261 print "<div class=\"page_nav\">\n" .
2262 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary")}, "summary") .
2263 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog;h=$hash")}, "shortlog") .
2264 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log;h=$hash")}, "log") .
2265 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash")}, "commit") .
2267 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") . "<br/>\n";
2268 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff_plain;h=$hash;hp=$hash_parent")}, "plain") . "\n" .
2271 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash"), -class => "title"}, esc_html
($co{'title'}) . $ref) . "\n" .
2273 print "<div class=\"page_body\">\n";
2274 my $comment = $co{'comment'};
2277 my @log = @$comment;
2278 # remove first and empty lines after that
2280 while (defined $log[0] && $log[0] eq "") {
2283 foreach my $line (@log) {
2284 if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
2295 print format_log_line_html
($line) . "<br/>\n";
2298 foreach my $line (@difftree) {
2299 # ':100644 100644 03b218260e99b78c6df0ed378e59ed9205ccc96d 3b93d5e7cc7f7dd4ebed13a5cc1a4ad976fc94d8 M ls-files.c'
2300 # ':100644 100644 7f9281985086971d3877aca27704f2aaf9c448ce bc190ebc71bbd923f2b728e505408f5e54bd073a M rev-tree.c'
2301 $line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$/;
2307 my $file = validate_input
(unquote
($6));
2308 if ($status eq "A") {
2309 print "<div class=\"diff_info\">" . file_type
($to_mode) . ":" .
2310 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, $to_id) . "(new)" .
2312 git_diff_print
(undef, "/dev/null", $to_id, "b/$file");
2313 } elsif ($status eq "D") {
2314 print "<div class=\"diff_info\">" . file_type
($from_mode) . ":" .
2315 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;h=$from_id;hb=$hash;f=$file")}, $from_id) . "(deleted)" .
2317 git_diff_print
($from_id, "a/$file", undef, "/dev/null");
2318 } elsif ($status eq "M") {
2319 if ($from_id ne $to_id) {
2320 print "<div class=\"diff_info\">" .
2321 file_type
($from_mode) . ":" . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;h=$from_id;hb=$hash;f=$file")}, $from_id) .
2323 file_type
($to_mode) . ":" . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, $to_id);
2325 git_diff_print
($from_id, "a/$file", $to_id, "b/$file");
2334 sub git_commitdiff_plain
{
2335 mkdir($git_temp, 0700);
2336 open my $fd, "-|", "$GIT diff-tree -r $hash_parent $hash" or die_error
(undef, "Open failed.");
2337 my (@difftree) = map { chomp; $_ } <$fd>;
2338 close $fd or die_error
(undef, "Reading diff-tree failed.");
2340 # try to figure out the next tag after this commit
2342 my $refs = read_info_ref
("tags");
2343 open $fd, "-|", "$GIT rev-list HEAD";
2344 chomp (my (@commits) = <$fd>);
2346 foreach my $commit (@commits) {
2347 if (defined $refs->{$commit}) {
2348 $tagname = $refs->{$commit}
2350 if ($commit eq $hash) {
2355 print $cgi->header(-type
=> "text/plain", -charset
=> 'utf-8', '-content-disposition' => "inline; filename=\"git-$hash.patch\"");
2356 my %co = git_read_commit
($hash);
2357 my %ad = date_str
($co{'author_epoch'}, $co{'author_tz'});
2358 my $comment = $co{'comment'};
2359 print "From: $co{'author'}\n" .
2360 "Date: $ad{'rfc2822'} ($ad{'tz_local'})\n".
2361 "Subject: $co{'title'}\n";
2362 if (defined $tagname) {
2363 print "X-Git-Tag: $tagname\n";
2365 print "X-Git-Url: $my_url?p=$project;a=commitdiff;h=$hash\n" .
2368 foreach my $line (@$comment) {;
2373 foreach my $line (@difftree) {
2374 $line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$/;
2379 if ($status eq "A") {
2380 git_diff_print
(undef, "/dev/null", $to_id, "b/$file", "plain");
2381 } elsif ($status eq "D") {
2382 git_diff_print
($from_id, "a/$file", undef, "/dev/null", "plain");
2383 } elsif ($status eq "M") {
2384 git_diff_print
($from_id, "a/$file", $to_id, "b/$file", "plain");
2390 if (!defined $hash_base) {
2391 $hash_base = git_read_head
($project);
2393 my %co = git_read_commit
($hash_base);
2395 die_error
(undef, "Unknown commit object.");
2397 my $refs = read_info_ref
();
2399 print "<div class=\"page_nav\">\n" .
2400 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary")}, "summary") .
2401 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog")}, "shortlog") .
2402 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log")}, "log") .
2403 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash_base")}, "commit") .
2404 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$hash_base")}, "commitdiff") .
2405 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;h=$co{'tree'};hb=$hash_base")}, "tree") .
2409 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash_base"), -class => "title"}, esc_html
($co{'title'})) . "\n" .
2411 if (!defined $hash && defined $file_name) {
2412 $hash = git_get_hash_by_path
($hash_base, $file_name);
2414 if (defined $hash) {
2415 my $ftype = git_get_type
($hash);
2417 if ($ftype =~ "blob") {
2418 print "<div class=\"page_path\"><b>/" .
2419 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob_plain;f=$file_name")}, esc_html
($file_name)) . "</b><br/></div>\n";
2421 print "<div class=\"page_path\"><b>/" . esc_html
($file_name) . "</b><br/></div>\n";
2424 print "<div class=\"page_path\"><b>/" . esc_html
($file_name) . "</b><br/></div>\n";
2428 "$GIT rev-list --full-history $hash_base -- \'$file_name\'";
2429 print "<table cellspacing=\"0\">\n";
2431 while (my $line = <$fd>) {
2432 if ($line =~ m/^([0-9a-fA-F]{40})/){
2434 my %co = git_read_commit
($commit);
2439 if (defined $refs->{$commit}) {
2440 $ref = " <span class=\"tag\">" . esc_html
($refs->{$commit}) . "</span>";
2443 print "<tr class=\"dark\">\n";
2445 print "<tr class=\"light\">\n";
2448 print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
2449 "<td><i>" . esc_html
(chop_str
($co{'author_name'}, 15, 3)) . "</i></td>\n" .
2450 "<td>" . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$commit"), -class => "list"}, "<b>" .
2451 esc_html
(chop_str
($co{'title'}, 50)) . "$ref</b>") . "</td>\n" .
2452 "<td class=\"link\">" .
2453 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$commit")}, "commit") .
2454 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$commit")}, "commitdiff") .
2455 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;hb=$commit;f=$file_name")}, "blob");
2456 my $blob = git_get_hash_by_path
($hash_base, $file_name);
2457 my $blob_parent = git_get_hash_by_path
($commit, $file_name);
2458 if (defined $blob && defined $blob_parent && $blob ne $blob_parent) {
2460 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blobdiff;h=$blob;hp=$blob_parent;hb=$commit;f=$file_name")},
2473 if (!defined $searchtext) {
2474 die_error
("", "Text field empty.");
2476 if (!defined $hash) {
2477 $hash = git_read_head
($project);
2479 my %co = git_read_commit
($hash);
2481 die_error
(undef, "Unknown commit object.");
2483 # pickaxe may take all resources of your box and run for several minutes
2484 # with every query - so decide by yourself how public you make this feature :)
2485 my $commit_search = 1;
2486 my $author_search = 0;
2487 my $committer_search = 0;
2488 my $pickaxe_search = 0;
2489 if ($searchtext =~ s/^author\\://i) {
2491 } elsif ($searchtext =~ s/^committer\\://i) {
2492 $committer_search = 1;
2493 } elsif ($searchtext =~ s/^pickaxe\\://i) {
2495 $pickaxe_search = 1;
2498 print "<div class=\"page_nav\">\n" .
2499 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary;h=$hash")}, "summary") .
2500 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog")}, "shortlog") .
2501 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log;h=$hash")}, "log") .
2502 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash")}, "commit") .
2503 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$hash")}, "commitdiff") .
2504 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") .
2509 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash"), -class => "title"}, esc_html
($co{'title'})) . "\n" .
2511 print "<table cellspacing=\"0\">\n";
2513 if ($commit_search) {
2515 open my $fd, "-|", "$GIT rev-list --header --parents $hash" or next;
2516 while (my $commit_text = <$fd>) {
2517 if (!grep m/$searchtext/i, $commit_text) {
2520 if ($author_search && !grep m/\nauthor .*$searchtext/i, $commit_text) {
2523 if ($committer_search && !grep m/\ncommitter .*$searchtext/i, $commit_text) {
2526 my @commit_lines = split "\n", $commit_text;
2527 my %co = git_read_commit
(undef, \
@commit_lines);
2532 print "<tr class=\"dark\">\n";
2534 print "<tr class=\"light\">\n";
2537 print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
2538 "<td><i>" . esc_html
(chop_str
($co{'author_name'}, 15, 5)) . "</i></td>\n" .
2540 $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/>");
2541 my $comment = $co{'comment'};
2542 foreach my $line (@$comment) {
2543 if ($line =~ m/^(.*)($searchtext)(.*)$/i) {
2544 my $lead = esc_html
($1) || "";
2545 $lead = chop_str
($lead, 30, 10);
2546 my $match = esc_html
($2) || "";
2547 my $trail = esc_html
($3) || "";
2548 $trail = chop_str
($trail, 30, 10);
2549 my $text = "$lead<span class=\"match\">$match</span>$trail";
2550 print chop_str
($text, 80, 5) . "<br/>\n";
2554 "<td class=\"link\">" .
2555 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$co{'id'}")}, "commit") .
2556 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;h=$co{'tree'};hb=$co{'id'}")}, "tree");
2563 if ($pickaxe_search) {
2565 open my $fd, "-|", "$GIT rev-list $hash | $GIT diff-tree -r --stdin -S\'$searchtext\'";
2568 while (my $line = <$fd>) {
2569 if (%co && $line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$/) {
2572 $set{'from_id'} = $3;
2574 $set{'id'} = $set{'to_id'};
2575 if ($set{'id'} =~ m/0{40}/) {
2576 $set{'id'} = $set{'from_id'};
2578 if ($set{'id'} =~ m/0{40}/) {
2582 } elsif ($line =~ m/^([0-9a-fA-F]{40})$/){
2585 print "<tr class=\"dark\">\n";
2587 print "<tr class=\"light\">\n";
2590 print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
2591 "<td><i>" . esc_html
(chop_str
($co{'author_name'}, 15, 5)) . "</i></td>\n" .
2593 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$co{'id'}"), -class => "list"}, "<b>" .
2594 esc_html
(chop_str
($co{'title'}, 50)) . "</b><br/>");
2595 while (my $setref = shift @files) {
2597 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;h=$set{'id'};hb=$co{'id'};f=$set{'file'}"), class => "list"},
2598 "<span class=\"match\">" . esc_html
($set{'file'}) . "</span>") .
2602 "<td class=\"link\">" .
2603 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$co{'id'}")}, "commit") .
2604 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;h=$co{'tree'};hb=$co{'id'}")}, "tree");
2608 %co = git_read_commit
($1);
2618 my $head = git_read_head
($project);
2619 if (!defined $hash) {
2622 if (!defined $page) {
2625 my $refs = read_info_ref
();
2627 print "<div class=\"page_nav\">\n" .
2628 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary")}, "summary") .
2630 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log;h=$hash")}, "log") .
2631 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash")}, "commit") .
2632 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$hash")}, "commitdiff") .
2633 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;h=$hash;hb=$hash")}, "tree") . "<br/>\n";
2635 my $limit = sprintf("--max-count=%i", (100 * ($page+1)));
2636 open my $fd, "-|", "$GIT rev-list $limit $hash" or die_error
(undef, "Open failed.");
2637 my (@revlist) = map { chomp; $_ } <$fd>;
2640 if ($hash ne $head || $page) {
2641 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog")}, "HEAD");
2647 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog;h=$hash;pg=" . ($page-1)), -accesskey
=> "p", -title
=> "Alt-p"}, "prev");
2649 print " ⋅ prev";
2651 if ($#revlist >= (100 * ($page+1)-1)) {
2653 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog;h=$hash;pg=" . ($page+1)), -accesskey
=> "n", -title
=> "Alt-n"}, "next");
2655 print " ⋅ next";
2660 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary"), -class => "title"}, " ") .
2662 print "<table cellspacing=\"0\">\n";
2664 for (my $i = ($page * 100); $i <= $#revlist; $i++) {
2665 my $commit = $revlist[$i];
2667 if (defined $refs->{$commit}) {
2668 $ref = " <span class=\"tag\">" . esc_html
($refs->{$commit}) . "</span>";
2670 my %co = git_read_commit
($commit);
2671 my %ad = date_str
($co{'author_epoch'});
2673 print "<tr class=\"dark\">\n";
2675 print "<tr class=\"light\">\n";
2678 print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
2679 "<td><i>" . esc_html
(chop_str
($co{'author_name'}, 10)) . "</i></td>\n" .
2681 if (length($co{'title_short'}) < length($co{'title'})) {
2682 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$commit"), -class => "list", -title
=> "$co{'title'}"},
2683 "<b>" . esc_html
($co{'title_short'}) . "$ref</b>");
2685 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$commit"), -class => "list"},
2686 "<b>" . esc_html
($co{'title_short'}) . "$ref</b>");
2689 "<td class=\"link\">" .
2690 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$commit")}, "commit") .
2691 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$commit")}, "commitdiff") .
2695 if ($#revlist >= (100 * ($page+1)-1)) {
2698 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog;h=$hash;pg=" . ($page+1)), -title
=> "Alt-n"}, "next") .