]>
Lady’s Gitweb - Gitweb/blob - gitweb.cgi
8fb8391935acdfb9fd0be1daec9b528eb20fad07b6cec8fc99d827702a95b11d
3 # gitweb - simple web interface to track changes in git repositories
5 # (C) 2005, Kay Sievers <kay.sievers@vrfy.org>
6 # (C) 2005, Christian Gierke <ch@gierke.de>
8 # This program is licensed under the 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 my $my_url = $cgi->url();
22 my $my_uri = $cgi->url(-absolute
=> 1);
25 # absolute fs-path which will be prepended to the project path
26 #my $projectroot = "/pub/scm";
27 my $projectroot = "/home/kay/public_html/pub/scm";
29 # location of the git-core binaries
30 my $gitbin = "/usr/bin";
32 # location for temporary files needed for diffs
33 my $git_temp = "/tmp/gitweb";
35 # target of the home link on top of all pages
36 my $home_link = $my_uri;
38 # html text to include at home page
39 my $home_text = "indextext.html";
41 # source of projects list
42 #my $projects_list = $projectroot;
43 my $projects_list = "index/index.aux";
45 # input validation and dispatch
46 my $action = $cgi->param('a');
47 if (defined $action) {
48 if ($action =~ m/[^0-9a-zA-Z\.\-_]/) {
50 die_error
(undef, "Invalid action parameter.");
52 if ($action eq "git-logo.png") {
55 } elsif ($action eq "opml") {
61 my $order = $cgi->param('o');
63 if ($order =~ m/[^0-9a-zA-Z_]/) {
65 die_error
(undef, "Invalid order parameter.");
69 my $project = $cgi->param('p');
70 if (defined $project) {
71 $project = validate_input
($project);
72 if (!defined($project)) {
73 die_error
(undef, "Invalid project parameter.");
75 if (!(-d
"$projectroot/$project")) {
77 die_error
(undef, "No such directory.");
79 if (!(-e
"$projectroot/$project/HEAD")) {
81 die_error
(undef, "No such project.");
83 $rss_link = "<link rel=\"alternate\" title=\"" . esc_param
($project) . " log\" href=\"" .
84 "$my_uri?" . esc_param
("p=$project;a=rss") . "\" type=\"application/rss+xml\"/>";
85 $ENV{'GIT_DIR'} = "$projectroot/$project";
91 my $file_name = $cgi->param('f');
92 if (defined $file_name) {
93 $file_name = validate_input
($file_name);
94 if (!defined($file_name)) {
95 die_error
(undef, "Invalid file parameter.");
99 my $hash = $cgi->param('h');
101 $hash = validate_input
($hash);
102 if (!defined($hash)) {
103 die_error
(undef, "Invalid hash parameter.");
107 my $hash_parent = $cgi->param('hp');
108 if (defined $hash_parent) {
109 $hash_parent = validate_input
($hash_parent);
110 if (!defined($hash_parent)) {
111 die_error
(undef, "Invalid hash parent parameter.");
115 my $hash_base = $cgi->param('hb');
116 if (defined $hash_base) {
117 $hash_base = validate_input
($hash_base);
118 if (!defined($hash_base)) {
119 die_error
(undef, "Invalid hash base parameter.");
123 my $page = $cgi->param('pg');
125 if ($page =~ m/[^0-9]$/) {
127 die_error
(undef, "Invalid page parameter.");
131 my $searchtext = $cgi->param('s');
132 if (defined $searchtext) {
133 if ($searchtext =~ m/[^a-zA-Z0-9_\.\/\
-\
+\
:\
@ ]/) {
135 die_error
(undef, "Invalid search parameter.");
137 $searchtext = quotemeta $searchtext;
143 if ($input =~ m/^[0-9a-fA-F]{40}$/) {
146 if ($input =~ m/(^|\/)(|\
.|\
.\
.)($|\
/)/) {
149 if ($input =~ m/[^a-zA-Z0-9_\x80-\xff\ \t\.\/\
-\
+\#\
~\
%]/) {
155 if (!defined $action || $action eq "summary") {
158 } elsif ($action eq "heads") {
161 } elsif ($action eq "tags") {
164 } elsif ($action eq "blob") {
167 } elsif ($action eq "blob_plain") {
170 } elsif ($action eq "tree") {
173 } elsif ($action eq "rss") {
176 } elsif ($action eq "commit") {
179 } elsif ($action eq "log") {
182 } elsif ($action eq "blobdiff") {
185 } elsif ($action eq "blobdiff_plain") {
186 git_blobdiff_plain
();
188 } elsif ($action eq "commitdiff") {
191 } elsif ($action eq "commitdiff_plain") {
192 git_commitdiff_plain
();
194 } elsif ($action eq "history") {
197 } elsif ($action eq "search") {
200 } elsif ($action eq "shortlog") {
203 } elsif ($action eq "tag") {
208 die_error
(undef, "Unknown action.");
212 # quote unsafe chars, but keep the slash, even when it's not
213 # correct, but quoted slashes look too horrible in bookmarks
216 $str =~ s/([^A-Za-z0-9\-_.~();\/;?:@&=])/sprintf
("%%%02X", ord($1))/eg
;
222 # replace invalid utf8 character with SUBSTITUTION sequence
225 $str = decode
("utf8", $str, Encode
::FB_DEFAULT
);
226 $str = escapeHTML
($str);
230 # git may return quoted and escaped filenames
233 if ($str =~ m/^"(.*)"$/) {
235 $str =~ s/\\([0-7]{1,3})/chr(oct($1))/eg;
240 sub git_header_html
{
241 my $status = shift || "200 OK";
245 if (defined $project) {
246 $title .= " - $project";
247 if (defined $action) {
248 $title .= "/$action";
251 print $cgi->header(-type
=>'text/html', -charset
=> 'utf-8', -status
=> $status, -expires
=> $expires);
253 <?xml version="1.0" encoding="utf-8"?>
254 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
255 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
256 <!-- git web interface v$version, (C) 2005, Kay Sievers <kay.sievers\@vrfy.org>, Christian Gierke <ch\@gierke.de> -->
258 <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
259 <meta name="robots" content="index, nofollow"/>
260 <title>$title</title>
262 <style type="text/css">
263 body { font-family: sans-serif; font-size: 12px; margin:0px; border:solid #d9d8d1; border-width:1px; margin:10px; }
265 a:hover, a:visited, a:active { color:#880000; }
266 div.page_header { height:25px; padding:8px; font-size:18px; font-weight:bold; background-color:#d9d8d1; }
267 div.page_header a:visited, a.header { color:#0000cc; }
268 div.page_header a:hover { color:#880000; }
269 div.page_nav { padding:8px; }
270 div.page_nav a:visited { color:#0000cc; }
271 div.page_path { padding:8px; border:solid #d9d8d1; border-width:0px 0px 1px}
272 div.page_footer { height:17px; padding:4px 8px; background-color: #d9d8d1; }
273 div.page_footer_text { float:left; color:#555555; font-style:italic; }
274 div.page_body { padding:8px; }
276 display:block; padding:6px 8px;
277 font-weight:bold; background-color:#edece6; text-decoration:none; color:#000000;
279 a.title:hover { background-color: #d9d8d1; }
280 div.title_text { padding:6px 0px; border: solid #d9d8d1; border-width:0px 0px 1px; }
281 div.log_body { padding:8px 8px 8px 150px; }
282 span.age { position:relative; float:left; width:142px; font-style:italic; }
285 font-size:10px; font-family:sans-serif; font-style:normal;
286 position:relative; float:left; width:136px;
288 div.list_head { padding:6px 8px 4px; border:solid #d9d8d1; border-width:1px 0px 0px; font-style:italic; }
289 a.list { text-decoration:none; color:#000000; }
290 a.list:hover { text-decoration:underline; color:#880000; }
291 a.text { text-decoration:none; color:#0000cc; }
292 a.text:visited { text-decoration:none; color:#880000; }
293 a.text:hover { text-decoration:underline; color:#880000; }
294 table { padding:8px 4px; }
295 th { padding:2px 5px; font-size:12px; text-align:left; }
296 tr.light:hover { background-color:#edece6; }
297 tr.dark { background-color:#f6f6f0; }
298 tr.dark:hover { background-color:#edece6; }
299 td { padding:2px 5px; font-size:12px; vertical-align:top; }
300 td.link { padding:2px 5px; font-family:sans-serif; font-size:10px; }
301 div.pre { font-family:monospace; font-size:12px; white-space:pre; }
302 div.diff_info { font-family:monospace; color:#000099; background-color:#edece6; font-style:italic; }
303 div.index_include { border:solid #d9d8d1; border-width:0px 0px 1px; padding:12px 8px; }
304 div.search { margin:4px 8px; position:absolute; top:56px; right:12px }
305 a.linenr { color:#999999; text-decoration:none }
307 float:right; padding:3px 0px; width:35px; line-height:10px;
308 border:1px solid; border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e;
309 color:#ffffff; background-color:#ff6600;
310 font-weight:bold; font-family:sans-serif; font-size:10px;
311 text-align:center; text-decoration:none;
313 a.rss_logo:hover { background-color:#ee5500; }
315 padding:0px 4px; font-size:10px; font-weight:normal;
316 background-color:#ffffaa; border:1px solid; border-color:#ffffcc #ffee00 #ffee00 #ffffcc;
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) {
338 $search_hash = $hash;
340 $search_hash = "HEAD";
342 $cgi->param("a", "search");
343 $cgi->param("h", $search_hash);
344 print $cgi->startform(-method => "get", -action
=> $my_uri) .
345 "<div class=\"search\">\n" .
346 $cgi->hidden(-name
=> "p") . "\n" .
347 $cgi->hidden(-name
=> "a") . "\n" .
348 $cgi->hidden(-name
=> "h") . "\n" .
349 $cgi->textfield(-name
=> "s", -value
=> $searchtext) . "\n" .
351 $cgi->end_form() . "\n";
356 sub git_footer_html
{
357 print "<div class=\"page_footer\">\n";
358 if (defined $project) {
359 my $descr = git_read_description
($project);
360 if (defined $descr) {
361 print "<div class=\"page_footer_text\">" . esc_html
($descr) . "</div>\n";
363 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=rss"), -class => "rss_logo"}, "RSS") . "\n";
365 print $cgi->a({-href
=> "$my_uri?" . esc_param
("a=opml"), -class => "rss_logo"}, "OPML") . "\n";
373 my $status = shift || "403 Forbidden";
374 my $error = shift || "Malformed query, file missing or permission denied";
376 git_header_html
($status);
377 print "<div class=\"page_body\">\n" .
379 "$status - $error\n" .
389 open my $fd, "-|", "$gitbin/git-cat-file -t $hash" or return;
399 open my $fd, "$projectroot/$path" or return undef;
403 if ($head =~ m/^[0-9a-fA-F]{40}$/) {
408 sub git_read_description
{
411 open my $fd, "$projectroot/$path/description" or return undef;
423 open my $fd, "-|", "$gitbin/git-cat-file tag $tag_id" or return;
424 $tag{'id'} = $tag_id;
425 while (my $line = <$fd>) {
427 if ($line =~ m/^object ([0-9a-fA-F]{40})$/) {
429 } elsif ($line =~ m/^type (.+)$/) {
431 } elsif ($line =~ m/^tag (.+)$/) {
433 } elsif ($line =~ m/^tagger (.*) ([0-9]+) (.*)$/) {
437 } elsif ($line =~ m/--BEGIN/) {
438 push @comment, $line;
440 } elsif ($line eq "") {
444 push @comment, <$fd>;
445 $tag{'comment'} = \
@comment;
447 if (!defined $tag{'name'}) {
457 if ($age > 60*60*24*365*2) {
458 $age_str = (int $age/60/60/24/365);
459 $age_str .= " years ago";
460 } elsif ($age > 60*60*24*(365/12)*2) {
461 $age_str = int $age/60/60/24/(365/12);
462 $age_str .= " months ago";
463 } elsif ($age > 60*60*24*7*2) {
464 $age_str = int $age/60/60/24/7;
465 $age_str .= " weeks ago";
466 } elsif ($age > 60*60*24*2) {
467 $age_str = int $age/60/60/24;
468 $age_str .= " days ago";
469 } elsif ($age > 60*60*2) {
470 $age_str = int $age/60/60;
471 $age_str .= " hours ago";
472 } elsif ($age > 60*2) {
473 $age_str = int $age/60;
474 $age_str .= " min ago";
477 $age_str .= " sec ago";
479 $age_str .= " right now";
484 sub git_read_commit
{
485 my $commit_id = shift;
486 my $commit_text = shift;
491 if (defined $commit_text) {
492 @commit_lines = @$commit_text;
495 open my $fd, "-|", "$gitbin/git-rev-list --header --parents --max-count=1 $commit_id" or return;
496 @commit_lines = split '\n', <$fd>;
501 my $header = shift @commit_lines;
502 if (!($header =~ m/^[0-9a-fA-F]{40}/)) {
505 ($co{'id'}, my @parents) = split ' ', $header;
506 $co{'parents'} = \
@parents;
507 $co{'parent'} = $parents[0];
508 while (my $line = shift @commit_lines) {
509 last if $line eq "\n";
510 if ($line =~ m/^tree ([0-9a-fA-F]{40})$/) {
512 } elsif ($line =~ m/^author (.*) ([0-9]+) (.*)$/) {
514 $co{'author_epoch'} = $2;
515 $co{'author_tz'} = $3;
516 if ($co{'author'} =~ m/^([^<]+) </) {
517 $co{'author_name'} = $1;
519 $co{'author_name'} = $co{'author'};
521 } elsif ($line =~ m/^committer (.*) ([0-9]+) (.*)$/) {
522 $co{'committer'} = $1;
523 $co{'committer_epoch'} = $2;
524 $co{'committer_tz'} = $3;
525 $co{'committer_name'} = $co{'committer'};
526 $co{'committer_name'} =~ s/ <.*//;
529 if (!defined $co{'tree'}) {
533 foreach my $title (@commit_lines) {
536 $co{'title'} = chop_str
($title, 80, 5);
537 # remove leading stuff of merges to make the interesting part visible
538 if (length($title) > 50) {
539 $title =~ s/^Automatic //;
540 $title =~ s/^merge (of|with) /Merge ... /i;
541 if (length($title) > 50) {
542 $title =~ s/(http|rsync):\/\///;
544 if (length($title) > 50) {
545 $title =~ s/(master|www|rsync)\.//;
547 if (length($title) > 50) {
548 $title =~ s/kernel.org:?//;
550 if (length($title) > 50) {
551 $title =~ s/\/pub\/scm//;
554 $co{'title_short'} = chop_str
($title, 50, 5);
558 # remove added spaces
559 foreach my $line (@commit_lines) {
562 $co{'comment'} = \
@commit_lines;
564 my $age = time - $co{'committer_epoch'};
566 $co{'age_string'} = age_string
($age);
567 my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($co{'committer_epoch'});
568 if ($age > 60*60*24*7*2) {
569 $co{'age_string_date'} = sprintf "%4i-%02u-%02i", 1900 + $year, $mon+1, $mday;
570 $co{'age_string_age'} = $co{'age_string'};
572 $co{'age_string_date'} = $co{'age_string'};
573 $co{'age_string_age'} = sprintf "%4i-%02u-%02i", 1900 + $year, $mon+1, $mday;
580 my $from_name = shift;
583 my $format = shift || "html";
585 my $from_tmp = "/dev/null";
586 my $to_tmp = "/dev/null";
589 # create tmp from-file
591 $from_tmp = "$git_temp/gitweb_" . $$ . "_from";
592 open my $fd2, "> $from_tmp";
593 open my $fd, "-|", "$gitbin/git-cat-file blob $from";
602 $to_tmp = "$git_temp/gitweb_" . $$ . "_to";
603 open my $fd2, "> $to_tmp";
604 open my $fd, "-|", "$gitbin/git-cat-file blob $to";
611 open my $fd, "-|", "/usr/bin/diff -u -p -L \'$from_name\' -L \'$to_name\' $from_tmp $to_tmp";
612 if ($format eq "plain") {
617 while (my $line = <$fd>) {
619 my $char = substr($line, 0, 1);
622 $color = " style=\"color:#008800;\"";
623 } elsif ($char eq "-") {
624 $color = " style=\"color:#cc0000;\"";
625 } elsif ($char eq "@") {
626 $color = " style=\"color:#990099;\"";
627 } elsif ($char eq "\\") {
631 while ((my $pos = index($line, "\t")) != -1) {
632 if (my $count = (8 - (($pos-1) % 8))) {
633 my $spaces = ' ' x
$count;
634 $line =~ s/\t/$spaces/;
637 print "<div class=\"pre\"$color>" . esc_html
($line) . "</div>\n";
651 my $mode = oct shift;
653 if (S_ISDIR
($mode & S_IFMT
)) {
655 } elsif (S_ISLNK
($mode)) {
657 } elsif (S_ISREG
($mode)) {
658 # git cares only about the executable bit
659 if ($mode & S_IXUSR
) {
672 my $add_len = shift || 10;
674 # allow only $len chars, but don't cut a word if it would fit in $add_len
675 # if it doesn't fit, cut it if it's still longer than the dots we would add
676 $str =~ m/^(.{0,$len}[^ \/\
-_
:\
.@]{0,$add_len})(.*)/;
679 if (length($tail) > 4) {
686 my $mode = oct shift;
688 if (S_ISDIR
($mode & S_IFMT
)) {
690 } elsif (S_ISLNK
($mode)) {
692 } elsif (S_ISREG
($mode)) {
699 sub format_log_line_html
{
702 $line = esc_html
($line);
703 $line =~ s/ / /g;
704 if ($line =~ m/([0-9a-fA-F]{40})/) {
706 if (git_get_type
($hash_text) eq "commit") {
707 my $link = $cgi->a({-class => "text", -href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash_text")}, $hash_text);
708 $line =~ s/$hash_text/$link/;
716 my $tz = shift || "-0000";
719 my @months = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
720 my @days = ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
721 my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($epoch);
722 $date{'hour'} = $hour;
723 $date{'minute'} = $min;
724 $date{'mday'} = $mday;
725 $date{'day'} = $days[$wday];
726 $date{'month'} = $months[$mon];
727 $date{'rfc2822'} = sprintf "%s, %d %s %4d %02d:%02d:%02d +0000", $days[$wday], $mday, $months[$mon], 1900+$year, $hour ,$min, $sec;
728 $date{'mday-time'} = sprintf "%d %s %02d:%02d", $mday, $months[$mon], $hour ,$min;
730 $tz =~ m/^([+\-][0-9][0-9])([0-9][0-9])$/;
731 my $local = $epoch + ((int $1 + ($2/60)) * 3600);
732 ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($local);
733 $date{'hour_local'} = $hour;
734 $date{'minute_local'} = $min;
735 $date{'tz_local'} = $tz;
739 # git-logo (cached in browser for one day)
741 binmode STDOUT
, ':raw';
742 print $cgi->header(-type
=> 'image/png', -expires
=> '+1d');
743 # cat git-logo.png | hexdump -e '16/1 " %02x" "\n"' | sed 's/ /\\x/g'
744 print "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52" .
745 "\x00\x00\x00\x48\x00\x00\x00\x1b\x04\x03\x00\x00\x00\x2d\xd9\xd4" .
746 "\x2d\x00\x00\x00\x18\x50\x4c\x54\x45\xff\xff\xff\x60\x60\x5d\xb0" .
747 "\xaf\xaa\x00\x80\x00\xce\xcd\xc7\xc0\x00\x00\xe8\xe8\xe6\xf7\xf7" .
748 "\xf6\x95\x0c\xa7\x47\x00\x00\x00\x73\x49\x44\x41\x54\x28\xcf\x63" .
749 "\x48\x67\x20\x04\x4a\x5c\x18\x0a\x08\x2a\x62\x53\x61\x20\x02\x08" .
750 "\x0d\x69\x45\xac\xa1\xa1\x01\x30\x0c\x93\x60\x36\x26\x52\x91\xb1" .
751 "\x01\x11\xd6\xe1\x55\x64\x6c\x6c\xcc\x6c\x6c\x0c\xa2\x0c\x70\x2a" .
752 "\x62\x06\x2a\xc1\x62\x1d\xb3\x01\x02\x53\xa4\x08\xe8\x00\x03\x18" .
753 "\x26\x56\x11\xd4\xe1\x20\x97\x1b\xe0\xb4\x0e\x35\x24\x71\x29\x82" .
754 "\x99\x30\xb8\x93\x0a\x11\xb9\x45\x88\xc1\x8d\xa0\xa2\x44\x21\x06" .
755 "\x27\x41\x82\x40\x85\xc1\x45\x89\x20\x70\x01\x00\xa4\x3d\x21\xc5" .
756 "\x12\x1c\x9a\xfe\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82";
762 my ($dev, $ino, $mode, $nlink, $st_uid, $st_gid, $rdev, $size) = stat($path);
763 my ($name, $passwd, $uid, $gid, $quota, $comment, $gcos, $dir, $shell) = getpwuid($st_uid);
764 if (!defined $gcos) {
768 $owner =~ s/[,;].*$//;
772 sub git_read_projects
{
775 if (-d
$projects_list) {
776 # search in directory
777 my $dir = $projects_list;
778 opendir my $dh, $dir or return undef;
779 while (my $dir = readdir($dh)) {
780 if (-e
"$projectroot/$dir/HEAD") {
788 } elsif (-f
$projects_list) {
789 # read from file(url-encoded):
790 # 'git%2Fgit.git Linus+Torvalds'
791 # 'libs%2Fklibc%2Fklibc.git H.+Peter+Anvin'
792 # 'linux%2Fhotplug%2Fudev.git Greg+Kroah-Hartman'
793 open my $fd , $projects_list or return undef;
794 while (my $line = <$fd>) {
796 my ($path, $owner) = split ' ', $line;
797 $path = unescape
($path);
798 $owner = unescape
($owner);
799 if (!defined $path) {
802 if (-e
"$projectroot/$path/HEAD") {
812 @list = sort {$a->{'path'} cmp $b->{'path'}} @list;
816 sub git_project_list
{
817 my @list = git_read_projects
();
820 die_error
(undef, "No project found.");
822 foreach my $pr (@list) {
823 my $head = git_read_hash
("$pr->{'path'}/HEAD");
824 if (!defined $head) {
827 $ENV{'GIT_DIR'} = "$projectroot/$pr->{'path'}";
828 my %co = git_read_commit
($head);
832 $pr->{'commit'} = \
%co;
833 if (!defined $pr->{'descr'}) {
834 my $descr = git_read_description
($pr->{'path'}) || "";
835 $pr->{'descr'} = chop_str
($descr, 25, 5);
837 if (!defined $pr->{'owner'}) {
838 $pr->{'owner'} = get_file_owner
("$projectroot/$pr->{'path'}") || "";
844 print "<div class=\"index_include\">\n";
845 open (my $fd, $home_text);
850 print "<table cellspacing=\"0\">\n" .
852 if (!defined($order) || (defined($order) && ($order eq "project"))) {
853 @projects = sort {$a->{'path'} cmp $b->{'path'}} @projects;
854 print "<th>Project</th>\n";
856 print "<th>" . $cgi->a({-class => "header", -href
=> "$my_uri?" . esc_param
("o=project")}, "Project") . "</th>\n";
858 if (defined($order) && ($order eq "descr")) {
859 @projects = sort {$a->{'descr'} cmp $b->{'descr'}} @projects;
860 print "<th>Description</th>\n";
862 print "<th>" . $cgi->a({-class => "header", -href
=> "$my_uri?" . esc_param
("o=descr")}, "Description") . "</th>\n";
864 if (defined($order) && ($order eq "owner")) {
865 @projects = sort {$a->{'owner'} cmp $b->{'owner'}} @projects;
866 print "<th>Owner</th>\n";
868 print "<th>" . $cgi->a({-class => "header", -href
=> "$my_uri?" . esc_param
("o=owner")}, "Owner") . "</th>\n";
870 if (defined($order) && ($order eq "age")) {
871 @projects = sort {$a->{'commit'}{'age'} <=> $b->{'commit'}{'age'}} @projects;
872 print "<th>Last Change</th>\n";
874 print "<th>" . $cgi->a({-class => "header", -href
=> "$my_uri?" . esc_param
("o=age")}, "Last Change") . "</th>\n";
876 print "<th></th>\n" .
879 foreach my $pr (@projects) {
881 print "<tr class=\"dark\">\n";
883 print "<tr class=\"light\">\n";
886 print "<td>" . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$pr->{'path'};a=summary"), -class => "list"}, esc_html
($pr->{'path'})) . "</td>\n" .
887 "<td>$pr->{'descr'}</td>\n" .
888 "<td><i>" . chop_str
($pr->{'owner'}, 15) . "</i></td>\n";
890 if ($pr->{'commit'}{'age'} < 60*60*2) {
891 $colored_age = "<span style =\"color: #009900;\"><b><i>$pr->{'commit'}{'age_string'}</i></b></span>";
892 } elsif ($pr->{'commit'}{'age'} < 60*60*24*2) {
893 $colored_age = "<span style =\"color: #009900;\"><i>$pr->{'commit'}{'age_string'}</i></span>";
895 $colored_age = "<i>$pr->{'commit'}{'age_string'}</i>";
897 print "<td>$colored_age</td>\n" .
898 "<td class=\"link\">" .
899 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$pr->{'path'};a=summary")}, "summary") .
900 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$pr->{'path'};a=shortlog")}, "shortlog") .
901 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$pr->{'path'};a=log")}, "log") .
910 my $type = shift || "";
912 # 5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c refs/tags/v2.6.11
913 # c39ae07f393806ccf406ef966e9a15afc43cc36a refs/tags/v2.6.11^{}
914 open my $fd, "$projectroot/$project/info/refs" or return;
915 while (my $line = <$fd>) {
917 if ($line =~ m/^([0-9a-fA-F]{40})\t.*$type\/([^\
^]+)/) {
918 if (defined $refs{$1}) {
919 $refs{$1} .= " / $2";
934 opendir my $dh, "$projectroot/$project/$ref_dir";
935 while (my $dir = readdir($dh)) {
936 if ($dir =~ m/^\./) {
939 if (-d
"$projectroot/$project/$ref_dir/$dir") {
940 opendir my $dh2, "$projectroot/$project/$ref_dir/$dir";
941 my @subdirs = grep !m/^\./, readdir $dh2;
943 foreach my $subdir (@subdirs) {
944 push @refs, "$dir/$subdir"
951 foreach my $ref_file (@refs) {
952 my $ref_id = git_read_hash
("$project/$ref_dir/$ref_file");
953 my $type = git_get_type
($ref_id) || next;
956 $ref_item{'type'} = $type;
957 $ref_item{'id'} = $ref_id;
958 $ref_item{'epoch'} = 0;
959 $ref_item{'age'} = "unknown";
960 if ($type eq "tag") {
961 my %tag = git_read_tag
($ref_id);
962 $ref_item{'comment'} = $tag{'comment'};
963 if ($tag{'type'} eq "commit") {
964 %co = git_read_commit
($tag{'object'});
965 $ref_item{'epoch'} = $co{'committer_epoch'};
966 $ref_item{'age'} = $co{'age_string'};
967 } elsif (defined($tag{'epoch'})) {
968 my $age = time - $tag{'epoch'};
969 $ref_item{'epoch'} = $tag{'epoch'};
970 $ref_item{'age'} = age_string
($age);
972 $ref_item{'reftype'} = $tag{'type'};
973 $ref_item{'name'} = $tag{'name'};
974 $ref_item{'refid'} = $tag{'object'};
975 } elsif ($type eq "commit"){
976 %co = git_read_commit
($ref_id);
977 $ref_item{'reftype'} = "commit";
978 $ref_item{'name'} = $ref_file;
979 $ref_item{'title'} = $co{'title'};
980 $ref_item{'refid'} = $ref_id;
981 $ref_item{'epoch'} = $co{'committer_epoch'};
982 $ref_item{'age'} = $co{'age_string'};
985 push @reflist, \
%ref_item;
988 @reflist = sort {$b->{'epoch'} <=> $a->{'epoch'}} @reflist;
993 my $descr = git_read_description
($project) || "none";
994 my $head = git_read_hash
("$project/HEAD");
995 my %co = git_read_commit
($head);
996 my %cd = date_str
($co{'committer_epoch'}, $co{'committer_tz'});
999 if (-f
$projects_list) {
1000 open (my $fd , $projects_list);
1001 while (my $line = <$fd>) {
1003 my ($pr, $ow) = split ' ', $line;
1004 $pr = unescape
($pr);
1005 $ow = unescape
($ow);
1006 if ($pr eq $project) {
1013 if (!defined $owner) {
1014 $owner = get_file_owner
("$projectroot/$project");
1017 my $refs = read_info_ref
();
1019 print "<div class=\"page_nav\">\n" .
1021 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog")}, "shortlog") .
1022 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log")}, "log") .
1023 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$head")}, "commit") .
1024 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$head")}, "commitdiff") .
1025 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree")}, "tree") .
1028 print "<div class=\"title\"> </div>\n";
1029 print "<table cellspacing=\"0\">\n" .
1030 "<tr><td>description</td><td>" . esc_html
($descr) . "</td></tr>\n" .
1031 "<tr><td>owner</td><td>$owner</td></tr>\n" .
1032 "<tr><td>last change</td><td>$cd{'rfc2822'}</td></tr>\n" .
1034 open my $fd, "-|", "$gitbin/git-rev-list --max-count=17 " . git_read_hash
("$project/HEAD") or die_error
(undef, "Open failed.");
1035 my (@revlist) = map { chomp; $_ } <$fd>;
1038 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog"), -class => "title"}, "shortlog") .
1041 print "<table cellspacing=\"0\">\n";
1043 foreach my $commit (@revlist) {
1044 my %co = git_read_commit
($commit);
1045 my %ad = date_str
($co{'author_epoch'});
1047 print "<tr class=\"dark\">\n";
1049 print "<tr class=\"light\">\n";
1054 if (defined $refs->{$commit}) {
1055 $ref = " <span class=\"tag\">" . esc_html
($refs->{$commit}) . "</span>";
1057 print "<td><i>$co{'age_string'}</i></td>\n" .
1058 "<td><i>" . esc_html
(chop_str
($co{'author_name'}, 10)) . "</i></td>\n" .
1060 if (length($co{'title_short'}) < length($co{'title'})) {
1061 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$commit"), -class => "list", -title
=> "$co{'title'}"},
1062 "<b>" . esc_html
($co{'title_short'}) . "$ref</b>");
1064 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$commit"), -class => "list"},
1065 "<b>" . esc_html
($co{'title'}) . "$ref</b>");
1068 "<td class=\"link\">" .
1069 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$commit")}, "commit") .
1070 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$commit")}, "commitdiff") .
1074 print "<td>" . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog")}, "...") . "</td>\n" .
1081 my $taglist = git_read_refs
("refs/tags");
1082 if (defined @$taglist) {
1084 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tags"), -class => "title"}, "tags") .
1087 print "<table cellspacing=\"0\">\n";
1089 foreach my $entry (@$taglist) {
1091 my $comment_lines = $tag{'comment'};
1092 my $comment = shift @$comment_lines;
1093 if (defined($comment)) {
1094 $comment = chop_str
($comment, 30, 5);
1097 print "<tr class=\"dark\">\n";
1099 print "<tr class=\"light\">\n";
1103 print "<td><i>$tag{'age'}</i></td>\n" .
1105 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=$tag{'reftype'};h=$tag{'refid'}"), -class => "list"},
1106 "<b>" . esc_html
($tag{'name'}) . "</b>") .
1109 if (defined($comment)) {
1110 print $cgi->a({-class => "list", -href
=> "$my_uri?" . esc_param
("p=$project;a=tag;h=$tag{'id'}")}, $comment);
1113 "<td class=\"link\">";
1114 if ($tag{'type'} eq "tag") {
1115 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tag;h=$tag{'id'}")}, "tag") . " | ";
1117 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=$tag{'reftype'};h=$tag{'refid'}")}, $tag{'reftype'});
1118 if ($tag{'reftype'} eq "commit") {
1119 print " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog;h=$tag{'name'}")}, "shortlog") .
1120 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log;h=$tag{'refid'}")}, "log");
1125 print "<td>" . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tags")}, "...") . "</td>\n" .
1133 my $headlist = git_read_refs
("refs/heads");
1134 if (defined @$headlist) {
1136 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=heads"), -class => "title"}, "heads") .
1139 print "<table cellspacing=\"0\">\n";
1141 foreach my $entry (@$headlist) {
1144 print "<tr class=\"dark\">\n";
1146 print "<tr class=\"light\">\n";
1150 print "<td><i>$tag{'age'}</i></td>\n" .
1152 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog;h=$tag{'name'}"), -class => "list"},
1153 "<b>" . esc_html
($tag{'name'}) . "</b>") .
1155 "<td class=\"link\">" .
1156 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog;h=$tag{'name'}")}, "shortlog") .
1157 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log;h=$tag{'name'}")}, "log") .
1161 print "<td>" . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=heads")}, "...") . "</td>\n" .
1172 my $head = git_read_hash
("$project/HEAD");
1174 print "<div class=\"page_nav\">\n" .
1175 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary")}, "summary") .
1176 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog")}, "shortlog") .
1177 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log")}, "log") .
1178 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$head")}, "commit") .
1179 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$head")}, "commitdiff") .
1180 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;hb=$head")}, "tree") . "<br/>\n" .
1183 my %tag = git_read_tag
($hash);
1185 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash"), -class => "title"}, esc_html
($tag{'name'})) . "\n" .
1187 print "<div class=\"title_text\">\n" .
1188 "<table cellspacing=\"0\">\n" .
1190 "<td>object</td>\n" .
1191 "<td>" . $cgi->a({-class => "list", -href
=> "$my_uri?" . esc_param
("p=$project;a=$tag{'type'};h=$tag{'object'}")}, $tag{'object'}) . "</td>\n" .
1192 "<td class=\"link\">" . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=$tag{'type'};h=$tag{'object'}")}, $tag{'type'}) . "</td>\n" .
1194 if (defined($tag{'author'})) {
1195 my %ad = date_str
($tag{'epoch'}, $tag{'tz'});
1196 print "<tr><td>author</td><td>" . esc_html
($tag{'author'}) . "</td></tr>\n";
1197 print "<tr><td></td><td>" . $ad{'rfc2822'} . sprintf(" (%02d:%02d %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'}) . "</td></tr>\n";
1199 print "</table>\n\n" .
1201 print "<div class=\"page_body\">";
1202 my $comment = $tag{'comment'};
1203 foreach my $line (@$comment) {
1204 print esc_html
($line) . "<br/>\n";
1211 my $head = git_read_hash
("$project/HEAD");
1213 print "<div class=\"page_nav\">\n" .
1214 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary")}, "summary") .
1215 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog")}, "shortlog") .
1216 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log")}, "log") .
1217 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$head")}, "commit") .
1218 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$head")}, "commitdiff") .
1219 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;hb=$head")}, "tree") . "<br/>\n" .
1222 my $taglist = git_read_refs
("refs/tags");
1224 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary"), -class => "title"}, " ") .
1226 print "<table cellspacing=\"0\">\n";
1228 if (defined @$taglist) {
1229 foreach my $entry (@$taglist) {
1231 my $comment_lines = $tag{'comment'};
1232 my $comment = shift @$comment_lines;
1233 if (defined($comment)) {
1234 $comment = chop_str
($comment, 30, 5);
1237 print "<tr class=\"dark\">\n";
1239 print "<tr class=\"light\">\n";
1242 print "<td><i>$tag{'age'}</i></td>\n" .
1244 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=$tag{'reftype'};h=$tag{'refid'}"), -class => "list"},
1245 "<b>" . esc_html
($tag{'name'}) . "</b>") .
1248 if (defined($comment)) {
1249 print $cgi->a({-class => "list", -href
=> "$my_uri?" . esc_param
("p=$project;a=tag;h=$tag{'id'}")}, $comment);
1252 "<td class=\"link\">";
1253 if ($tag{'type'} eq "tag") {
1254 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tag;h=$tag{'id'}")}, "tag") . " | ";
1256 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=$tag{'reftype'};h=$tag{'refid'}")}, $tag{'reftype'});
1257 if ($tag{'reftype'} eq "commit") {
1258 print " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog;h=$tag{'name'}")}, "shortlog") .
1259 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log;h=$tag{'refid'}")}, "log");
1270 my $head = git_read_hash
("$project/HEAD");
1272 print "<div class=\"page_nav\">\n" .
1273 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary")}, "summary") .
1274 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog")}, "shortlog") .
1275 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log")}, "log") .
1276 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$head")}, "commit") .
1277 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$head")}, "commitdiff") .
1278 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;hb=$head")}, "tree") . "<br/>\n" .
1281 my $taglist = git_read_refs
("refs/heads");
1283 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary"), -class => "title"}, " ") .
1285 print "<table cellspacing=\"0\">\n";
1287 if (defined @$taglist) {
1288 foreach my $entry (@$taglist) {
1291 print "<tr class=\"dark\">\n";
1293 print "<tr class=\"light\">\n";
1296 print "<td><i>$tag{'age'}</i></td>\n" .
1298 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog;h=$tag{'name'}"), -class => "list"}, "<b>" . esc_html
($tag{'name'}) . "</b>") .
1300 "<td class=\"link\">" .
1301 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog;h=$tag{'name'}")}, "shortlog") .
1302 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log;h=$tag{'name'}")}, "log") .
1311 sub git_get_hash_by_path
{
1313 my $path = shift || return undef;
1316 my @parts = split '/', $path;
1317 while (my $part = shift @parts) {
1318 open my $fd, "-|", "$gitbin/git-ls-tree $tree" or die_error
(undef, "Open git-ls-tree failed.");
1319 my (@entries) = map { chomp; $_ } <$fd>;
1320 close $fd or return undef;
1321 foreach my $line (@entries) {
1322 #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c'
1323 $line =~ m/^([0-9]+) (.+) ([0-9a-fA-F]{40})\t(.+)$/;
1327 my $t_name = validate_input
(unquote
($4));
1328 if ($t_name eq $part) {
1332 if ($t_type eq "tree") {
1342 if (!defined $hash && defined $file_name) {
1343 my $base = $hash_base || git_read_hash
("$project/HEAD");
1344 $hash = git_get_hash_by_path
($base, $file_name, "blob") || die_error
(undef, "Error lookup file.");
1346 open my $fd, "-|", "$gitbin/git-cat-file blob $hash" or die_error
(undef, "Open failed.");
1348 if (defined $hash_base && (my %co = git_read_commit
($hash_base))) {
1349 print "<div class=\"page_nav\">\n" .
1350 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary")}, "summary") .
1351 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog")}, "shortlog") .
1352 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log")}, "log") .
1353 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash_base")}, "commit") .
1354 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$hash_base")}, "commitdiff") .
1355 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;h=$co{'tree'};hb=$hash_base")}, "tree") . "<br/>\n";
1356 if (defined $file_name) {
1357 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob_plain;h=$hash;f=$file_name")}, "plain") .
1358 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;hb=HEAD;f=$file_name")}, "head") . "<br/>\n";
1360 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob_plain;h=$hash")}, "plain") . "<br/>\n";
1364 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash_base"), -class => "title"}, esc_html
($co{'title'})) .
1367 print "<div class=\"page_nav\">\n" .
1368 "<br/><br/></div>\n" .
1369 "<div class=\"title\">$hash</div>\n";
1371 if (defined $file_name) {
1372 print "<div class=\"page_path\"><b>" . esc_html
($file_name) . "</b></div>\n";
1374 print "<div class=\"page_body\">\n";
1376 while (my $line = <$fd>) {
1379 while ((my $pos = index($line, "\t")) != -1) {
1380 if (my $count = (8 - ($pos % 8))) {
1381 my $spaces = ' ' x
$count;
1382 $line =~ s/\t/$spaces/;
1385 printf "<div class=\"pre\"><a id=\"l%i\" href=\"#l%i\" class=\"linenr\">%4i</a> %s</div>\n", $nr, $nr, $nr, esc_html
($line);
1387 close $fd or print "Reading blob failed.\n";
1392 sub git_blob_plain
{
1393 my $save_as = "$hash.txt";
1394 if (defined $file_name) {
1395 $save_as = $file_name;
1397 print $cgi->header(-type
=> "text/plain", -charset
=> 'utf-8', '-content-disposition' => "inline; filename=\"$save_as\"");
1398 open my $fd, "-|", "$gitbin/git-cat-file blob $hash" or return;
1406 if (!defined $hash) {
1407 $hash = git_read_hash
("$project/HEAD");
1408 if (defined $file_name) {
1409 my $base = $hash_base || git_read_hash
("$project/HEAD");
1410 $hash = git_get_hash_by_path
($base, $file_name, "tree");
1412 if (!defined $hash_base) {
1413 $hash_base = git_read_hash
("$project/HEAD");
1417 open my $fd, "-|", "$gitbin/git-ls-tree -z $hash" or die_error
(undef, "Open git-ls-tree failed.");
1418 chomp (my (@entries) = <$fd>);
1419 close $fd or die_error
(undef, "Reading tree failed.");
1422 my $refs = read_info_ref
();
1424 if (defined $refs->{$hash_base}) {
1425 $ref = " <span class=\"tag\">" . esc_html
($refs->{$hash_base}) . "</span>";
1430 if (defined $hash_base && (my %co = git_read_commit
($hash_base))) {
1431 $base_key = ";hb=$hash_base";
1432 print "<div class=\"page_nav\">\n" .
1433 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary")}, "summary") .
1434 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog;h=$hash_base")}, "shortlog") .
1435 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log;h=$hash_base")}, "log") .
1436 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash_base")}, "commit") .
1437 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$hash_base")}, "commitdiff") .
1442 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash_base"), -class => "title"}, esc_html
($co{'title'}) . $ref) . "\n" .
1445 print "<div class=\"page_nav\">\n";
1446 print "<br/><br/></div>\n";
1447 print "<div class=\"title\">$hash</div>\n";
1449 if (defined $file_name) {
1450 $base = esc_html
("$file_name/");
1451 print "<div class=\"page_path\"><b>/" . esc_html
($file_name) . "</b></div>\n";
1453 print "<div class=\"page_path\"><b>/</b></div>\n";
1455 print "<div class=\"page_body\">\n";
1456 print "<table cellspacing=\"0\">\n";
1458 foreach my $line (@entries) {
1459 #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c'
1460 $line =~ m/^([0-9]+) (.+) ([0-9a-fA-F]{40})\t(.+)$/;
1464 my $t_name = validate_input
($4);
1466 print "<tr class=\"dark\">\n";
1468 print "<tr class=\"light\">\n";
1471 print "<td style=\"font-family:monospace\">" . mode_str
($t_mode) . "</td>\n";
1472 if ($t_type eq "blob") {
1473 print "<td class=\"list\">" .
1474 $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)) .
1476 "<td class=\"link\">" .
1477 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;h=$t_hash$base_key;f=$base$t_name")}, "blob") .
1478 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=history;h=$hash_base;f=$base$t_name")}, "history") .
1480 } elsif ($t_type eq "tree") {
1481 print "<td class=\"list\">" .
1482 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;h=$t_hash$base_key;f=$base$t_name")}, esc_html
($t_name)) .
1484 "<td class=\"link\">" .
1485 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;h=$t_hash$base_key;f=$base$t_name")}, "tree") .
1490 print "</table>\n" .
1496 # http://www.notestips.com/80256B3A007F2692/1/NAMO5P9UPQ
1497 open my $fd, "-|", "$gitbin/git-rev-list --max-count=150 " . git_read_hash
("$project/HEAD") or die_error
(undef, "Open failed.");
1498 my (@revlist) = map { chomp; $_ } <$fd>;
1499 close $fd or die_error
(undef, "Reading rev-list failed.");
1500 print $cgi->header(-type
=> 'text/xml', -charset
=> 'utf-8');
1501 print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n".
1502 "<rss version=\"2.0\" xmlns:content=\"http://purl.org/rss/1.0/modules/content/\">\n";
1503 print "<channel>\n";
1504 print "<title>$project</title>\n".
1505 "<link>" . esc_html
("$my_url?p=$project;a=summary") . "</link>\n".
1506 "<description>$project log</description>\n".
1507 "<language>en</language>\n";
1509 for (my $i = 0; $i <= $#revlist; $i++) {
1510 my $commit = $revlist[$i];
1511 my %co = git_read_commit
($commit);
1512 # we read 150, we always show 30 and the ones more recent than 48 hours
1513 if (($i >= 20) && ((time - $co{'committer_epoch'}) > 48*60*60)) {
1516 my %cd = date_str
($co{'committer_epoch'});
1517 open $fd, "-|", "$gitbin/git-diff-tree -r $co{'parent'} $co{'id'}" or next;
1518 my @difftree = map { chomp; $_ } <$fd>;
1522 sprintf("%d %s %02d:%02d", $cd{'mday'}, $cd{'month'}, $cd{'hour'}, $cd{'minute'}) . " - " . esc_html
($co{'title'}) .
1524 "<author>" . esc_html
($co{'author'}) . "</author>\n" .
1525 "<pubDate>$cd{'rfc2822'}</pubDate>\n" .
1526 "<guid isPermaLink=\"true\">" . esc_html
("$my_url?p=$project;a=commit;h=$commit") . "</guid>\n" .
1527 "<link>" . esc_html
("$my_url?p=$project;a=commit;h=$commit") . "</link>\n" .
1528 "<description>" . esc_html
($co{'title'}) . "</description>\n" .
1529 "<content:encoded>" .
1531 my $comment = $co{'comment'};
1532 foreach my $line (@$comment) {
1533 $line = decode
("utf8", $line, Encode
::FB_DEFAULT
);
1534 print "$line<br/>\n";
1537 foreach my $line (@difftree) {
1538 if (!($line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)([0-9]{0,3})\t(.*)$/)) {
1541 my $file = validate_input
(unquote
($7));
1542 $file = decode
("utf8", $file, Encode
::FB_DEFAULT
);
1543 print "$file<br/>\n";
1546 "</content:encoded>\n" .
1549 print "</channel></rss>";
1553 my @list = git_read_projects
();
1555 print $cgi->header(-type
=> 'text/xml', -charset
=> 'utf-8');
1556 print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n".
1557 "<opml version=\"1.0\">\n".
1559 " <title>Git OPML Export</title>\n".
1562 "<outline text=\"git RSS feeds\">\n";
1564 foreach my $pr (@list) {
1566 my $head = git_read_hash
("$proj{'path'}/HEAD");
1567 if (!defined $head) {
1570 $ENV{'GIT_DIR'} = "$projectroot/$proj{'path'}";
1571 my %co = git_read_commit
($head);
1576 my $path = esc_html
(chop_str
($proj{'path'}, 25, 5));
1577 my $rss = "$my_url?p=$proj{'path'};a=rss";
1578 my $html = "$my_url?p=$proj{'path'};a=summary";
1579 print "<outline type=\"rss\" text=\"$path\" title=\"$path\" xmlUrl=\"$rss\" htmlUrl=\"$html\"/>\n";
1581 print "</outline>\n".
1587 my $head = git_read_hash
("$project/HEAD");
1588 if (!defined $hash) {
1591 if (!defined $page) {
1594 my $refs = read_info_ref
();
1596 print "<div class=\"page_nav\">\n";
1597 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary")}, "summary") .
1598 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog;h=$hash")}, "shortlog") .
1600 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash")}, "commit") .
1601 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$hash")}, "commitdiff") .
1602 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;h=$hash;hb=$hash")}, "tree") . "<br/>\n";
1604 my $limit = sprintf("--max-count=%i", (100 * ($page+1)));
1605 open my $fd, "-|", "$gitbin/git-rev-list $limit $hash" or die_error
(undef, "Open failed.");
1606 my (@revlist) = map { chomp; $_ } <$fd>;
1609 if ($hash ne $head || $page) {
1610 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log")}, "HEAD");
1616 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log;h=$hash;pg=" . ($page-1)), -accesskey
=> "p", -title
=> "Alt-p"}, "prev");
1618 print " ⋅ prev";
1620 if ($#revlist >= (100 * ($page+1)-1)) {
1622 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log;h=$hash;pg=" . ($page+1)), -accesskey
=> "n", -title
=> "Alt-n"}, "next");
1624 print " ⋅ next";
1630 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary"), -class => "title"}, " ") .
1632 my %co = git_read_commit
($hash);
1633 print "<div class=\"page_body\"> Last change $co{'age_string'}.<br/><br/></div>\n";
1635 for (my $i = ($page * 100); $i <= $#revlist; $i++) {
1636 my $commit = $revlist[$i];
1638 if (defined $refs->{$commit}) {
1639 $ref = " <span class=\"tag\">" . esc_html
($refs->{$commit}) . "</span>";
1641 my %co = git_read_commit
($commit);
1643 my %ad = date_str
($co{'author_epoch'});
1645 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$commit"), -class => "title"},
1646 "<span class=\"age\">$co{'age_string'}</span>" . esc_html
($co{'title'}) . $ref) . "\n";
1648 print "<div class=\"title_text\">\n" .
1649 "<div class=\"log_link\">\n" .
1650 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$commit")}, "commit") .
1651 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$commit")}, "commitdiff") .
1654 "<i>" . esc_html
($co{'author_name'}) . " [$ad{'rfc2822'}]</i><br/>\n" .
1656 "<div class=\"log_body\">\n";
1657 my $comment = $co{'comment'};
1659 foreach my $line (@$comment) {
1660 if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
1671 print format_log_line_html
($line) . "<br/>\n";
1682 my %co = git_read_commit
($hash);
1684 die_error
(undef, "Unknown commit object.");
1686 my %ad = date_str
($co{'author_epoch'}, $co{'author_tz'});
1687 my %cd = date_str
($co{'committer_epoch'}, $co{'committer_tz'});
1691 my $parent = $co{'parent'};
1692 if (!defined $parent) {
1696 open my $fd, "-|", "$gitbin/git-diff-tree -r -M $root $parent $hash" or die_error
(undef, "Open failed.");
1697 @difftree = map { chomp; $_ } <$fd>;
1698 close $fd or die_error
(undef, "Reading diff-tree failed.");
1700 # non-textual hash id's can be cached
1702 if ($hash =~ m/^[0-9a-fA-F]{40}$/) {
1705 my $refs = read_info_ref
();
1707 if (defined $refs->{$hash}) {
1708 $ref = " <span class=\"tag\">" . esc_html
($refs->{$hash}) . "</span>";
1710 git_header_html
(undef, $expires);
1711 print "<div class=\"page_nav\">\n" .
1712 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary")}, "summary") .
1713 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog;h=$hash")}, "shortlog") .
1714 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log;h=$hash")}, "log") .
1716 if (defined $co{'parent'}) {
1717 print " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$hash")}, "commitdiff");
1719 print " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") . "\n" .
1720 "<br/><br/></div>\n";
1721 if (defined $co{'parent'}) {
1723 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$hash"), -class => "title"}, esc_html
($co{'title'}) . $ref) . "\n" .
1727 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;h=$co{'tree'};hb=$hash"), -class => "title"}, esc_html
($co{'title'})) . "\n" .
1730 print "<div class=\"title_text\">\n" .
1731 "<table cellspacing=\"0\">\n";
1732 print "<tr><td>author</td><td>" . esc_html
($co{'author'}) . "</td></tr>\n".
1734 "<td></td><td> $ad{'rfc2822'}";
1735 if ($ad{'hour_local'} < 6) {
1736 printf(" (<span style=\"color: #cc0000;\">%02d:%02d</span> %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
1738 printf(" (%02d:%02d %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
1742 print "<tr><td>committer</td><td>" . esc_html
($co{'committer'}) . "</td></tr>\n";
1743 print "<tr><td></td><td> $cd{'rfc2822'}" . sprintf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}) . "</td></tr>\n";
1744 print "<tr><td>commit</td><td style=\"font-family:monospace\">$co{'id'}</td></tr>\n";
1747 "<td style=\"font-family:monospace\">" .
1748 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;h=$co{'tree'};hb=$hash"), class => "list"}, $co{'tree'}) .
1750 "<td class=\"link\">" . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") .
1753 my $parents = $co{'parents'};
1754 foreach my $par (@$parents) {
1757 "<td style=\"font-family:monospace\">" . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$par"), class => "list"}, $par) . "</td>" .
1758 "<td class=\"link\">" .
1759 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$par")}, "commit") .
1760 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$hash;hp=$par")}, "commitdiff") .
1766 print "<div class=\"page_body\">\n";
1767 my $comment = $co{'comment'};
1770 foreach my $line (@$comment) {
1771 # print only one empty line
1773 if ($empty || $signed) {
1780 if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
1782 print "<span style=\"color: #888888\">" . esc_html
($line) . "</span><br/>\n";
1785 print format_log_line_html
($line) . "<br/>\n";
1789 print "<div class=\"list_head\">\n";
1790 if ($#difftree > 10) {
1791 print(($#difftree + 1) . " files changed:\n");
1794 print "<table cellspacing=\"0\">\n";
1796 foreach my $line (@difftree) {
1797 # ':100644 100644 03b218260e99b78c6df0ed378e59ed9205ccc96d 3b93d5e7cc7f7dd4ebed13a5cc1a4ad976fc94d8 M ls-files.c'
1798 # ':100644 100644 7f9281985086971d3877aca27704f2aaf9c448ce bc190ebc71bbd923f2b728e505408f5e54bd073a M rev-tree.c'
1799 if (!($line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)([0-9]{0,3})\t(.*)$/)) {
1807 my $similarity = $6;
1808 my $file = validate_input
(unquote
($7));
1810 print "<tr class=\"dark\">\n";
1812 print "<tr class=\"light\">\n";
1815 if ($status eq "A") {
1817 if (S_ISREG
(oct $to_mode)) {
1818 $mode_chng = sprintf(" with mode: %04o", (oct $to_mode) & 0777);
1821 $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" .
1822 "<td><span style=\"color: #008000;\">[new " . file_type
($to_mode) . "$mode_chng]</span></td>\n" .
1823 "<td class=\"link\">" . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, "blob") . "</td>\n";
1824 } elsif ($status eq "D") {
1826 $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" .
1827 "<td><span style=\"color: #c00000;\">[deleted " . file_type
($from_mode). "]</span></td>\n" .
1828 "<td class=\"link\">" .
1829 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;h=$from_id;hb=$hash;f=$file")}, "blob") .
1830 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=history;h=$hash;f=$file")}, "history") .
1832 } elsif ($status eq "M" || $status eq "T") {
1833 my $mode_chnge = "";
1834 if ($from_mode != $to_mode) {
1835 $mode_chnge = " <span style=\"color: #777777;\">[changed";
1836 if (((oct $from_mode) & S_IFMT
) != ((oct $to_mode) & S_IFMT
)) {
1837 $mode_chnge .= " from " . file_type
($from_mode) . " to " . file_type
($to_mode);
1839 if (((oct $from_mode) & 0777) != ((oct $to_mode) & 0777)) {
1840 if (S_ISREG
($from_mode) && S_ISREG
($to_mode)) {
1841 $mode_chnge .= sprintf(" mode: %04o->%04o", (oct $from_mode) & 0777, (oct $to_mode) & 0777);
1842 } elsif (S_ISREG
($to_mode)) {
1843 $mode_chnge .= sprintf(" mode: %04o", (oct $to_mode) & 0777);
1846 $mode_chnge .= "]</span>\n";
1849 if ($to_id ne $from_id) {
1850 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));
1852 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;h=$to_id;hb=$hash;f=$file"), -class => "list"}, esc_html
($file));
1855 "<td>$mode_chnge</td>\n" .
1856 "<td class=\"link\">";
1857 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, "blob");
1858 if ($to_id ne $from_id) {
1859 print " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file")}, "diff");
1861 print " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=history;h=$hash;f=$file")}, "history") . "\n";
1863 } elsif ($status eq "R") {
1864 my ($from_file, $to_file) = split "\t", $file;
1866 if ($from_mode != $to_mode) {
1867 $mode_chng = sprintf(", mode: %04o", (oct $to_mode) & 0777);
1870 $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" .
1871 "<td><span style=\"color: #777777;\">[moved from " .
1872 $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)) .
1873 " with " . (int $similarity) . "% similarity$mode_chng]</span></td>\n" .
1874 "<td class=\"link\">" .
1875 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;h=$to_id;hb=$hash;f=$to_file")}, "blob");
1876 if ($to_id ne $from_id) {
1877 print " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$to_file")}, "diff");
1888 mkdir($git_temp, 0700);
1890 if (defined $hash_base && (my %co = git_read_commit
($hash_base))) {
1891 print "<div class=\"page_nav\">\n" .
1892 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary")}, "summary") .
1893 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog")}, "shortlog") .
1894 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log")}, "log") .
1895 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash_base")}, "commit") .
1896 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$hash_base")}, "commitdiff") .
1897 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;h=$co{'tree'};hb=$hash_base")}, "tree") .
1899 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blobdiff_plain;h=$hash;hp=$hash_parent")}, "plain") .
1902 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash_base"), -class => "title"}, esc_html
($co{'title'})) . "\n" .
1905 print "<div class=\"page_nav\">\n" .
1906 "<br/><br/></div>\n" .
1907 "<div class=\"title\">$hash vs $hash_parent</div>\n";
1909 if (defined $file_name) {
1910 print "<div class=\"page_path\"><b>/" . esc_html
($file_name) . "</b></div>\n";
1912 print "<div class=\"page_body\">\n" .
1913 "<div class=\"diff_info\">blob:" .
1914 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;h=$hash_parent;hb=$hash_base;f=$file_name")}, $hash_parent) .
1916 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;h=$hash;hb=$hash_base;f=$file_name")}, $hash) .
1918 git_diff_print
($hash_parent, $file_name || $hash_parent, $hash, $file_name || $hash);
1923 sub git_blobdiff_plain
{
1924 mkdir($git_temp, 0700);
1925 print $cgi->header(-type
=> "text/plain", -charset
=> 'utf-8');
1926 git_diff_print
($hash_parent, $file_name || $hash_parent, $hash, $file_name || $hash, "plain");
1929 sub git_commitdiff
{
1930 mkdir($git_temp, 0700);
1931 my %co = git_read_commit
($hash);
1933 die_error
(undef, "Unknown commit object.");
1935 if (!defined $hash_parent) {
1936 $hash_parent = $co{'parent'};
1938 open my $fd, "-|", "$gitbin/git-diff-tree -r $hash_parent $hash" or die_error
(undef, "Open failed.");
1939 my (@difftree) = map { chomp; $_ } <$fd>;
1940 close $fd or die_error
(undef, "Reading diff-tree failed.");
1942 # non-textual hash id's can be cached
1944 if ($hash =~ m/^[0-9a-fA-F]{40}$/) {
1947 my $refs = read_info_ref
();
1949 if (defined $refs->{$hash}) {
1950 $ref = " <span class=\"tag\">" . esc_html
($refs->{$hash}) . "</span>";
1952 git_header_html
(undef, $expires);
1953 print "<div class=\"page_nav\">\n" .
1954 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary")}, "summary") .
1955 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog;h=$hash")}, "shortlog") .
1956 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log;h=$hash")}, "log") .
1957 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash")}, "commit") .
1959 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") . "<br/>\n";
1960 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff_plain;h=$hash;hp=$hash_parent")}, "plain") . "\n" .
1963 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash"), -class => "title"}, esc_html
($co{'title'}) . $ref) . "\n" .
1965 print "<div class=\"page_body\">\n";
1966 my $comment = $co{'comment'};
1969 my @log = @$comment;
1970 # remove first and empty lines after that
1972 while (defined $log[0] && $log[0] eq "") {
1975 foreach my $line (@log) {
1976 if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
1987 print format_log_line_html
($line) . "<br/>\n";
1990 foreach my $line (@difftree) {
1991 # ':100644 100644 03b218260e99b78c6df0ed378e59ed9205ccc96d 3b93d5e7cc7f7dd4ebed13a5cc1a4ad976fc94d8 M ls-files.c'
1992 # ':100644 100644 7f9281985086971d3877aca27704f2aaf9c448ce bc190ebc71bbd923f2b728e505408f5e54bd073a M rev-tree.c'
1993 $line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$/;
1999 my $file = validate_input
(unquote
($6));
2000 if ($status eq "A") {
2001 print "<div class=\"diff_info\">" . file_type
($to_mode) . ":" .
2002 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, $to_id) . "(new)" .
2004 git_diff_print
(undef, "/dev/null", $to_id, "b/$file");
2005 } elsif ($status eq "D") {
2006 print "<div class=\"diff_info\">" . file_type
($from_mode) . ":" .
2007 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;h=$from_id;hb=$hash;f=$file")}, $from_id) . "(deleted)" .
2009 git_diff_print
($from_id, "a/$file", undef, "/dev/null");
2010 } elsif ($status eq "M") {
2011 if ($from_id ne $to_id) {
2012 print "<div class=\"diff_info\">" .
2013 file_type
($from_mode) . ":" . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;h=$from_id;hb=$hash;f=$file")}, $from_id) .
2015 file_type
($to_mode) . ":" . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, $to_id);
2017 git_diff_print
($from_id, "a/$file", $to_id, "b/$file");
2026 sub git_commitdiff_plain
{
2027 mkdir($git_temp, 0700);
2028 open my $fd, "-|", "$gitbin/git-diff-tree -r $hash_parent $hash" or die_error
(undef, "Open failed.");
2029 my (@difftree) = map { chomp; $_ } <$fd>;
2030 close $fd or die_error
(undef, "Reading diff-tree failed.");
2032 # try to figure out the next tag after this commit
2034 my $refs = read_info_ref
("tags");
2035 open $fd, "-|", "$gitbin/git-rev-list HEAD";
2036 chomp (my (@commits) = <$fd>);
2038 foreach my $commit (@commits) {
2039 if (defined $refs->{$commit}) {
2040 $tagname = $refs->{$commit}
2042 if ($commit eq $hash) {
2047 print $cgi->header(-type
=> "text/plain", -charset
=> 'utf-8', '-content-disposition' => "inline; filename=\"git-$hash.patch\"");
2048 my %co = git_read_commit
($hash);
2049 my %ad = date_str
($co{'author_epoch'}, $co{'author_tz'});
2050 my $comment = $co{'comment'};
2051 print "From: $co{'author'}\n" .
2052 "Date: $ad{'rfc2822'} ($ad{'tz_local'})\n".
2053 "Subject: $co{'title'}\n";
2054 if (defined $tagname) {
2055 print "X-Git-Tag: $tagname\n";
2057 print "X-Git-Url: $my_url?p=$project;a=commitdiff;h=$hash\n" .
2060 foreach my $line (@$comment) {;
2065 foreach my $line (@difftree) {
2066 $line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$/;
2071 if ($status eq "A") {
2072 git_diff_print
(undef, "/dev/null", $to_id, "b/$file", "plain");
2073 } elsif ($status eq "D") {
2074 git_diff_print
($from_id, "a/$file", undef, "/dev/null", "plain");
2075 } elsif ($status eq "M") {
2076 git_diff_print
($from_id, "a/$file", $to_id, "b/$file", "plain");
2082 if (!defined $hash) {
2083 $hash = git_read_hash
("$project/HEAD");
2085 my %co = git_read_commit
($hash);
2087 die_error
(undef, "Unknown commit object.");
2089 my $refs = read_info_ref
();
2091 print "<div class=\"page_nav\">\n" .
2092 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary")}, "summary") .
2093 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog")}, "shortlog") .
2094 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log")}, "log") .
2095 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash")}, "commit") .
2096 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$hash")}, "commitdiff") .
2097 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") .
2101 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash"), -class => "title"}, esc_html
($co{'title'})) . "\n" .
2103 print "<div class=\"page_path\"><b>/" . esc_html
($file_name) . "</b><br/></div>\n";
2105 open my $fd, "-|", "$gitbin/git-rev-list $hash | $gitbin/git-diff-tree -r --stdin \'$file_name\'";
2107 print "<table cellspacing=\"0\">\n";
2109 while (my $line = <$fd>) {
2110 if ($line =~ m/^([0-9a-fA-F]{40})/){
2114 if ($line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$/ && (defined $commit)) {
2115 my %co = git_read_commit
($commit);
2120 if (defined $refs->{$commit}) {
2121 $ref = " <span class=\"tag\">" . esc_html
($refs->{$commit}) . "</span>";
2124 print "<tr class=\"dark\">\n";
2126 print "<tr class=\"light\">\n";
2129 print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
2130 "<td><i>" . esc_html
(chop_str
($co{'author_name'}, 15, 3)) . "</i></td>\n" .
2131 "<td>" . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$commit"), -class => "list"}, "<b>" .
2132 esc_html
(chop_str
($co{'title'}, 50)) . "$ref</b>") . "</td>\n" .
2133 "<td class=\"link\">" .
2134 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$commit")}, "commit") .
2135 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$commit")}, "commitdiff") .
2136 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;hb=$commit;f=$file_name")}, "blob");
2137 my $blob = git_get_hash_by_path
($hash, $file_name);
2138 my $blob_parent = git_get_hash_by_path
($commit, $file_name);
2139 if (defined $blob && defined $blob_parent && $blob ne $blob_parent) {
2141 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blobdiff;h=$blob;hp=$blob_parent;hb=$commit;f=$file_name")},
2155 if (!defined $searchtext) {
2156 die_error
("", "Text field empty.");
2158 if (!defined $hash) {
2159 $hash = git_read_hash
("$project/HEAD");
2161 my %co = git_read_commit
($hash);
2163 die_error
(undef, "Unknown commit object.");
2165 # pickaxe may take all resources of your box and run for several minutes
2166 # with every query - so decide by yourself how public you make this feature :)
2167 my $commit_search = 1;
2168 my $author_search = 0;
2169 my $committer_search = 0;
2170 my $pickaxe_search = 0;
2171 if ($searchtext =~ s/^author\\://i) {
2173 } elsif ($searchtext =~ s/^committer\\://i) {
2174 $committer_search = 1;
2175 } elsif ($searchtext =~ s/^pickaxe\\://i) {
2177 $pickaxe_search = 1;
2180 print "<div class=\"page_nav\">\n" .
2181 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary;h=$hash")}, "summary") .
2182 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog")}, "shortlog") .
2183 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log;h=$hash")}, "log") .
2184 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash")}, "commit") .
2185 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$hash")}, "commitdiff") .
2186 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") .
2191 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$hash"), -class => "title"}, esc_html
($co{'title'})) . "\n" .
2193 print "<table cellspacing=\"0\">\n";
2195 if ($commit_search) {
2197 open my $fd, "-|", "$gitbin/git-rev-list --header --parents $hash" or next;
2198 while (my $commit_text = <$fd>) {
2199 if (!grep m/$searchtext/i, $commit_text) {
2202 if ($author_search && !grep m/\nauthor .*$searchtext/i, $commit_text) {
2205 if ($committer_search && !grep m/\ncommitter .*$searchtext/i, $commit_text) {
2208 my @commit_lines = split "\n", $commit_text;
2209 my %co = git_read_commit
(undef, \
@commit_lines);
2214 print "<tr class=\"dark\">\n";
2216 print "<tr class=\"light\">\n";
2219 print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
2220 "<td><i>" . esc_html
(chop_str
($co{'author_name'}, 15, 5)) . "</i></td>\n" .
2222 $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/>");
2223 my $comment = $co{'comment'};
2224 foreach my $line (@$comment) {
2225 if ($line =~ m/^(.*)($searchtext)(.*)$/i) {
2226 my $lead = esc_html
($1) || "";
2227 $lead = chop_str
($lead, 30, 10);
2228 my $match = esc_html
($2) || "";
2229 my $trail = esc_html
($3) || "";
2230 $trail = chop_str
($trail, 30, 10);
2231 my $text = "$lead<span style=\"color:#e00000\">$match</span>$trail";
2232 print chop_str
($text, 80, 5) . "<br/>\n";
2236 "<td class=\"link\">" .
2237 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$co{'id'}")}, "commit") .
2238 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;h=$co{'tree'};hb=$co{'id'}")}, "tree");
2245 if ($pickaxe_search) {
2247 open my $fd, "-|", "$gitbin/git-rev-list $hash | $gitbin/git-diff-tree -r --stdin -S\'$searchtext\'";
2250 while (my $line = <$fd>) {
2251 if (%co && $line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$/) {
2254 $set{'from_id'} = $3;
2256 $set{'id'} = $set{'to_id'};
2257 if ($set{'id'} =~ m/0{40}/) {
2258 $set{'id'} = $set{'from_id'};
2260 if ($set{'id'} =~ m/0{40}/) {
2264 } elsif ($line =~ m/^([0-9a-fA-F]{40})$/){
2267 print "<tr class=\"dark\">\n";
2269 print "<tr class=\"light\">\n";
2272 print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
2273 "<td><i>" . esc_html
(chop_str
($co{'author_name'}, 15, 5)) . "</i></td>\n" .
2275 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$co{'id'}"), -class => "list"}, "<b>" .
2276 esc_html
(chop_str
($co{'title'}, 50)) . "</b><br/>");
2277 while (my $setref = shift @files) {
2279 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=blob;h=$set{'id'};hb=$co{'id'};f=$set{'file'}"), class => "list"},
2280 "<span style=\"color:#e00000\">" . esc_html
($set{'file'}) . "</span>") .
2284 "<td class=\"link\">" .
2285 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$co{'id'}")}, "commit") .
2286 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=tree;h=$co{'tree'};hb=$co{'id'}")}, "tree");
2290 %co = git_read_commit
($1);
2300 my $head = git_read_hash
("$project/HEAD");
2301 if (!defined $hash) {
2304 if (!defined $page) {
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") .
2312 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=log;h=$hash")}, "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=$hash;hb=$hash")}, "tree") . "<br/>\n";
2317 my $limit = sprintf("--max-count=%i", (100 * ($page+1)));
2318 open my $fd, "-|", "$gitbin/git-rev-list $limit $hash" or die_error
(undef, "Open failed.");
2319 my (@revlist) = map { chomp; $_ } <$fd>;
2322 if ($hash ne $head || $page) {
2323 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog")}, "HEAD");
2329 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog;h=$hash;pg=" . ($page-1)), -accesskey
=> "p", -title
=> "Alt-p"}, "prev");
2331 print " ⋅ prev";
2333 if ($#revlist >= (100 * ($page+1)-1)) {
2335 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog;h=$hash;pg=" . ($page+1)), -accesskey
=> "n", -title
=> "Alt-n"}, "next");
2337 print " ⋅ next";
2342 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=summary"), -class => "title"}, " ") .
2344 print "<table cellspacing=\"0\">\n";
2346 for (my $i = ($page * 100); $i <= $#revlist; $i++) {
2347 my $commit = $revlist[$i];
2349 if (defined $refs->{$commit}) {
2350 $ref = " <span class=\"tag\">" . esc_html
($refs->{$commit}) . "</span>";
2352 my %co = git_read_commit
($commit);
2353 my %ad = date_str
($co{'author_epoch'});
2355 print "<tr class=\"dark\">\n";
2357 print "<tr class=\"light\">\n";
2360 print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
2361 "<td><i>" . esc_html
(chop_str
($co{'author_name'}, 10)) . "</i></td>\n" .
2363 if (length($co{'title_short'}) < length($co{'title'})) {
2364 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$commit"), -class => "list", -title
=> "$co{'title'}"},
2365 "<b>" . esc_html
($co{'title_short'}) . "$ref</b>");
2367 print $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$commit"), -class => "list"},
2368 "<b>" . esc_html
($co{'title_short'}) . "$ref</b>");
2371 "<td class=\"link\">" .
2372 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commit;h=$commit")}, "commit") .
2373 " | " . $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=commitdiff;h=$commit")}, "commitdiff") .
2377 if ($#revlist >= (100 * ($page+1)-1)) {
2380 $cgi->a({-href
=> "$my_uri?" . esc_param
("p=$project;a=shortlog;h=$hash;pg=" . ($page+1)), -title
=> "Alt-n"}, "next") .
This page took 3.379517 seconds and 3 git commands to generate.