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 8px; 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; }
201 font-size:10px; font-family:sans-serif; font-style:normal;
202 position:relative; float:left; width:142px;
204 div.list { display:block; padding:4px 8px 2px; }
206 display:block; padding:6px 6px 4px; border:solid #d9d8d1;
207 border-width:0px 0px 1px; font-style:italic;
209 div.list a { text-decoration:none; color:#000000; }
210 div.list a:hover { color:#880000; }
212 padding:4px 8px 6px; border:solid #d9d8d1; border-width:0px 0px 1px;
213 font-family:sans-serif; font-size:10px;
215 td { padding:5px 15px 0px 0px; font-size:12px; }
216 th { padding-right:10px; font-size:12px; text-align:left; }
217 td.link { font-family:sans-serif; font-size:10px; }
218 td.pre { font-family:monospace; font-size:12px; white-space:pre; padding:2px 15px 0px 0px; }
219 div.pre { font-family:monospace; font-size:12px; white-space:pre; }
220 div.diff_info { font-family:monospace; color:#000099; background-color:#edece6; font-style:italic; }
221 div.index_include { border:solid #d9d8d1; border-width:0px 0px 1px; padding:12px 8px; }
222 a.rss_logo { float:right; padding:3px 0px; width:35px; line-height:10px;
223 border:1px solid; border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e;
224 color:#ffffff; background-color:#ff6600;
225 font-weight:bold; font-family:sans-serif; font-size:10px;
226 text-align:center; text-decoration:none;
228 a.rss_logo:hover { background-color:#ee5500; }
233 print "<div class=\"page_header\">\n" .
234 "<a href=\"http://kernel.org/pub/software/scm/git/docs/\">" .
235 "<img src=\"$my_uri?a=git-logo.png\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/></a>";
236 print $cgi->a({-href => $home_link}, "projects") . " / ";
237 if (defined $project) {
238 print $cgi->a({-href => "$my_uri?p=$project;a=summary"}, escapeHTML($project));
239 if (defined $action) {
246 sub git_footer_html {
247 print "<div class=\"page_footer\">\n";
248 if (defined $project) {
249 my $descr = git_read_description($project);
250 if (defined $descr) {
251 print "<div class=\"page_footer_text\">" . escapeHTML($descr) . "</div>\n";
253 print $cgi->a({-href => "$my_uri?p=$project;a=rss", -class => "rss_logo"}, "RSS") . "\n";
261 my $status = shift || "403 Forbidden";
262 my $error = shift || "Malformed query, file missing or permission denied";
264 git_header_html($status);
265 print "<div class=\"page_body\">\n" .
267 print "$status - $error\n";
268 print "<br/></div>\n";
276 open my $fd, "-|", "$gitbin/git-cat-file -t $hash" || return;
286 open my $fd, "$projectroot/$path" || return undef;
290 if ($head =~ m/^[0-9a-fA-F]{40}$/) {
295 sub git_read_description {
298 open my $fd, "$projectroot/$path/description" || return undef;
309 open my $fd, "-|", "$gitbin/git-cat-file tag $tag_id" || return;
310 while (my $line = <$fd>) {
312 if ($line =~ m/^object ([0-9a-fA-F]{40})$/) {
314 } elsif ($line =~ m/^type (.*)$/) {
316 } elsif ($line =~ m/^tag (.*)$/) {
321 if (!defined $tag{'name'}) {
327 sub git_read_commit {
332 open my $fd, "-|", "$gitbin/git-cat-file commit $commit" || return;
333 while (my $line = <$fd>) {
334 last if $line eq "\n";
336 if ($line =~ m/^tree (.*)$/) {
338 } elsif ($line =~ m/^parent (.*)$/) {
340 } elsif ($line =~ m/^author (.*) ([0-9]+) (.*)$/) {
342 $co{'author_epoch'} = $2;
343 $co{'author_tz'} = $3;
344 $co{'author_name'} = $co{'author'};
345 $co{'author_name'} =~ s/ <.*//;
346 } elsif ($line =~ m/^committer (.*) ([0-9]+) (.*)$/) {
347 $co{'committer'} = $1;
348 $co{'committer_epoch'} = $2;
349 $co{'committer_tz'} = $3;
350 $co{'committer_name'} = $co{'committer'};
351 $co{'committer_name'} =~ s/ <.*//;
354 if (!defined $co{'tree'}) {
358 $co{'parents'} = \@parents;
359 $co{'parent'} = $parents[0];
360 my (@comment) = map { chomp; $_ } <$fd>;
361 $co{'comment'} = \@comment;
362 $comment[0] =~ m/^(.{0,60}[^ ]*)/;
364 if ($comment[0] ne $co{'title'}) {
365 $co{'title'} .= " ...";
369 my $age = time - $co{'committer_epoch'};
371 if ($age > 60*60*24*365*2) {
372 $co{'age_string'} = (int $age/60/60/24/365);
373 $co{'age_string'} .= " years ago";
374 } elsif ($age > 60*60*24*(365/12)*2) {
375 $co{'age_string'} = int $age/60/60/24/(365/12);
376 $co{'age_string'} .= " months ago";
377 } elsif ($age > 60*60*24*7*2) {
378 $co{'age_string'} = int $age/60/60/24/7;
379 $co{'age_string'} .= " weeks ago";
380 } elsif ($age > 60*60*24*2) {
381 $co{'age_string'} = int $age/60/60/24;
382 $co{'age_string'} .= " days ago";
383 } elsif ($age > 60*60*2) {
384 $co{'age_string'} = int $age/60/60;
385 $co{'age_string'} .= " hours ago";
386 } elsif ($age > 60*2) {
387 $co{'age_string'} = int $age/60;
388 $co{'age_string'} .= " min ago";
390 $co{'age_string'} = int $age;
391 $co{'age_string'} .= " sec ago";
393 $co{'age_string'} .= " right now";
400 my $from_name = shift;
404 my $from_tmp = "/dev/null";
405 my $to_tmp = "/dev/null";
408 # create tmp from-file
410 $from_tmp = "$gittmp/gitweb_" . $$ . "_from";
411 open my $fd2, "> $from_tmp";
412 open my $fd, "-|", "$gitbin/git-cat-file blob $from";
421 $to_tmp = "$gittmp/gitweb_" . $$ . "_to";
422 open my $fd2, "> $to_tmp";
423 open my $fd, "-|", "$gitbin/git-cat-file blob $to";
430 open my $fd, "-|", "/usr/bin/diff -u -p -L $from_name -L $to_name $from_tmp $to_tmp";
431 while (my $line = <$fd>) {
433 my $char = substr($line, 0, 1);
436 $color = " style=\"color:#008800;\"";
437 } elsif ($char eq '-') {
438 $color = " style=\"color:#cc0000;\"";
439 } elsif ($char eq '@') {
440 $color = " style=\"color:#990099;\"";
441 } elsif ($char eq '\\') {
445 print "<div class=\"pre\"$color>" . escapeHTML($line) . "</div>\n";
458 my $mode = oct shift;
460 if (S_ISDIR($mode & S_IFMT)) {
462 } elsif (S_ISLNK($mode)) {
464 } elsif (S_ISREG($mode)) {
465 # git cares only about the executable bit
466 if ($mode & S_IXUSR) {
477 my $mode = oct shift;
479 if (S_ISDIR($mode & S_IFMT)) {
481 } elsif (S_ISLNK($mode)) {
483 } elsif (S_ISREG($mode)) {
492 my $tz = shift || "-0000";
495 my @months = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
496 my @days = ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
497 my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($epoch);
498 $date{'hour'} = $hour;
499 $date{'minute'} = $min;
500 $date{'mday'} = $mday;
501 $date{'day'} = $days[$wday];
502 $date{'month'} = $months[$mon];
503 $date{'rfc2822'} = sprintf "%s, %d %s %4d %02d:%02d:%02d +0000", $days[$wday], $mday, $months[$mon], 1900+$year, $hour ,$min, $sec;
504 $date{'mday-time'} = sprintf "%d %s %02d:%02d", $mday, $months[$mon], $hour ,$min;
506 $tz =~ m/^([+\-][0-9][0-9])([0-9][0-9])$/;
507 my $local = $epoch + ((int $1 + ($2/60)) * 3600);
508 ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($local);
509 $date{'hour_local'} = $hour;
510 $date{'minute_local'} = $min;
511 $date{'tz_local'} = $tz;
515 # git-logo (cached in browser for one day)
517 print $cgi->header(-type => 'image/png', -expires => '+1d');
518 # cat git-logo.png | hexdump -e '16/1 " %02x" "\n"' | sed 's/ /\\x/g'
519 print "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52" .
520 "\x00\x00\x00\x48\x00\x00\x00\x1b\x04\x03\x00\x00\x00\x2d\xd9\xd4" .
521 "\x2d\x00\x00\x00\x18\x50\x4c\x54\x45\xff\xff\xff\x60\x60\x5d\xb0" .
522 "\xaf\xaa\x00\x80\x00\xce\xcd\xc7\xc0\x00\x00\xe8\xe8\xe6\xf7\xf7" .
523 "\xf6\x95\x0c\xa7\x47\x00\x00\x00\x73\x49\x44\x41\x54\x28\xcf\x63" .
524 "\x48\x67\x20\x04\x4a\x5c\x18\x0a\x08\x2a\x62\x53\x61\x20\x02\x08" .
525 "\x0d\x69\x45\xac\xa1\xa1\x01\x30\x0c\x93\x60\x36\x26\x52\x91\xb1" .
526 "\x01\x11\xd6\xe1\x55\x64\x6c\x6c\xcc\x6c\x6c\x0c\xa2\x0c\x70\x2a" .
527 "\x62\x06\x2a\xc1\x62\x1d\xb3\x01\x02\x53\xa4\x08\xe8\x00\x03\x18" .
528 "\x26\x56\x11\xd4\xe1\x20\x97\x1b\xe0\xb4\x0e\x35\x24\x71\x29\x82" .
529 "\x99\x30\xb8\x93\x0a\x11\xb9\x45\x88\xc1\x8d\xa0\xa2\x44\x21\x06" .
530 "\x27\x41\x82\x40\x85\xc1\x45\x89\x20\x70\x01\x00\xa4\x3d\x21\xc5" .
531 "\x12\x1c\x9a\xfe\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82";
537 my ($dev, $ino, $mode, $nlink, $st_uid, $st_gid, $rdev, $size) = stat($path);
538 my ($name, $passwd, $uid, $gid, $quota, $comment, $gcos, $dir, $shell) = getpwuid($st_uid);
539 if (!defined $gcos) {
543 $owner =~ s/[,;].*$//;
547 sub git_project_list {
550 if (-d $projects_list) {
551 # search in directory
552 my $dir = $projects_list;
553 opendir my $dh, $dir || return undef;
554 while (my $dir = readdir($dh)) {
555 if (-e "$projectroot/$dir/HEAD") {
563 } elsif (-f $projects_list) {
565 # 'git/git.git:Linus Torvalds'
566 # 'linux/hotplug/udev.git'
567 open my $fd , $projects_list || return undef;
568 while (my $line = <$fd>) {
570 my ($path, $owner) = split ' ', $line;
571 $path = unescape($path);
572 $owner = unescape($owner);
573 if (!defined $path) {
576 if (-e "$projectroot/$path/HEAD") {
588 die_error(undef, "No project found.");
590 @list = sort {$a->{'path'} cmp $b->{'path'}} @list;
594 print "<div class=\"index_include\">\n";
595 open (my $fd, $home_text);
600 print "<div class=\"page_body\"><br/>\n" .
601 "<table cellspacing=\"0\">\n" .
603 "<th>Project</th>\n" .
604 "<th>Description</th>\n" .
606 "<th>last change</th>\n" .
609 foreach my $pr (@list) {
611 my $head = git_read_hash("$proj{'path'}/HEAD");
612 if (!defined $head) {
615 $ENV{'GIT_OBJECT_DIRECTORY'} = "$projectroot/$proj{'path'}/objects";
616 $ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$proj{'path'}/objects";
617 my %co = git_read_commit($head);
621 my $descr = git_read_description($proj{'path'}) || "";
622 # get directory owner if not already specified
623 if (!defined $proj{'owner'}) {
624 $proj{'owner'} = get_file_owner("$projectroot/$proj{'path'}") || "";
627 "<td>" . $cgi->a({-href => "$my_uri?p=$proj{'path'};a=summary"}, escapeHTML($proj{'path'})) . "</td>\n" .
628 "<td>$descr</td>\n" .
629 "<td><i>$proj{'owner'}</i></td>\n";
631 if ($co{'age'} < 60*60*2) {
632 $colored_age = "<span style =\"color: #009900;\"><b><i>$co{'age_string'}</i></b></span>";
633 } elsif ($co{'age'} < 60*60*24*2) {
634 $colored_age = "<span style =\"color: #009900;\"><i>$co{'age_string'}</i></span>";
636 $colored_age = "<i>$co{'age_string'}</i>";
638 print "<td>$colored_age</td>\n" .
639 "<td class=\"link\">" .
640 $cgi->a({-href => "$my_uri?p=$proj{'path'};a=summary"}, "summary") .
641 " | " . $cgi->a({-href => "$my_uri?p=$proj{'path'};a=log"}, "log") .
642 " | " . $cgi->a({-href => "$my_uri?p=$proj{'path'};a=tree"}, "tree") .
656 opendir my $dh, "$projectroot/$project/$ref_dir";
657 my @refs = grep !m/^\./, readdir $dh;
659 foreach my $ref_file (@refs) {
660 my $ref_id = git_read_hash("$project/$ref_dir/$ref_file");
661 my $type = git_get_type($ref_id) || next;
664 if ($type eq "tag") {
665 my %tag = git_read_tag($ref_id);
666 if ($tag{'type'} eq "commit") {
667 %co = git_read_commit($tag{'object'});
669 $ref_item{'type'} = $tag{'type'};
670 $ref_item{'name'} = $tag{'name'};
671 $ref_item{'id'} = $tag{'object'};
672 } elsif ($type eq "commit"){
673 %co = git_read_commit($ref_id);
674 $ref_item{'type'} = "commit";
675 $ref_item{'name'} = $ref_file;
676 $ref_item{'title'} = $co{'title'};
677 $ref_item{'id'} = $ref_id;
679 $ref_item{'epoch'} = $co{'committer_epoch'} || 0;
680 $ref_item{'age'} = $co{'age_string'} || "unknown";
682 push @reflist, \%ref_item;
685 @reflist = sort {$b->{'epoch'} <=> $a->{'epoch'}} @reflist;
690 my $descr = git_read_description($project) || "none";
691 my $head = git_read_hash("$project/HEAD");
692 $ENV{'GIT_OBJECT_DIRECTORY'} = "$projectroot/$project/objects";
693 $ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$project/objects";
694 my %co = git_read_commit($head);
695 my %cd = date_str($co{'committer_epoch'}, $co{'committer_tz'});
698 if (-f $projects_list) {
699 open (my $fd , $projects_list);
700 while (my $line = <$fd>) {
702 my ($pr, $ow) = split ' ', $line;
705 if ($pr eq $project) {
712 if (!defined $owner) {
713 $owner = get_file_owner("$projectroot/$project");
717 print "<div class=\"page_nav\">\n" .
718 $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") .
719 " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree"}, "tree") .
722 print "<div class=\"title\">project</div>\n";
723 print "<div class=\"page_body\">\n" .
724 "<table cellspacing=\"0\">\n" .
725 "<tr><td>description</td><td>" . escapeHTML($descr) . "</td></tr>\n" .
726 "<tr><td>owner</td><td>$owner</td></tr>\n" .
727 "<tr><td>last change</td><td>$cd{'rfc2822'}</td></tr>\n" .
730 open my $fd, "-|", "$gitbin/git-rev-list --max-count=11 " . git_read_hash("$project/HEAD") || die_error(undef, "Open failed.");
731 my (@revlist) = map { chomp; $_ } <$fd>;
734 $cgi->a({-href => "$my_uri?p=$project;a=log", -class => "title"}, "commits") .
737 print "<div class=\"page_body\">\n" .
738 "<table cellspacing=\"0\">\n";
739 foreach my $commit (@revlist) {
740 my %co = git_read_commit($commit);
741 my %ad = date_str($co{'author_epoch'});
744 print "<td>$co{'age_string'}</td>\n" .
745 "<td>$co{'author_name'}</td>\n" .
746 "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, escapeHTML($co{'title'})) . "</td>\n" .
749 print "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "...") . "</td>\n" .
757 my $taglist = git_read_refs("refs/tags");
758 if (defined @$taglist) {
760 $cgi->a({-href => "$my_uri?p=$project;a=tags", -class => "title"}, "tags") .
763 print "<div class=\"page_body\">\n" .
764 "<table cellspacing=\"0\">\n";
765 foreach my $entry (@$taglist) {
769 print "<td>$tag{'age'}</td>\n" .
770 "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'id'}"}, escapeHTML($tag{'name'})) . "</td>\n" .
773 print "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=tags"}, "...") . "</td>\n" .
782 my $branchlist = git_read_refs("refs/heads");
783 if (defined @$branchlist) {
785 $cgi->a({-href => "$my_uri?p=$project;a=branches", -class => "title"}, "branches") .
788 print "<div class=\"page_body\">\n" .
789 "<table cellspacing=\"0\">\n";
790 foreach my $entry (@$branchlist) {
794 print "<td>$tag{'age'}</td>\n" .
795 "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}"}, escapeHTML($tag{'name'})) . "</td>\n" .
798 print "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=branches"}, "...") . "</td>\n" .
810 my $head = git_read_hash("$project/HEAD");
812 print "<div class=\"page_nav\">\n" .
813 $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") .
814 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$head"}, "commit") .
815 " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree"}, "tree") .
818 my $taglist = git_read_refs("refs/tags");
820 $cgi->a({-href => "$my_uri?p=$project;a=summary", -class => "title"}, "tags") .
822 if (defined @$taglist) {
823 foreach my $entry (@$taglist) {
825 print "<div class=\"list\">\n" .
826 $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'id'}"},
827 "<span class=\"age\">$tag{'age'}</span>" . escapeHTML($tag{'name'})) . "\n" .
831 print "<div class=\"list\"><br/></div>\n";
836 my $head = git_read_hash("$project/HEAD");
838 print "<div class=\"page_nav\">\n" .
839 $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") .
840 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$head"}, "commit") .
841 " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree"}, "tree") .
844 my $taglist = git_read_refs("refs/heads");
846 $cgi->a({-href => "$my_uri?p=$project;a=summary", -class => "title"}, "branches") .
848 if (defined @$taglist) {
849 foreach my $entry (@$taglist) {
851 print "<div class=\"list\">\n" .
852 $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}"},
853 "<span class=\"age\">$tag{'age'}</span>" . escapeHTML($tag{'name'})) . "\n" .
857 print "<div class=\"list\"><br/></div>\n";
861 sub git_get_hash_by_path {
866 my @parts = split '/', $path;
867 while (my $part = shift @parts) {
868 open my $fd, "-|", "$gitbin/git-ls-tree $tree" || die_error(undef, "Open git-ls-tree failed.");
869 my (@entries) = map { chomp; $_ } <$fd>;
870 close $fd || return undef;
871 foreach my $line (@entries) {
872 #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c'
873 $line =~ m/^([0-9]+)\t(.*)\t(.*)\t(.*)$/;
878 if ($t_name eq $part) {
882 if ($t_type eq "tree") {
892 if (!defined $hash && defined $file_name) {
893 my $base = $hash_base || git_read_hash("$project/HEAD");
894 $hash = git_get_hash_by_path($base, $file_name, "blob");
896 open my $fd, "-|", "$gitbin/git-cat-file blob $hash" || die_error(undef, "Open failed.");
897 my $base = $file_name || "";
899 if (defined $hash_base && (my %co = git_read_commit($hash_base))) {
900 print "<div class=\"page_nav\">\n" .
901 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") .
902 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "commitdiff") .
903 " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash_base"}, "tree");
904 if (defined $file_name) {
905 print " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash_base;f=$file_name"}, "history");
907 print "<br/><br/>\n" .
910 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base", -class => "title"}, escapeHTML($co{'title'})) .
913 print "<div class=\"page_nav\">\n" .
914 "<br/><br/></div>\n" .
915 "<div class=\"title\">$hash</div>\n";
917 if (defined $file_name) {
918 print "<div class=\"page_path\">/$file_name</div>\n";
920 print "<div class=\"page_body\">\n";
922 while (my $line = <$fd>) {
925 print "<div class=\"pre\">";
926 printf "<span style=\"color:#999999;\">%4i</span>", $nr;
927 print " " .escapeHTML($line) . "</div>\n";
929 close $fd || print "Reading blob failed.\n";
935 if (!defined $hash) {
936 $hash = git_read_hash("$project/HEAD");
937 if (defined $file_name) {
938 my $base = $hash_base || git_read_hash("$project/HEAD");
939 $hash = git_get_hash_by_path($base, $file_name, "tree");
942 if (!defined $hash_base) {
943 $hash_base = git_read_hash("$project/HEAD");
945 open my $fd, "-|", "$gitbin/git-ls-tree $hash" || die_error(undef, "Open git-ls-tree failed.");
946 my (@entries) = map { chomp; $_ } <$fd>;
947 close $fd || die_error(undef, "Reading tree failed.");
953 if (defined $hash_base && (my %co = git_read_commit($hash_base))) {
954 $base_key = ";hb=$hash_base";
955 print "<div class=\"page_nav\">\n" .
956 $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") .
957 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") .
958 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "commitdiff") .
959 " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash_base"}, "tree") .
963 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base", -class => "title"}, escapeHTML($co{'title'})) . "\n" .
966 print "<div class=\"page_nav\">\n";
967 print "<br/><br/></div>\n";
968 print "<div class=\"title\">$hash</div>\n";
970 if (defined $file_name) {
971 $base = "$file_name/";
972 print "<div class=\"page_path\">/$file_name</div>\n";
974 print "<div class=\"page_path\">/</div>\n";
976 print "<div class=\"page_body\">\n";
977 print "<table cellspacing=\"0\">\n";
978 foreach my $line (@entries) {
979 #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c'
980 $line =~ m/^([0-9]+)\t(.*)\t(.*)\t(.*)$/;
985 $file_key = ";f=$base$t_name";
987 "<td class=\"pre\">" . mode_str($t_mode) . "</td>\n";
988 if ($t_type eq "blob") {
989 print "<td class=\"pre\">$t_name</td>\n";
990 print "<td class=\"link\">" .
991 $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash" . $base_key . $file_key}, "blob") .
992 " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash_base" . $file_key}, "history") .
994 } elsif ($t_type eq "tree") {
995 print "<td class=\"pre\">" .
996 $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$t_hash" . $base_key . $file_key}, $t_name) .
1001 print "</table>\n" .
1007 open my $fd, "-|", "$gitbin/git-rev-list --max-count=20 " . git_read_hash("$project/HEAD") || die_error(undef, "Open failed.");
1008 my (@revlist) = map { chomp; $_ } <$fd>;
1009 close $fd || die_error(undef, "Reading rev-list failed.");
1011 print $cgi->header(-type => 'text/xml', -charset => 'utf-8');
1012 print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n".
1013 "<rss version=\"0.91\">\n";
1014 print "<channel>\n";
1015 print "<title>$project</title>\n".
1016 "<link> $my_url/$project/log</link>\n".
1017 "<description>$project log</description>\n".
1018 "<language>en</language>\n";
1020 foreach my $commit (@revlist) {
1021 my %co = git_read_commit($commit);
1022 my %ad = date_str($co{'author_epoch'});
1024 "\t<title>" . sprintf("%d %s %02d:%02d", $ad{'mday'}, $ad{'month'}, $ad{'hour'}, $ad{'minute'}) . " - " . escapeHTML($co{'title'}) . "</title>\n" .
1025 "\t<link> $my_url?p=$project;a=commit;h=$commit</link>\n" .
1027 my $comment = $co{'comment'};
1028 foreach my $line (@$comment) {
1029 print escapeHTML($line) . "<br/>\n";
1031 print "\t</description>\n" .
1034 print "</channel></rss>";
1038 if (!defined $hash) {
1039 $hash = git_read_hash("$project/HEAD");
1041 my $limit_option = "";
1042 if (!defined $time_back) {
1043 $limit_option = "--max-count=10";
1044 } elsif ($time_back > 0) {
1045 my $date = time - $time_back*24*60*60;
1046 $limit_option = "--max-age=$date";
1048 open my $fd, "-|", "$gitbin/git-rev-list $limit_option $hash" || die_error(undef, "Open failed.");
1049 my (@revlist) = map { chomp; $_ } <$fd>;
1050 close $fd || die_error(undef, "Reading rev-list failed.");
1053 print "<div class=\"page_nav\">\n";
1054 print $cgi->a({-href => "$my_uri?p=$project;a=log"}, "last 10") . " | " .
1055 $cgi->a({-href => "$my_uri?p=$project;a=log;t=1"}, "day") . " | " .
1056 $cgi->a({-href => "$my_uri?p=$project;a=log;t=7"}, "week") . " | " .
1057 $cgi->a({-href => "$my_uri?p=$project;a=log;t=31"}, "month") . " | " .
1058 $cgi->a({-href => "$my_uri?p=$project;a=log;t=365"}, "year") . " | " .
1059 $cgi->a({-href => "$my_uri?p=$project;a=log;t=0"}, "all") . "<br/>\n";
1064 my %co = git_read_commit($hash);
1065 print "<div class=\"page_body\"> Last change $co{'age_string'}.<br/><br/></div>\n";
1068 foreach my $commit (@revlist) {
1069 my %co = git_read_commit($commit);
1071 my %ad = date_str($co{'author_epoch'});
1073 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "title"},
1074 "<span class=\"age\">$co{'age_string'}</span>" . escapeHTML($co{'title'})) . "\n" .
1076 print "<div class=\"title_text\">\n" .
1077 "<div class=\"log_link\">\n" .
1078 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") .
1079 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "commitdiff") .
1082 "<i>" . escapeHTML($co{'author_name'}) . " [$ad{'rfc2822'}]</i><br/>\n" .
1084 "<div class=\"log_body\">\n";
1085 my $comment = $co{'comment'};
1087 foreach my $line (@$comment) {
1088 if ($line =~ m/^(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
1099 print escapeHTML($line) . "<br/>\n";
1110 my %co = git_read_commit($hash);
1112 die_error(undef, "Unknown commit object.");
1114 my %ad = date_str($co{'author_epoch'}, $co{'author_tz'});
1115 my %cd = date_str($co{'committer_epoch'}, $co{'committer_tz'});
1118 if (defined $co{'parent'}) {
1119 open my $fd, "-|", "$gitbin/git-diff-tree -r $co{'parent'} $hash" || die_error(undef, "Open failed.");
1120 @difftree = map { chomp; $_ } <$fd>;
1121 close $fd || die_error(undef, "Reading diff-tree failed.");
1123 # fake git-diff-tree output for initial revision
1124 open my $fd, "-|", "$gitbin/git-ls-tree -r $hash" || die_error(undef, "Open failed.");
1125 @difftree = map { chomp; "+" . $_ } <$fd>;
1126 close $fd || die_error(undef, "Reading ls-tree failed.");
1129 print "<div class=\"page_nav\">\n" .
1130 $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") .
1131 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit");
1132 if (defined $co{'parent'}) {
1133 print " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff");
1135 print " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, "tree") . "\n" .
1136 "<br/><br/></div>\n";
1137 if (defined $co{'parent'}) {
1139 $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" .
1143 $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" .
1146 print "<div class=\"title_text\">\n" .
1147 "<table cellspacing=\"0\">\n";
1148 print "<tr><td>author</td><td>" . escapeHTML($co{'author'}) . "</td></tr>\n".
1149 "<tr><td></td><td> $ad{'rfc2822'}";
1150 if ($ad{'hour_local'} < 6) {
1151 printf(" (<span style=\"color: #cc0000;\">%02d:%02d</span> %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
1153 printf(" (%02d:%02d %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
1155 print "</td></tr>\n";
1156 print "<tr><td>committer</td><td>" . escapeHTML($co{'committer'}) . "</td></tr>\n";
1157 print "<tr><td></td><td> $cd{'rfc2822'}" . sprintf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}) . "</td></tr>\n";
1158 print "<tr><td>commit</td><td style=\"font-family: monospace;\">$hash</td></tr>\n";
1159 print "<tr><td>tree</td><td style=\"font-family: monospace;\">" .
1160 $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, $co{'tree'}) . "</td></tr>\n";
1161 my $parents = $co{'parents'};
1162 foreach my $par (@$parents) {
1163 print "<tr><td>parent</td><td style=\"font-family: monospace;\">" .
1164 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$par"}, $par) . "</td></tr>\n";
1168 print "<div class=\"page_body\">\n";
1169 my $comment = $co{'comment'};
1172 foreach my $line (@$comment) {
1173 # print only one empty line
1175 if ($empty || $signed) {
1182 if ($line =~ m/^(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
1184 print "<span style=\"color: #888888\">" . escapeHTML($line) . "</span><br/>\n";
1187 print escapeHTML($line) . "<br/>\n";
1191 print "<div class=\"list_head\">\n";
1192 if ($#difftree > 10) {
1193 print(($#difftree + 1) . " files changed:\n");
1196 foreach my $line (@difftree) {
1197 # '*100644->100644 blob 9f91a116d91926df3ba936a80f020a6ab1084d2b->bb90a0c3a91eb52020d0db0e8b4f94d30e02d596 net/ipv4/route.c'
1198 # '+100644 blob 4a83ab6cd565d21ab0385bac6643826b83c2fcd4 arch/arm/lib/bitops.h'
1199 # '*100664->100644 blob b1a8e3dd5556b61dd771d32307c6ee5d7150fa43->b1a8e3dd5556b61dd771d32307c6ee5d7150fa43 show-files.c'
1200 # '*100664->100644 blob d08e895238bac36d8220586fdc28c27e1a7a76d3->d08e895238bac36d8220586fdc28c27e1a7a76d3 update-cache.c'
1201 $line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/;
1207 if ($type eq "blob") {
1210 if (S_ISREG(oct $mode)) {
1211 $mode_chng = sprintf(" with mode: %04o", (oct $mode) & 0777);
1213 print "<div class=\"list\">\n" .
1214 $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"},
1215 escapeHTML($file) . " <span style=\"color: #008000;\">[new " . file_type($mode) . "$mode_chng]</span>") . "\n" .
1217 print "<div class=\"list_link\">\n" .
1218 $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, "blob") . "\n" .
1220 } elsif ($op eq "-") {
1221 print "<div class=\"list\">\n" .
1222 $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"},
1223 escapeHTML($file) . " <span style=\"color: #c00000;\">[deleted " . file_type($mode) . "]</span>") . "\n" .
1225 print "<div class=\"list_link\">\n" .
1226 $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, "blob") . " | " .
1227 $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . "\n" .
1229 } elsif ($op eq "*") {
1230 $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/;
1233 $mode =~ m/^([0-7]{6})->([0-7]{6})$/;
1236 my $mode_chnge = "";
1237 if ($from_mode != $to_mode) {
1238 $mode_chnge = " <span style=\"color: #777777;\">[changed";
1239 if (((oct $from_mode) & S_IFMT) != ((oct $to_mode) & S_IFMT)) {
1240 $mode_chnge .= " from " . file_type($from_mode) . " to " . file_type($to_mode);
1242 if (((oct $from_mode) & 0777) != ((oct $to_mode) & 0777)) {
1243 if (S_ISREG($from_mode) && S_ISREG($to_mode)) {
1244 $mode_chnge .= sprintf(" mode: %04o->%04o", (oct $from_mode) & 0777, (oct $to_mode) & 0777);
1245 } elsif (S_ISREG($to_mode)) {
1246 $mode_chnge .= sprintf(" mode: %04o", (oct $to_mode) & 0777);
1249 $mode_chnge .= "]</span>\n";
1251 print "<div class=\"list\">\n";
1252 if ($to_id ne $from_id) {
1253 print $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file"},
1254 escapeHTML($file) . $mode_chnge) . "\n" .
1257 print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"},
1258 escapeHTML($file) . $mode_chnge) . "\n" .
1261 print "<div class=\"list_link\">\n";
1262 if ($to_id ne $from_id) {
1263 print $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file"}, "diff") . " | ";
1265 print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"}, "blob") . " | " .
1266 $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . "\n" .
1275 mkdir($gittmp, 0700);
1277 if (defined $hash_base && (my %co = git_read_commit($hash_base))) {
1278 print "<div class=\"page_nav\">\n" .
1279 $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") .
1280 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") .
1281 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "commitdiff") .
1282 " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash_base"}, "tree");
1283 if (defined $file_name) {
1284 print " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash_base;f=$file_name"}, "history");
1286 print "<br/><br/>\n" .
1289 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base", -class => "title"}, escapeHTML($co{'title'})) . "\n" .
1292 print "<div class=\"page_nav\">\n" .
1293 "<br/><br/></div>\n" .
1294 "<div class=\"title\">$hash vs $hash_parent</div>\n";
1296 if (defined $file_name) {
1297 print "<div class=\"page_path\">\n" .
1301 print "<div class=\"page_body\">\n" .
1302 "<div class=\"diff_info\">blob:" .
1303 $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$hash_parent;hb=$hash_base;f=$file_name"}, $hash_parent) .
1305 $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$hash;hb=$hash_base;f=$file_name"}, $hash) .
1307 git_diff_html($hash_parent, $file_name || $hash_parent, $hash, $file_name || $hash);
1312 sub git_commitdiff {
1313 mkdir($gittmp, 0700);
1314 my %co = git_read_commit($hash);
1316 die_error(undef, "Unknown commit object.");
1318 open my $fd, "-|", "$gitbin/git-diff-tree -r $co{'parent'} $hash" || die_error(undef, "Open failed.");
1319 my (@difftree) = map { chomp; $_ } <$fd>;
1320 close $fd || die_error(undef, "Reading diff-tree failed.");
1323 print "<div class=\"page_nav\">\n" .
1324 $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") .
1325 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") .
1326 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff") .
1327 " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash"}, "tree") .
1328 "<br/><br/></div>\n";
1330 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" .
1332 print "<div class=\"page_body\">\n";
1333 my $comment = $co{'comment'};
1336 my @log = @$comment;
1338 #while ($log[0] eq "") {
1341 foreach my $line (@log) {
1342 if ($line =~ m/^(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
1353 print escapeHTML($line) . "<br/>\n";
1356 foreach my $line (@difftree) {
1357 # '*100644->100644 blob 8e5f9bbdf4de94a1bc4b4da8cb06677ce0a57716->8da3a306d0c0c070d87048d14a033df02f40a154 Makefile'
1358 $line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/;
1364 if ($type eq "blob") {
1366 print "<div class=\"diff_info\">" . file_type($mode) . ":" .
1367 $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, $id) . "(new)" .
1369 git_diff_html(undef, "/dev/null", $id, "b/$file");
1370 } elsif ($op eq "-") {
1371 print "<div class=\"diff_info\">" . file_type($mode) . ":" .
1372 $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, $id) . "(deleted)" .
1374 git_diff_html($id, "a/$file", undef, "/dev/null");
1375 } elsif ($op eq "*") {
1376 $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/;
1379 $mode =~ m/([0-7]+)->([0-7]+)/;
1382 if ($from_id ne $to_id) {
1383 print "<div class=\"diff_info\">" .
1384 file_type($from_mode) . ":" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file"}, $from_id) .
1386 file_type($to_mode) . ":" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"}, $to_id);
1388 git_diff_html($from_id, "a/$file", $to_id, "b/$file");
1399 if (!defined $hash) {
1400 $hash = git_read_hash("$project/HEAD");
1402 my %co = git_read_commit($hash);
1404 die_error(undef, "Unknown commit object.");
1407 print "<div class=\"page_nav\">\n" .
1408 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | " .
1409 $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff") . " | " .
1410 $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, "tree") .
1414 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" .
1416 print "<div class=\"page_path\">\n" .
1417 "/$file_name<br/>\n";
1419 open my $fd, "-|", "$gitbin/git-rev-list $hash | $gitbin/git-diff-tree -r --stdin $file_name";
1421 while (my $line = <$fd>) {
1422 if ($line =~ m/^([0-9a-fA-F]{40}) /){
1426 if ($line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/ && (defined $commit)) {
1429 if ($file ne $file_name || $type ne "blob") {
1432 my %co = git_read_commit($commit);
1436 print "<div class=\"list\">\n" .
1437 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"},
1438 "<span class=\"age\">$co{'age_string'}</span>" . escapeHTML($co{'title'})) . "\n" .
1440 print "<div class=\"list_link\">\n" .
1441 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") .
1442 " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$commit"}, "tree") .
1443 " | " . $cgi->a({-href => "$my_uri?p=$project;a=blob;hb=$commit;f=$file"}, "blob");
1444 my $blob = git_get_hash_by_path($hash, $file_name);
1445 my $blob_parent = git_get_hash_by_path($commit, $file_name);
1446 if (defined $blob && defined $blob_parent && $blob ne $blob_parent) {
1447 print " | " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$blob;hp=$blob_parent;hb=$commit;f=$file"}, "diff");