]>
Lady’s Gitweb - Gitweb/blob - gitweb.cgi
3 # gitweb.pl - simple web interface to track changes in git repositories
5 # (C) 2005, Kay Sievers <kay.sievers@vrfy.org>
6 # (C) 2005, Christian Gierke <ch@gierke.de>
8 # This program is licensed under the GPL v2, or a later version
12 use CGI
qw(:standard :escapeHTML);
13 use CGI
::Util
qw(unescape);
14 use CGI
::Carp
qw(fatalsToBrowser);
19 my $my_url = $cgi->url();
20 my $my_uri = $cgi->url(-absolute
=> 1);
23 # absolute fs-path which will be prepended to the project path
24 my $projectroot = "/pub/scm";
26 # location of the git-core binaries
27 my $gitbin = "/usr/bin";
29 # location for temporary files needed for diffs
30 my $gittmp = "/tmp/gitweb";
32 # target of the home link on top of all pages
33 my $home_link = $my_uri;
35 # html text to include at home page
36 my $home_text = "indextext.html";
38 # source of projects list
39 #my $projects_list = $projectroot;
40 my $projects_list = "index/index.aux";
42 # input validation and dispatch
43 my $action = $cgi->param('a');
44 if (defined $action) {
45 if ($action =~ m/[^0-9a-zA-Z\.\-]+/) {
47 die_error
(undef, "Invalid action parameter.");
49 if ($action eq "git-logo.png") {
57 my $project = $cgi->param('p');
58 if (defined $project) {
59 if ($project =~ m/(^|\/)(|\
.|\
.\
.)($|\
/)/) {
61 die_error
(undef, "Non-canonical project parameter.");
63 if ($project =~ m/[^a-zA-Z0-9_\.\/\
-\
+\#\
~]/) {
65 die_error
(undef, "Invalid character in project parameter.");
67 if (!(-d
"$projectroot/$project")) {
69 die_error
(undef, "No such directory.");
71 if (!(-e
"$projectroot/$project/HEAD")) {
73 die_error
(undef, "No such project.");
75 $rss_link = "<link rel=\"alternate\" title=\"$project log\" href=\"$my_uri?p=$project;a=rss\" type=\"application/rss+xml\"/>";
76 $ENV{'GIT_OBJECT_DIRECTORY'} = "$projectroot/$project/objects";
77 $ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$project/objects";
83 my $file_name = $cgi->param('f');
84 if (defined $file_name) {
85 if ($file_name =~ m/(^|\/)(|\
.|\
.\
.)($|\
/)/) {
87 die_error
(undef, "Non-canonical file parameter.");
89 if ($file_name =~ m/[^a-zA-Z0-9_\.\/\
-\
+\#\
~\
:\
!]/) {
91 die_error
(undef, "Invalid character in file parameter.");
95 my $hash = $cgi->param('h');
96 if (defined $hash && !($hash =~ m/^[0-9a-fA-F]{40}$/)) {
98 die_error
(undef, "Invalid hash parameter.");
101 my $hash_parent = $cgi->param('hp');
102 if (defined $hash_parent && !($hash_parent =~ m/^[0-9a-fA-F]{40}$/)) {
104 die_error
(undef, "Invalid hash_parent parameter.");
107 my $hash_base = $cgi->param('hb');
108 if (defined $hash_base && !($hash_base =~ m/^[0-9a-fA-F]{40}$/)) {
110 die_error
(undef, "Invalid parent hash parameter.");
113 my $time_back = $cgi->param('t');
114 if (defined $time_back) {
115 if ($time_back =~ m/^[^0-9]+$/) {
117 die_error
(undef, "Invalid time parameter.");
121 if ($action eq "summary") {
124 } elsif ($action eq "branches") {
127 } elsif ($action eq "tags") {
130 } elsif ($action eq "blob") {
133 } elsif ($action eq "tree") {
136 } elsif ($action eq "rss") {
139 } elsif ($action eq "commit") {
142 } elsif ($action eq "log") {
145 } elsif ($action eq "blobdiff") {
148 } elsif ($action eq "commitdiff") {
151 } elsif ($action eq "history") {
156 die_error
(undef, "Unknown action.");
160 sub git_header_html
{
161 my $status = shift || "200 OK";
164 if (defined $project) {
165 $title .= " - $project";
166 if (defined $action) {
167 $title .= "/$action";
170 print $cgi->header(-type
=>'text/html', -charset
=> 'utf-8', -status
=> $status);
172 <?xml version="1.0" encoding="utf-8"?>
173 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
174 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
175 <!-- git web interface v$version, (C) 2005, Kay Sievers <kay.sievers\@vrfy.org>, Christian Gierke <ch\@gierke.de> -->
177 <title>$title</title>
179 <style type="text/css">
180 body { font-family: sans-serif; font-size: 12px; margin:0px; border:solid #d9d8d1; border-width:1px; margin:10px; }
182 a:hover, a:visited, a:active { color:#880000; }
183 div.page_header { height:25px; padding:8px; font-size:18px; font-weight:bold; background-color:#d9d8d1; }
184 div.page_header a:visited { color:#0000cc; }
185 div.page_header a:hover { color:#880000; }
186 div.page_nav { padding:8px; }
187 div.page_nav a:visited { color:#0000cc; }
188 div.page_path { font-weight:bold; padding:8px; border:solid #d9d8d1; border-width:0px 0px 1px}
189 div.page_footer { height:17px; padding:4px 8px; background-color: #d9d8d1; }
190 div.page_footer_text { float:left; color:#555555; font-style:italic; }
191 div.page_body { padding:8px; }
193 display:block; padding:6px 8px;
194 font-weight:bold; background-color:#edece6; text-decoration:none; color:#000000;
196 a.title:hover { background-color: #d9d8d1; }
197 div.title_text { padding:6px 0px; border: solid #d9d8d1; border-width:0px 0px 1px; }
198 div.log_body { padding:8px 8px 8px 150px; }
199 span.age { position:relative; float:left; width:142px; font-style:italic; }
202 font-size:10px; font-family:sans-serif; font-style:normal;
203 position:relative; float:left; width:136px;
205 div.list_head { padding:6px 8px 4px; border:solid #d9d8d1; border-width:1px 0px 0px; font-style:italic; }
206 a.list { text-decoration:none; color:#000000; }
207 a.list:hover { color:#880000; }
208 table { padding:8px 4px; }
209 th { padding:2px 5px; font-size:12px; text-align:left; }
210 td { padding:2px 5px; font-size:12px; }
211 td.link { padding:2px 5px; font-family:sans-serif; font-size:10px; }
212 div.pre { font-family:monospace; font-size:12px; white-space:pre; }
213 div.diff_info { font-family:monospace; color:#000099; background-color:#edece6; font-style:italic; }
214 div.index_include { border:solid #d9d8d1; border-width:0px 0px 1px; padding:12px 8px; }
215 a.rss_logo { float:right; padding:3px 0px; width:35px; line-height:10px;
216 border:1px solid; border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e;
217 color:#ffffff; background-color:#ff6600;
218 font-weight:bold; font-family:sans-serif; font-size:10px;
219 text-align:center; text-decoration:none;
221 a.rss_logo:hover { background-color:#ee5500; }
226 print "<div class=\"page_header\">\n" .
227 "<a href=\"http://kernel.org/pub/software/scm/git/docs/\">" .
228 "<img src=\"$my_uri?a=git-logo.png\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/></a>";
229 print $cgi->a({-href
=> $home_link}, "projects") . " / ";
230 if (defined $project) {
231 print $cgi->a({-href
=> "$my_uri?p=$project;a=summary"}, escapeHTML
($project));
232 if (defined $action) {
239 sub git_footer_html
{
240 print "<div class=\"page_footer\">\n";
241 if (defined $project) {
242 my $descr = git_read_description
($project);
243 if (defined $descr) {
244 print "<div class=\"page_footer_text\">" . escapeHTML
($descr) . "</div>\n";
246 print $cgi->a({-href
=> "$my_uri?p=$project;a=rss", -class => "rss_logo"}, "RSS") . "\n";
254 my $status = shift || "403 Forbidden";
255 my $error = shift || "Malformed query, file missing or permission denied";
257 git_header_html
($status);
258 print "<div class=\"page_body\">\n" .
260 print "$status - $error\n";
261 print "<br/></div>\n";
269 open my $fd, "-|", "$gitbin/git-cat-file -t $hash" || return;
279 open my $fd, "$projectroot/$path" || return undef;
283 if ($head =~ m/^[0-9a-fA-F]{40}$/) {
288 sub git_read_description
{
291 open my $fd, "$projectroot/$path/description" || return undef;
302 open my $fd, "-|", "$gitbin/git-cat-file tag $tag_id" || return;
303 while (my $line = <$fd>) {
305 if ($line =~ m/^object ([0-9a-fA-F]{40})$/) {
307 } elsif ($line =~ m/^type (.*)$/) {
309 } elsif ($line =~ m/^tag (.*)$/) {
314 if (!defined $tag{'name'}) {
320 sub git_read_commit
{
325 open my $fd, "-|", "$gitbin/git-cat-file commit $commit" || return;
326 while (my $line = <$fd>) {
327 last if $line eq "\n";
329 if ($line =~ m/^tree (.*)$/) {
331 } elsif ($line =~ m/^parent (.*)$/) {
333 } elsif ($line =~ m/^author (.*) ([0-9]+) (.*)$/) {
335 $co{'author_epoch'} = $2;
336 $co{'author_tz'} = $3;
337 $co{'author_name'} = $co{'author'};
338 $co{'author_name'} =~ s/ <.*//;
339 } elsif ($line =~ m/^committer (.*) ([0-9]+) (.*)$/) {
340 $co{'committer'} = $1;
341 $co{'committer_epoch'} = $2;
342 $co{'committer_tz'} = $3;
343 $co{'committer_name'} = $co{'committer'};
344 $co{'committer_name'} =~ s/ <.*//;
347 if (!defined $co{'tree'}) {
351 $co{'parents'} = \
@parents;
352 $co{'parent'} = $parents[0];
353 my (@comment) = map { chomp; $_ } <$fd>;
354 $co{'comment'} = \
@comment;
355 $comment[0] =~ m/^(.{0,50}[^ \/\
-_
:\
.]{0,10})/;
357 if ($comment[0] ne $co{'title'}) {
358 $co{'title'} .= " ...";
362 my $age = time - $co{'committer_epoch'};
364 if ($age > 60*60*24*365*2) {
365 $co{'age_string'} = (int $age/60/60/24/365);
366 $co{'age_string'} .= " years ago";
367 } elsif ($age > 60*60*24*(365/12)*2) {
368 $co{'age_string'} = int $age/60/60/24/(365/12);
369 $co{'age_string'} .= " months ago";
370 } elsif ($age > 60*60*24*7*2) {
371 $co{'age_string'} = int $age/60/60/24/7;
372 $co{'age_string'} .= " weeks ago";
373 } elsif ($age > 60*60*24*2) {
374 $co{'age_string'} = int $age/60/60/24;
375 $co{'age_string'} .= " days ago";
376 } elsif ($age > 60*60*2) {
377 $co{'age_string'} = int $age/60/60;
378 $co{'age_string'} .= " hours ago";
379 } elsif ($age > 60*2) {
380 $co{'age_string'} = int $age/60;
381 $co{'age_string'} .= " min ago";
383 $co{'age_string'} = int $age;
384 $co{'age_string'} .= " sec ago";
386 $co{'age_string'} .= " right now";
393 my $from_name = shift;
397 my $from_tmp = "/dev/null";
398 my $to_tmp = "/dev/null";
401 # create tmp from-file
403 $from_tmp = "$gittmp/gitweb_" . $$ . "_from";
404 open my $fd2, "> $from_tmp";
405 open my $fd, "-|", "$gitbin/git-cat-file blob $from";
414 $to_tmp = "$gittmp/gitweb_" . $$ . "_to";
415 open my $fd2, "> $to_tmp";
416 open my $fd, "-|", "$gitbin/git-cat-file blob $to";
423 open my $fd, "-|", "/usr/bin/diff -u -p -L $from_name -L $to_name $from_tmp $to_tmp";
424 while (my $line = <$fd>) {
426 my $char = substr($line, 0, 1);
429 $color = " style=\"color:#008800;\"";
430 } elsif ($char eq '-') {
431 $color = " style=\"color:#cc0000;\"";
432 } elsif ($char eq '@') {
433 $color = " style=\"color:#990099;\"";
434 } elsif ($char eq '\\') {
438 print "<div class=\"pre\"$color>" . escapeHTML
($line) . "</div>\n";
451 my $mode = oct shift;
453 if (S_ISDIR
($mode & S_IFMT
)) {
455 } elsif (S_ISLNK
($mode)) {
457 } elsif (S_ISREG
($mode)) {
458 # git cares only about the executable bit
459 if ($mode & S_IXUSR
) {
470 my $mode = oct shift;
472 if (S_ISDIR
($mode & S_IFMT
)) {
474 } elsif (S_ISLNK
($mode)) {
476 } elsif (S_ISREG
($mode)) {
485 my $tz = shift || "-0000";
488 my @months = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
489 my @days = ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
490 my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($epoch);
491 $date{'hour'} = $hour;
492 $date{'minute'} = $min;
493 $date{'mday'} = $mday;
494 $date{'day'} = $days[$wday];
495 $date{'month'} = $months[$mon];
496 $date{'rfc2822'} = sprintf "%s, %d %s %4d %02d:%02d:%02d +0000", $days[$wday], $mday, $months[$mon], 1900+$year, $hour ,$min, $sec;
497 $date{'mday-time'} = sprintf "%d %s %02d:%02d", $mday, $months[$mon], $hour ,$min;
499 $tz =~ m/^([+\-][0-9][0-9])([0-9][0-9])$/;
500 my $local = $epoch + ((int $1 + ($2/60)) * 3600);
501 ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($local);
502 $date{'hour_local'} = $hour;
503 $date{'minute_local'} = $min;
504 $date{'tz_local'} = $tz;
508 # git-logo (cached in browser for one day)
510 print $cgi->header(-type
=> 'image/png', -expires
=> '+1d');
511 # cat git-logo.png | hexdump -e '16/1 " %02x" "\n"' | sed 's/ /\\x/g'
512 print "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52" .
513 "\x00\x00\x00\x48\x00\x00\x00\x1b\x04\x03\x00\x00\x00\x2d\xd9\xd4" .
514 "\x2d\x00\x00\x00\x18\x50\x4c\x54\x45\xff\xff\xff\x60\x60\x5d\xb0" .
515 "\xaf\xaa\x00\x80\x00\xce\xcd\xc7\xc0\x00\x00\xe8\xe8\xe6\xf7\xf7" .
516 "\xf6\x95\x0c\xa7\x47\x00\x00\x00\x73\x49\x44\x41\x54\x28\xcf\x63" .
517 "\x48\x67\x20\x04\x4a\x5c\x18\x0a\x08\x2a\x62\x53\x61\x20\x02\x08" .
518 "\x0d\x69\x45\xac\xa1\xa1\x01\x30\x0c\x93\x60\x36\x26\x52\x91\xb1" .
519 "\x01\x11\xd6\xe1\x55\x64\x6c\x6c\xcc\x6c\x6c\x0c\xa2\x0c\x70\x2a" .
520 "\x62\x06\x2a\xc1\x62\x1d\xb3\x01\x02\x53\xa4\x08\xe8\x00\x03\x18" .
521 "\x26\x56\x11\xd4\xe1\x20\x97\x1b\xe0\xb4\x0e\x35\x24\x71\x29\x82" .
522 "\x99\x30\xb8\x93\x0a\x11\xb9\x45\x88\xc1\x8d\xa0\xa2\x44\x21\x06" .
523 "\x27\x41\x82\x40\x85\xc1\x45\x89\x20\x70\x01\x00\xa4\x3d\x21\xc5" .
524 "\x12\x1c\x9a\xfe\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82";
530 my ($dev, $ino, $mode, $nlink, $st_uid, $st_gid, $rdev, $size) = stat($path);
531 my ($name, $passwd, $uid, $gid, $quota, $comment, $gcos, $dir, $shell) = getpwuid($st_uid);
532 if (!defined $gcos) {
536 $owner =~ s/[,;].*$//;
540 sub git_project_list
{
543 if (-d
$projects_list) {
544 # search in directory
545 my $dir = $projects_list;
546 opendir my $dh, $dir || return undef;
547 while (my $dir = readdir($dh)) {
548 if (-e
"$projectroot/$dir/HEAD") {
556 } elsif (-f
$projects_list) {
558 # 'git/git.git:Linus Torvalds'
559 # 'linux/hotplug/udev.git'
560 open my $fd , $projects_list || return undef;
561 while (my $line = <$fd>) {
563 my ($path, $owner) = split ' ', $line;
564 $path = unescape
($path);
565 $owner = unescape
($owner);
566 if (!defined $path) {
569 if (-e
"$projectroot/$path/HEAD") {
581 die_error
(undef, "No project found.");
583 @list = sort {$a->{'path'} cmp $b->{'path'}} @list;
587 print "<div class=\"index_include\">\n";
588 open (my $fd, $home_text);
593 print "<table cellspacing=\"0\">\n" .
595 "<th>Project</th>\n" .
596 "<th>Description</th>\n" .
598 "<th>last change</th>\n" .
602 foreach my $pr (@list) {
604 my $head = git_read_hash
("$proj{'path'}/HEAD");
605 if (!defined $head) {
608 $ENV{'GIT_OBJECT_DIRECTORY'} = "$projectroot/$proj{'path'}/objects";
609 $ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$proj{'path'}/objects";
610 my %co = git_read_commit
($head);
614 my $descr = git_read_description
($proj{'path'}) || "";
615 # get directory owner if not already specified
616 if (!defined $proj{'owner'}) {
617 $proj{'owner'} = get_file_owner
("$projectroot/$proj{'path'}") || "";
620 print "<tr style=\"background-color:#f6f5ed\">\n";
625 print "<td>" . $cgi->a({-href
=> "$my_uri?p=$proj{'path'};a=summary", -class => "list"}, escapeHTML
($proj{'path'})) . "</td>\n" .
626 "<td>$descr</td>\n" .
627 "<td><i>$proj{'owner'}</i></td>\n";
629 if ($co{'age'} < 60*60*2) {
630 $colored_age = "<span style =\"color: #009900;\"><b><i>$co{'age_string'}</i></b></span>";
631 } elsif ($co{'age'} < 60*60*24*2) {
632 $colored_age = "<span style =\"color: #009900;\"><i>$co{'age_string'}</i></span>";
634 $colored_age = "<i>$co{'age_string'}</i>";
636 print "<td>$colored_age</td>\n" .
637 "<td class=\"link\">" .
638 $cgi->a({-href
=> "$my_uri?p=$proj{'path'};a=summary"}, "summary") .
639 " | " . $cgi->a({-href
=> "$my_uri?p=$proj{'path'};a=log"}, "log") .
652 opendir my $dh, "$projectroot/$project/$ref_dir";
653 my @refs = grep !m/^\./, readdir $dh;
655 foreach my $ref_file (@refs) {
656 my $ref_id = git_read_hash
("$project/$ref_dir/$ref_file");
657 my $type = git_get_type
($ref_id) || next;
660 if ($type eq "tag") {
661 my %tag = git_read_tag
($ref_id);
662 if ($tag{'type'} eq "commit") {
663 %co = git_read_commit
($tag{'object'});
665 $ref_item{'type'} = $tag{'type'};
666 $ref_item{'name'} = $tag{'name'};
667 $ref_item{'id'} = $tag{'object'};
668 } elsif ($type eq "commit"){
669 %co = git_read_commit
($ref_id);
670 $ref_item{'type'} = "commit";
671 $ref_item{'name'} = $ref_file;
672 $ref_item{'title'} = $co{'title'};
673 $ref_item{'id'} = $ref_id;
675 $ref_item{'epoch'} = $co{'committer_epoch'} || 0;
676 $ref_item{'age'} = $co{'age_string'} || "unknown";
678 push @reflist, \
%ref_item;
681 @reflist = sort {$b->{'epoch'} <=> $a->{'epoch'}} @reflist;
686 my $descr = git_read_description
($project) || "none";
687 my $head = git_read_hash
("$project/HEAD");
688 $ENV{'GIT_OBJECT_DIRECTORY'} = "$projectroot/$project/objects";
689 $ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$project/objects";
690 my %co = git_read_commit
($head);
691 my %cd = date_str
($co{'committer_epoch'}, $co{'committer_tz'});
694 if (-f
$projects_list) {
695 open (my $fd , $projects_list);
696 while (my $line = <$fd>) {
698 my ($pr, $ow) = split ' ', $line;
701 if ($pr eq $project) {
708 if (!defined $owner) {
709 $owner = get_file_owner
("$projectroot/$project");
713 print "<div class=\"page_nav\">\n" .
714 $cgi->a({-href
=> "$my_uri?p=$project;a=log"}, "log") .
715 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=tree"}, "tree") .
718 print "<div class=\"title\">project</div>\n";
719 print "<table cellspacing=\"0\">\n" .
720 "<tr><td>description</td><td>" . escapeHTML
($descr) . "</td></tr>\n" .
721 "<tr><td>owner</td><td>$owner</td></tr>\n" .
722 "<tr><td>last change</td><td>$cd{'rfc2822'}</td></tr>\n" .
724 open my $fd, "-|", "$gitbin/git-rev-list --max-count=16 " . git_read_hash
("$project/HEAD") || die_error
(undef, "Open failed.");
725 my (@revlist) = map { chomp; $_ } <$fd>;
728 $cgi->a({-href
=> "$my_uri?p=$project;a=log", -class => "title"}, "commits") .
731 print "<table cellspacing=\"0\">\n";
733 foreach my $commit (@revlist) {
734 my %co = git_read_commit
($commit);
735 my %ad = date_str
($co{'author_epoch'});
737 print "<tr style=\"background-color:#f6f5ed\">\n";
743 print "<td><i>$co{'age_string'}</i></td>\n" .
744 "<td><i>$co{'author_name'}</i></td>\n" .
745 "<td>" . $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$commit", -class => "list"}, "<b>" . escapeHTML
($co{'title'}) . "</b>") . "</td>\n" .
746 "<td class=\"link\">" .
747 $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$commit"}, "commit") .
748 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=commitdiff;h=$commit"}, "commitdiff") .
752 print "<td>" . $cgi->a({-href
=> "$my_uri?p=$project;a=log"}, "...") . "</td>\n" .
759 my $taglist = git_read_refs
("refs/tags");
760 if (defined @$taglist) {
762 $cgi->a({-href
=> "$my_uri?p=$project;a=tags", -class => "title"}, "tags") .
765 print "<table cellspacing=\"0\">\n";
767 foreach my $entry (@$taglist) {
770 print "<tr style=\"background-color:#f6f5ed\">\n";
776 print "<td><i>$tag{'age'}</i></td>\n" .
777 "<td>" . $cgi->a({-href
=> "$my_uri?p=$project;a=$tag{'type'};h=$tag{'id'}", -class => "list"}, "<b>" . escapeHTML
($tag{'name'}) . "</b>") . "</td>\n" .
778 "<td class=\"link\">" . $cgi->a({-href
=> "$my_uri?p=$project;a=$tag{'type'};h=$tag{'id'}"}, $tag{'type'}) . "</td>\n" .
781 print "<td>" . $cgi->a({-href
=> "$my_uri?p=$project;a=tags"}, "...") . "</td>\n" .
789 my $branchlist = git_read_refs
("refs/heads");
790 if (defined @$branchlist) {
792 $cgi->a({-href
=> "$my_uri?p=$project;a=branches", -class => "title"}, "branches") .
795 print "<table cellspacing=\"0\">\n";
797 foreach my $entry (@$branchlist) {
800 print "<tr style=\"background-color:#f6f5ed\">\n";
806 print "<td><i>$tag{'age'}</i></td>\n" .
807 "<td>" . $cgi->a({-href
=> "$my_uri?p=$project;a=log;h=$tag{'id'}", -class => "list"}, "<b>" . escapeHTML
($tag{'name'}) . "</b>") . "</td>\n" .
808 "<td class=\"link\">" . $cgi->a({-href
=> "$my_uri?p=$project;a=log;h=$tag{'id'}"}, "log") . "</td>\n" .
811 print "<td>" . $cgi->a({-href
=> "$my_uri?p=$project;a=branches"}, "...") . "</td>\n" .
822 my $head = git_read_hash
("$project/HEAD");
824 print "<div class=\"page_nav\">\n" .
825 $cgi->a({-href
=> "$my_uri?p=$project;a=log"}, "log") .
826 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$head"}, "commit") .
827 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=tree"}, "tree") .
830 my $taglist = git_read_refs
("refs/tags");
832 $cgi->a({-href
=> "$my_uri?p=$project;a=summary", -class => "title"}, "tags") .
834 print "<table cellspacing=\"0\">\n";
836 if (defined @$taglist) {
837 foreach my $entry (@$taglist) {
840 print "<tr style=\"background-color:#f6f5ed\">\n";
845 print "<td><i>$tag{'age'}</i></td>\n" .
846 "<td>" . $cgi->a({-href
=> "$my_uri?p=$project;a=log;h=$tag{'id'}", -class => "list"}, "<b>" . escapeHTML
($tag{'name'}) . "</b>") . "</td>\n" .
847 "<td class=\"link\">" . $cgi->a({-href
=> "$my_uri?p=$project;a=$tag{'type'};h=$tag{'id'}"}, $tag{'type'}) . "</td>\n" .
856 my $head = git_read_hash
("$project/HEAD");
858 print "<div class=\"page_nav\">\n" .
859 $cgi->a({-href
=> "$my_uri?p=$project;a=log"}, "log") .
860 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$head"}, "commit") .
861 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=tree"}, "tree") .
864 my $taglist = git_read_refs
("refs/heads");
866 $cgi->a({-href
=> "$my_uri?p=$project;a=summary", -class => "title"}, "branches") .
868 print "<table cellspacing=\"0\">\n";
870 if (defined @$taglist) {
871 foreach my $entry (@$taglist) {
874 print "<tr style=\"background-color:#f6f5ed\">\n";
879 print "<td><i>$tag{'age'}</i></td>\n" .
880 "<td>" . $cgi->a({-href
=> "$my_uri?p=$project;a=log;h=$tag{'id'}", -class => "list"}, "<b>" . escapeHTML
($tag{'name'}) . "</b>") . "</td>\n" .
881 "<td class=\"link\">" . $cgi->a({-href
=> "$my_uri?p=$project;a=log;h=$tag{'id'}"}, "log") . "</td>\n" .
889 sub git_get_hash_by_path
{
894 my @parts = split '/', $path;
895 while (my $part = shift @parts) {
896 open my $fd, "-|", "$gitbin/git-ls-tree $tree" || die_error
(undef, "Open git-ls-tree failed.");
897 my (@entries) = map { chomp; $_ } <$fd>;
898 close $fd || return undef;
899 foreach my $line (@entries) {
900 #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c'
901 $line =~ m/^([0-9]+)\t(.*)\t(.*)\t(.*)$/;
906 if ($t_name eq $part) {
910 if ($t_type eq "tree") {
920 if (!defined $hash && defined $file_name) {
921 my $base = $hash_base || git_read_hash
("$project/HEAD");
922 $hash = git_get_hash_by_path
($base, $file_name, "blob");
924 open my $fd, "-|", "$gitbin/git-cat-file blob $hash" || die_error
(undef, "Open failed.");
925 my $base = $file_name || "";
927 if (defined $hash_base && (my %co = git_read_commit
($hash_base))) {
928 print "<div class=\"page_nav\">\n" .
929 $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") .
930 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "commitdiff") .
931 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash_base"}, "tree");
932 if (defined $file_name) {
933 print " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=history;h=$hash_base;f=$file_name"}, "history");
935 print "<br/><br/>\n" .
938 $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$hash_base", -class => "title"}, escapeHTML
($co{'title'})) .
941 print "<div class=\"page_nav\">\n" .
942 "<br/><br/></div>\n" .
943 "<div class=\"title\">$hash</div>\n";
945 if (defined $file_name) {
946 print "<div class=\"page_path\">/$file_name</div>\n";
948 print "<div class=\"page_body\">\n";
950 while (my $line = <$fd>) {
953 print "<div class=\"pre\">";
954 printf "<span style=\"color:#999999;\">%4i</span>", $nr;
955 print " " .escapeHTML
($line) . "</div>\n";
957 close $fd || print "Reading blob failed.\n";
963 if (!defined $hash) {
964 $hash = git_read_hash
("$project/HEAD");
965 if (defined $file_name) {
966 my $base = $hash_base || git_read_hash
("$project/HEAD");
967 $hash = git_get_hash_by_path
($base, $file_name, "tree");
969 if (!defined $hash_base) {
970 $hash_base = git_read_hash
("$project/HEAD");
973 open my $fd, "-|", "$gitbin/git-ls-tree $hash" || die_error
(undef, "Open git-ls-tree failed.");
974 my (@entries) = map { chomp; $_ } <$fd>;
975 close $fd || die_error
(undef, "Reading tree failed.");
981 if (defined $hash_base && (my %co = git_read_commit
($hash_base))) {
982 $base_key = ";hb=$hash_base";
983 print "<div class=\"page_nav\">\n" .
984 $cgi->a({-href
=> "$my_uri?p=$project;a=log"}, "log") .
985 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") .
986 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "commitdiff") .
987 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash_base"}, "tree") .
991 $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$hash_base", -class => "title"}, escapeHTML
($co{'title'})) . "\n" .
994 print "<div class=\"page_nav\">\n";
995 print "<br/><br/></div>\n";
996 print "<div class=\"title\">$hash</div>\n";
998 if (defined $file_name) {
999 $base = "$file_name/";
1000 print "<div class=\"page_path\">/$file_name</div>\n";
1002 print "<div class=\"page_path\">/</div>\n";
1004 print "<div class=\"page_body\">\n";
1005 print "<table cellspacing=\"0\">\n";
1007 foreach my $line (@entries) {
1008 #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c'
1009 $line =~ m/^([0-9]+)\t(.*)\t(.*)\t(.*)$/;
1014 $file_key = ";f=$base$t_name";
1016 print "<tr style=\"background-color:#f6f5ed\">\n";
1021 print "<td style=\"font-family:monospace\">" . mode_str
($t_mode) . "</td>\n";
1022 if ($t_type eq "blob") {
1023 print "<td class=\"list\">" .
1024 $cgi->a({-href
=> "$my_uri?p=$project;a=blob;h=$t_hash" . $base_key . $file_key, -class => "list"}, $t_name) .
1026 print "<td class=\"link\">" .
1027 $cgi->a({-href
=> "$my_uri?p=$project;a=blob;h=$t_hash" . $base_key . $file_key}, "blob") .
1028 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=history;h=$hash_base" . $file_key}, "history") .
1030 } elsif ($t_type eq "tree") {
1031 print "<td class=\"list\">" .
1032 $cgi->a({-href
=> "$my_uri?p=$project;a=tree;h=$t_hash" . $base_key . $file_key}, $t_name) .
1038 print "</table>\n" .
1044 open my $fd, "-|", "$gitbin/git-rev-list --max-count=20 " . git_read_hash
("$project/HEAD") || die_error
(undef, "Open failed.");
1045 my (@revlist) = map { chomp; $_ } <$fd>;
1046 close $fd || die_error
(undef, "Reading rev-list failed.");
1048 print $cgi->header(-type
=> 'text/xml', -charset
=> 'utf-8');
1049 print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n".
1050 "<rss version=\"0.91\">\n";
1051 print "<channel>\n";
1052 print "<title>$project</title>\n".
1053 "<link> $my_url/$project/log</link>\n".
1054 "<description>$project log</description>\n".
1055 "<language>en</language>\n";
1057 foreach my $commit (@revlist) {
1058 my %co = git_read_commit
($commit);
1059 my %ad = date_str
($co{'author_epoch'});
1061 "\t<title>" . sprintf("%d %s %02d:%02d", $ad{'mday'}, $ad{'month'}, $ad{'hour'}, $ad{'minute'}) . " - " . escapeHTML
($co{'title'}) . "</title>\n" .
1062 "\t<link> $my_url?p=$project;a=commit;h=$commit</link>\n" .
1064 my $comment = $co{'comment'};
1065 foreach my $line (@$comment) {
1066 print escapeHTML
($line) . "<br/>\n";
1068 print "\t</description>\n" .
1071 print "</channel></rss>";
1075 if (!defined $hash) {
1076 $hash = git_read_hash
("$project/HEAD");
1078 my $limit_option = "";
1079 if (!defined $time_back) {
1080 $limit_option = "--max-count=10";
1081 } elsif ($time_back > 0) {
1082 my $date = time - $time_back*24*60*60;
1083 $limit_option = "--max-age=$date";
1085 open my $fd, "-|", "$gitbin/git-rev-list $limit_option $hash" || die_error
(undef, "Open failed.");
1086 my (@revlist) = map { chomp; $_ } <$fd>;
1087 close $fd || die_error
(undef, "Reading rev-list failed.");
1090 print "<div class=\"page_nav\">\n";
1091 print $cgi->a({-href
=> "$my_uri?p=$project;a=log"}, "last 10") . " | " .
1092 $cgi->a({-href
=> "$my_uri?p=$project;a=log;t=1"}, "day") . " | " .
1093 $cgi->a({-href
=> "$my_uri?p=$project;a=log;t=7"}, "week") . " | " .
1094 $cgi->a({-href
=> "$my_uri?p=$project;a=log;t=31"}, "month") . " | " .
1095 $cgi->a({-href
=> "$my_uri?p=$project;a=log;t=365"}, "year") . " | " .
1096 $cgi->a({-href
=> "$my_uri?p=$project;a=log;t=0"}, "all") . "<br/>\n";
1101 my %co = git_read_commit
($hash);
1102 print "<div class=\"page_body\"> Last change $co{'age_string'}.<br/><br/></div>\n";
1105 foreach my $commit (@revlist) {
1106 my %co = git_read_commit
($commit);
1108 my %ad = date_str
($co{'author_epoch'});
1110 $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$commit", -class => "title"},
1111 "<span class=\"age\">$co{'age_string'}</span>" . escapeHTML
($co{'title'})) . "\n" .
1113 print "<div class=\"title_text\">\n" .
1114 "<div class=\"log_link\">\n" .
1115 $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$commit"}, "commit") .
1116 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=commitdiff;h=$commit"}, "commitdiff") .
1119 "<i>" . escapeHTML
($co{'author_name'}) . " [$ad{'rfc2822'}]</i><br/>\n" .
1121 "<div class=\"log_body\">\n";
1122 my $comment = $co{'comment'};
1124 foreach my $line (@$comment) {
1125 if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
1136 print escapeHTML
($line) . "<br/>\n";
1147 my %co = git_read_commit
($hash);
1149 die_error
(undef, "Unknown commit object.");
1151 my %ad = date_str
($co{'author_epoch'}, $co{'author_tz'});
1152 my %cd = date_str
($co{'committer_epoch'}, $co{'committer_tz'});
1155 if (defined $co{'parent'}) {
1156 open my $fd, "-|", "$gitbin/git-diff-tree -r $co{'parent'} $hash" || die_error
(undef, "Open failed.");
1157 @difftree = map { chomp; $_ } <$fd>;
1158 close $fd || die_error
(undef, "Reading diff-tree failed.");
1160 # fake git-diff-tree output for initial revision
1161 open my $fd, "-|", "$gitbin/git-ls-tree -r $hash" || die_error
(undef, "Open failed.");
1162 @difftree = map { chomp; "+" . $_ } <$fd>;
1163 close $fd || die_error
(undef, "Reading ls-tree failed.");
1166 print "<div class=\"page_nav\">\n" .
1167 $cgi->a({-href
=> "$my_uri?p=$project;a=log"}, "log") .
1168 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$hash"}, "commit");
1169 if (defined $co{'parent'}) {
1170 print " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff");
1172 print " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, "tree") . "\n" .
1173 "<br/><br/></div>\n";
1174 if (defined $co{'parent'}) {
1176 $cgi->a({-href
=> "$my_uri?p=$project;a=commitdiff;h=$hash", -class => "title"}, escapeHTML
($co{'title'})) . "\n" .
1180 $cgi->a({-href
=> "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash", -class => "title"}, escapeHTML
($co{'title'})) . "\n" .
1183 print "<div class=\"title_text\">\n" .
1184 "<table cellspacing=\"0\">\n";
1185 print "<tr><td>author</td><td>" . escapeHTML
($co{'author'}) . "</td></tr>\n".
1187 "<td></td><td> $ad{'rfc2822'}";
1188 if ($ad{'hour_local'} < 6) {
1189 printf(" (<span style=\"color: #cc0000;\">%02d:%02d</span> %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
1191 printf(" (%02d:%02d %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
1195 print "<tr><td>committer</td><td>" . escapeHTML
($co{'committer'}) . "</td></tr>\n";
1196 print "<tr><td></td><td> $cd{'rfc2822'}" . sprintf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}) . "</td></tr>\n";
1197 print "<tr><td>commit</td><td style=\"font-family:monospace\">$hash</td></tr>\n";
1200 "<td style=\"font-family:monospace\">" . $cgi->a({-href
=> "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash", class => "list"}, $co{'tree'}) . "</td>" .
1201 "<td class=\"link\">" . $cgi->a({-href
=> "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, "tree") .
1204 my $parents = $co{'parents'};
1205 foreach my $par (@$parents) {
1208 "<td style=\"font-family:monospace\">" . $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$par", class => "list"}, $par) . "</td>" .
1209 "<td class=\"link\">" .
1210 $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$par"}, "commit") .
1211 " |" . $cgi->a({-href
=> "$my_uri?p=$project;a=commitdiff;h=$hash;hp=$par"}, "commitdiff") .
1217 print "<div class=\"page_body\">\n";
1218 my $comment = $co{'comment'};
1221 foreach my $line (@$comment) {
1222 # print only one empty line
1224 if ($empty || $signed) {
1231 if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
1233 print "<span style=\"color: #888888\">" . escapeHTML
($line) . "</span><br/>\n";
1236 print escapeHTML
($line) . "<br/>\n";
1240 print "<div class=\"list_head\">\n";
1241 if ($#difftree > 10) {
1242 print(($#difftree + 1) . " files changed:\n");
1245 print "<table cellspacing=\"0\">\n";
1247 foreach my $line (@difftree) {
1248 # '*100644->100644 blob 9f91a116d91926df3ba936a80f020a6ab1084d2b->bb90a0c3a91eb52020d0db0e8b4f94d30e02d596 net/ipv4/route.c'
1249 # '+100644 blob 4a83ab6cd565d21ab0385bac6643826b83c2fcd4 arch/arm/lib/bitops.h'
1250 # '*100664->100644 blob b1a8e3dd5556b61dd771d32307c6ee5d7150fa43->b1a8e3dd5556b61dd771d32307c6ee5d7150fa43 show-files.c'
1251 # '*100664->100644 blob d08e895238bac36d8220586fdc28c27e1a7a76d3->d08e895238bac36d8220586fdc28c27e1a7a76d3 update-cache.c'
1252 $line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/;
1258 if ($type ne "blob") {
1262 print "<tr style=\"background-color:#f6f5ed\">\n";
1267 print "<tr$alternate>\n";
1270 if (S_ISREG
(oct $mode)) {
1271 $mode_chng = sprintf(" with mode: %04o", (oct $mode) & 0777);
1274 $cgi->a({-href
=> "$my_uri?p=$project;a=blob;h=$id;hp=$hash;f=$file", -class => "list"}, escapeHTML
($file)) . "</td>\n" .
1275 "<td><span style=\"color: #008000;\">[new " . file_type
($mode) . "$mode_chng]</span></td>\n" .
1276 "<td class=\"link\">" . $cgi->a({-href
=> "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, "blob") . "</td>\n";
1277 } elsif ($op eq "-") {
1279 $cgi->a({-href
=> "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file", -class => "list"}, escapeHTML
($file)) . "</td>\n" .
1280 "<td><span style=\"color: #c00000;\">[deleted " . file_type
($mode). "]</span></td>\n" .
1281 "<td class=\"link\">" .
1282 $cgi->a({-href
=> "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, "blob") .
1283 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") .
1285 } elsif ($op eq "*") {
1286 $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/;
1289 $mode =~ m/^([0-7]{6})->([0-7]{6})$/;
1292 my $mode_chnge = "";
1293 if ($from_mode != $to_mode) {
1294 $mode_chnge = " <span style=\"color: #777777;\">[changed";
1295 if (((oct $from_mode) & S_IFMT
) != ((oct $to_mode) & S_IFMT
)) {
1296 $mode_chnge .= " from " . file_type
($from_mode) . " to " . file_type
($to_mode);
1298 if (((oct $from_mode) & 0777) != ((oct $to_mode) & 0777)) {
1299 if (S_ISREG
($from_mode) && S_ISREG
($to_mode)) {
1300 $mode_chnge .= sprintf(" mode: %04o->%04o", (oct $from_mode) & 0777, (oct $to_mode) & 0777);
1301 } elsif (S_ISREG
($to_mode)) {
1302 $mode_chnge .= sprintf(" mode: %04o", (oct $to_mode) & 0777);
1305 $mode_chnge .= "]</span>\n";
1308 if ($to_id ne $from_id) {
1309 print $cgi->a({-href
=> "$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file", -class => "list"}, escapeHTML
($file));
1311 print $cgi->a({-href
=> "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file", -class => "list"}, escapeHTML
($file));
1314 "<td>$mode_chnge</td>\n" .
1315 "<td class=\"link\">";
1316 print $cgi->a({-href
=> "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"}, "blob");
1317 if ($to_id ne $from_id) {
1318 print " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file"}, "diff");
1320 print " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . "\n";
1330 mkdir($gittmp, 0700);
1332 if (defined $hash_base && (my %co = git_read_commit
($hash_base))) {
1333 print "<div class=\"page_nav\">\n" .
1334 $cgi->a({-href
=> "$my_uri?p=$project;a=log"}, "log") .
1335 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") .
1336 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "commitdiff") .
1337 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash_base"}, "tree");
1338 if (defined $file_name) {
1339 print " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=history;h=$hash_base;f=$file_name"}, "history");
1341 print "<br/><br/>\n" .
1344 $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$hash_base", -class => "title"}, escapeHTML
($co{'title'})) . "\n" .
1347 print "<div class=\"page_nav\">\n" .
1348 "<br/><br/></div>\n" .
1349 "<div class=\"title\">$hash vs $hash_parent</div>\n";
1351 if (defined $file_name) {
1352 print "<div class=\"page_path\">\n" .
1356 print "<div class=\"page_body\">\n" .
1357 "<div class=\"diff_info\">blob:" .
1358 $cgi->a({-href
=> "$my_uri?p=$project;a=blob;h=$hash_parent;hb=$hash_base;f=$file_name"}, $hash_parent) .
1360 $cgi->a({-href
=> "$my_uri?p=$project;a=blob;h=$hash;hb=$hash_base;f=$file_name"}, $hash) .
1362 git_diff_html
($hash_parent, $file_name || $hash_parent, $hash, $file_name || $hash);
1367 sub git_commitdiff
{
1368 mkdir($gittmp, 0700);
1369 my %co = git_read_commit
($hash);
1371 die_error
(undef, "Unknown commit object.");
1373 if (!defined $hash_parent) {
1374 $hash_parent = $co{'parent'};
1376 open my $fd, "-|", "$gitbin/git-diff-tree -r $hash_parent $hash" || die_error
(undef, "Open failed.");
1377 my (@difftree) = map { chomp; $_ } <$fd>;
1378 close $fd || die_error
(undef, "Reading diff-tree failed.");
1381 print "<div class=\"page_nav\">\n" .
1382 $cgi->a({-href
=> "$my_uri?p=$project;a=log"}, "log") .
1383 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$hash"}, "commit") .
1384 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff") .
1385 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash"}, "tree") .
1386 "<br/><br/></div>\n";
1388 $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML
($co{'title'})) . "\n" .
1390 print "<div class=\"page_body\">\n";
1391 my $comment = $co{'comment'};
1394 my @log = @$comment;
1395 # remove first and empty lines after that
1397 while (defined $log[0] && $log[0] eq "") {
1400 foreach my $line (@log) {
1401 if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
1412 print escapeHTML
($line) . "<br/>\n";
1415 foreach my $line (@difftree) {
1416 # '*100644->100644 blob 8e5f9bbdf4de94a1bc4b4da8cb06677ce0a57716->8da3a306d0c0c070d87048d14a033df02f40a154 Makefile'
1417 $line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/;
1423 if ($type eq "blob") {
1425 print "<div class=\"diff_info\">" . file_type
($mode) . ":" .
1426 $cgi->a({-href
=> "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, $id) . "(new)" .
1428 git_diff_html
(undef, "/dev/null", $id, "b/$file");
1429 } elsif ($op eq "-") {
1430 print "<div class=\"diff_info\">" . file_type
($mode) . ":" .
1431 $cgi->a({-href
=> "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, $id) . "(deleted)" .
1433 git_diff_html
($id, "a/$file", undef, "/dev/null");
1434 } elsif ($op eq "*") {
1435 $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/;
1438 $mode =~ m/([0-7]+)->([0-7]+)/;
1441 if ($from_id ne $to_id) {
1442 print "<div class=\"diff_info\">" .
1443 file_type
($from_mode) . ":" . $cgi->a({-href
=> "$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file"}, $from_id) .
1445 file_type
($to_mode) . ":" . $cgi->a({-href
=> "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"}, $to_id);
1447 git_diff_html
($from_id, "a/$file", $to_id, "b/$file");
1458 if (!defined $hash) {
1459 $hash = git_read_hash
("$project/HEAD");
1461 my %co = git_read_commit
($hash);
1463 die_error
(undef, "Unknown commit object.");
1466 print "<div class=\"page_nav\">\n" .
1467 $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | " .
1468 $cgi->a({-href
=> "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff") . " | " .
1469 $cgi->a({-href
=> "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, "tree") .
1473 $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML
($co{'title'})) . "\n" .
1475 print "<div class=\"page_path\">\n" .
1476 "/$file_name<br/>\n";
1479 open my $fd, "-|", "$gitbin/git-rev-list $hash | $gitbin/git-diff-tree -r --stdin $file_name";
1481 print "<table cellspacing=\"0\">\n";
1483 while (my $line = <$fd>) {
1484 if ($line =~ m/^([0-9a-fA-F]{40}) /){
1488 if ($line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/ && (defined $commit)) {
1491 if ($file ne $file_name || $type ne "blob") {
1494 my %co = git_read_commit
($commit);
1499 print "<tr style=\"background-color:#f6f5ed\">\n";
1504 print "<td><i>$co{'age_string'}</i></td>\n" .
1505 "<td><i>$co{'author_name'}</i></td>\n" .
1506 "<td>" . $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$commit", -class => "list"}, "<b>" . escapeHTML
($co{'title'}) . "</b>") . "</td>\n" .
1507 "<td class=\"link\">" .
1508 $cgi->a({-href
=> "$my_uri?p=$project;a=commit;h=$commit"}, "commit") .
1509 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$commit"}, "tree") .
1510 " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=blob;hb=$commit;f=$file"}, "blob");
1511 my $blob = git_get_hash_by_path
($hash, $file_name);
1512 my $blob_parent = git_get_hash_by_path
($commit, $file_name);
1513 if (defined $blob && defined $blob_parent && $blob ne $blob_parent) {
1514 print " | " . $cgi->a({-href
=> "$my_uri?p=$project;a=blobdiff;h=$blob;hp=$blob_parent;hb=$commit;f=$file"}, "diff");
This page took 1.871262 seconds and 5 git commands to generate.