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 file is licensed under the GPL v2, or a later version
12 use CGI qw(:standard :escapeHTML);
13 use CGI::Carp qw(fatalsToBrowser);
18 my $projectroot = "/pub/scm";
19 my $home_link = "/git";
20 my $gitbin = "/usr/bin";
21 my $gittmp = "/tmp/gitweb";
22 my $logo_link = "/pub/software/scm/cogito";
23 my $my_url = $cgi->url();
24 my $my_uri = $cgi->url(-absolute => 1);
27 my $projectroot = "/home/kay/public_html/pub/scm";
28 my $home_link = "/~kay/git";
29 my $logo_link = "/~kay/pub/software/scm/cogito";
33 my $project = $cgi->param('p');
34 my $action = $cgi->param('a');
35 my $hash = $cgi->param('h');
36 my $hash_parent = $cgi->param('hp');
37 my $file_name = $cgi->param('f');
38 my $time_back = $cgi->param('t');
39 $ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$project/objects";
42 if (defined($project)) {
43 if ($project =~ /(^|\/)(|\.|\.\.)($|\/)/) {
44 die_error("", "Invalid project parameter.");
46 if (!(-d "$projectroot/$project")) {
47 die_error("", "No such project.");
50 if (defined($file_name) && $file_name =~ /(^|\/)(|\.|\.\.)($|\/)/) {
51 die_error("", "Invalid file parameter.");
53 if (defined($action) && !$action =~ m/^[0-9a-zA-Z\.\-]+$/) {
54 die_error("", "Invalid action parameter.");
56 if (defined($hash) && !($hash =~ m/^[0-9a-fA-F]{40}$/)) {
57 die_error("", "Invalid hash parameter.");
59 if (defined($hash_parent) && !($hash_parent =~ m/^[0-9a-fA-F]{40}$/)) {
60 die_error("", "Invalid parent hash parameter.");
62 if (defined($time_back) && !($time_back =~ m/^[0-9]+$/)) {
63 die_error("", "Invalid time parameter.");
67 my $status = shift || "200 OK";
69 print $cgi->header(-type=>'text/html', -charset => 'utf-8', -status=> $status);
71 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
74 <title>git - $project $action</title>
75 <link rel="alternate" title="$project log" href="$my_uri?p=$project;a=rss" type="application/rss+xml"/>
76 <style type="text/css">
77 body { font-family: sans-serif; font-size: 12px; margin:0px; }
79 a:hover { color:#880000; }
80 a:visited { color:#880000; }
81 a:active { color:#880000; }
83 margin:15px 25px 0px; height:25px; padding:8px;
84 font-size:18px; clear:both; font-weight:bold; background-color: #d9d8d1;
86 div.page_header a:visited { color:#0000cc; }
87 div.page_nav { margin:0px 25px; padding:8px; clear:both; border:solid #d9d8d1; border-width:0px 1px; }
88 div.page_nav a:visited { color:#0000cc; }
90 margin:0px 25px 15px; height:17px; padding:4px; padding-left:8px;
91 clear:both; background-color: #d9d8d1;
93 div.page_footer_text { float:left; color:#888888; font-size:10px;}
94 div.page_body { margin:0px 25px; padding:8px; clear:both; border:solid #d9d8d1; border-width:0px 1px; }
96 display:block; margin:0px 25px; padding:8px; clear:both;
97 font-weight:bold; background-color: #d9d8d1; color:#000000;
100 display:block; margin:0px 25px; padding:6px; clear:both;
101 font-weight:bold; background-color: #d9d8d1; text-decoration:none; color:#000000;
103 a.log_title:hover { background-color: #c9c8c1; }
105 margin:0px 25px; padding:8px; clear:both;
106 border: solid #d9d8d1; border-width:0px 1px; font-family:monospace;
107 background-color: #edece6;
110 margin:0px 25px; padding:8px; padding-left:150px; clear:both;
111 border:solid #d9d8d1; border-width:0px 1px;
113 span.log_age { position:relative; float:left; width:142px; }
114 div.log_link { font-size:10px; font-family:sans-serif; position:relative; float:left; width:142px; }
116 display:block; margin:0px 25px; padding:4px; border:solid #d9d8d1; border-width:0px 1px;
117 font-weight:bold; background-color: #edece6; text-decoration:none; color:#000000;
119 a.list:hover { background-color: #d9d8d1; }
120 div.link { margin:0px 25px; padding:4px 8px; border:solid #d9d8d1; border-width:0px 1px; font-family:sans-serif; font-size:10px; }
121 a.xml_logo { float:right; border:1px solid;
123 border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e; width:35px;
124 color:#ffffff; background-color:#ff6600;
125 font-weight:bold; font-family:sans-serif; text-align:center;
126 font-size:10px; display:block; text-decoration:none;
128 a.xml_logo:hover { background-color:#ee5500; }
133 print "<div class=\"page_header\">\n" .
134 "<a href=\"$logo_link\">" .
135 "<img src=\"$my_uri?a=git-logo.png\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/></a>";
136 print $cgi->a({-href => "$my_uri"}, "projects") . " / ";
137 if ($project ne "") {
138 print $cgi->a({-href => "$my_uri?p=$project;a=log"}, $project);
146 sub git_footer_html {
147 print "<div class=\"page_footer\">";
148 print "<div class=\"page_footer_text\">version $version</div>";
149 if ($project ne '') {
150 print $cgi->a({-href => "$my_uri?p=$project;a=rss", -class => "xml_logo"}, "XML") . "\n";
158 my $status = shift || "403 Forbidden";
159 my $error = shift || "Malformed query, file missing or permission denied";
163 git_header_html($status);
164 print "<div class=\"page_body\">\n" .
167 print "<br/></div>\n";
174 open(my $fd, "$projectroot/$path/HEAD") || die_error("", "Invalid project directory.");;
186 open my $fd, "-|", "$gitbin/git-cat-file commit $commit";
187 while (my $line = <$fd>) {
190 if ($line =~ m/^tree (.*)$/) {
192 } elsif ($line =~ m/^parent (.*)$/) {
194 } elsif ($line =~ m/^author (.*) ([0-9]+) (.*)$/) {
196 $co{'author_epoch'} = $2;
197 $co{'author_tz'} = $3;
198 $co{'author_name'} = $co{'author'};
199 $co{'author_name'} =~ s/ <.*//;
200 } elsif ($line =~ m/^committer (.*) ([0-9]+) (.*)$/) {
201 $co{'committer'} = $1;
202 $co{'committer_epoch'} = $2;
203 $co{'committer_tz'} = $3;
204 $co{'committer_name'} = $co{'committer'};
205 $co{'committer_name'} =~ s/ <.*//;
208 if (!defined($co{'tree'})) { die_error("", "Invalid commit object."); }
209 $co{'parents'} = \@parents;
210 $co{'parent'} = $parents[0];
211 my (@comment) = map { chomp; $_ } <$fd>;
212 $co{'comment'} = \@comment;
213 $co{'title'} = $comment[0];
216 my $age = time - $co{'committer_epoch'};
218 if ($age > 60*60*24*365*2) {
219 $co{'age_string'} = (int $age/60/60/24/365);
220 $co{'age_string'} .= " years ago";
221 } elsif ($age > 60*60*24*365/12*2) {
222 $co{'age_string'} = int $age/60/60/24/365/12;
223 $co{'age_string'} .= " months ago";
224 } elsif ($age > 60*60*24*7*2) {
225 $co{'age_string'} = int $age/60/60/24/7;
226 $co{'age_string'} .= " weeks ago";
227 } elsif ($age > 60*60*24*2) {
228 $co{'age_string'} = int $age/60/60/24;
229 $co{'age_string'} .= " days ago";
230 } elsif ($age > 60*60*2) {
231 $co{'age_string'} = int $age/60/60;
232 $co{'age_string'} .= " hours ago";
233 } elsif ($age > 60*2) {
234 $co{'age_string'} = int $age/60;
235 $co{'age_string'} .= " minutes ago";
241 my $from_name = shift || "/dev/null";
242 my $to_name = shift || "/dev/null";
246 my $from_tmp = "/dev/null";
247 my $to_tmp = "/dev/null";
248 my $from_label = "/dev/null";
249 my $to_label = "/dev/null";
252 # create tmp from-file
254 $from_tmp = "$gittmp/gitweb_" . $$ . "_from";
255 open(my $fd2, "> $from_tmp");
256 open my $fd, "-|", "$gitbin/git-cat-file blob $from";
261 $from_label = "a/$from_name";
266 $to_tmp = "$gittmp/gitweb_" . $$ . "_to";
267 open my $fd2, "> $to_tmp";
268 open my $fd, "-|", "$gitbin/git-cat-file blob $to";
273 $to_label = "b/$to_name";
276 open my $fd, "-|", "/usr/bin/diff -u -p -L $from_label -L $to_label $from_tmp $to_tmp";
277 print "<span style=\"color: #000099;\">===== ";
279 print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$from"}, $from);
285 print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to"}, $to);
289 print " =====</span>\n";
290 while (my $line = <$fd>) {
291 my $char = substr($line,0,1);
292 print '<span style="color: #008800;">' if $char eq '+';
293 print '<span style="color: #CC0000;">' if $char eq '-';
294 print '<span style="color: #990099;">' if $char eq '@';
295 print escapeHTML($line);
296 print '</span>' if $char eq '+' or $char eq '-' or $char eq '@';
309 my $perms = oct shift;
311 if ($perms & 040000) {
312 $modestr .= 'drwxr-xr-x';
314 # git cares only about the executable bit
316 $modestr .= '-rwxr-xr-x';
318 $modestr .= '-rw-r--r--';
326 my $tz = shift || "-0000";
329 my @months = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
330 my @days = ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
331 my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($epoch);
332 $date{'hour'} = $hour;
333 $date{'minute'} = $min;
334 $date{'mday'} = $mday;
335 $date{'day'} = $days[$wday];
336 $date{'month'} = $months[$mon];
337 $date{'rfc2822'} = sprintf "%s, %d %s %4d %02d:%02d:%02d +0000", $days[$wday], $mday, $months[$mon], 1900+$year, $hour ,$min, $sec;
338 $date{'mday-time'} = sprintf "%d %s %02d:%02d", $mday, $months[$mon], $hour ,$min;
340 $tz =~ m/((-|\+)[0-9][0-9])([0-9][0-9])/;
341 my $local = $epoch + (($1 + ($2/60)) * 3600);
342 ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($local);
343 $date{'hour_local'} = $hour;
344 $date{'minute_local'} = $min;
345 $date{'tz_local'} = $tz;
349 if ($action eq "git-logo.png") {
350 print $cgi->header(-type => 'image/png', -expires => '+1d');
351 print "\211\120\116\107\015\012\032\012\000\000\000\015\111\110\104\122".
352 "\000\000\000\110\000\000\000\033\004\003\000\000\000\055\331\324".
353 "\055\000\000\000\030\120\114\124\105\377\377\377\140\140\135\260".
354 "\257\252\000\200\000\316\315\307\300\000\000\350\350\346\367\367".
355 "\366\225\014\247\107\000\000\000\163\111\104\101\124\050\317\143".
356 "\110\147\040\004\112\134\030\012\010\052\142\123\141\040\002\010".
357 "\015\151\105\254\241\241\001\060\014\223\140\066\046\122\221\261".
358 "\001\021\326\341\125\144\154\154\314\154\154\014\242\014\160\052".
359 "\142\006\052\301\142\035\263\001\002\123\244\010\350\000\003\030".
360 "\046\126\021\324\341\040\227\033\340\264\016\065\044\161\051\202".
361 "\231\060\270\223\012\021\271\105\210\301\215\240\242\104\041\006".
362 "\047\101\202\100\205\301\105\211\040\160\001\000\244\075\041\305".
363 "\022\034\232\376\000\000\000\000\111\105\116\104\256\102\140\202";
367 if (!defined($project)) {
368 print $cgi->redirect($home_link);
372 if (!defined($action)) {
376 if (!defined($time_back)) {
380 if ($action eq "blob") {
382 print "<div class=\"page_nav\">\n";
383 print "<br/><br/></div>\n";
384 print "<div class=\"title\">$hash</div>\n";
385 print "<div class=\"page_body\"><pre>\n";
386 open(my $fd, "-|", "$gitbin/git-cat-file blob $hash");
388 while (my $line = <$fd>) {
390 printf "<span style =\"color: #999999;\">%4i\t</span>%s", $nr, escapeHTML($line);;
393 print "<br/></pre>\n";
396 } elsif ($action eq "tree") {
398 $hash = git_head($project);
400 open my $fd, "-|", "$gitbin/git-ls-tree $hash";
401 my (@entries) = map { chomp; $_ } <$fd>;
404 print "<div class=\"page_nav\">\n";
405 print "<br/><br/></div>\n";
406 print "<div class=\"title\">$hash</div>\n";
407 print "<div class=\"page_body\">\n";
408 print "<br/><pre>\n";
409 foreach my $line (@entries) {
410 #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c'
411 $line =~ m/^([0-9]+)\t(.*)\t(.*)\t(.*)$/;
416 if ($t_type eq "blob") {
417 print mode_str($t_mode). " " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash"}, $t_name) . "\n";
418 } elsif ($t_type eq "tree") {
419 print mode_str($t_mode). " " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$t_hash"}, $t_name) . "\n";
425 } elsif ($action eq "log" || $action eq "rss") {
426 open my $fd, "-|", "$gitbin/git-rev-list " . git_head($project);
427 my (@revlist) = map { chomp; $_ } <$fd>;
430 if ($action eq "log") {
432 print "<div class=\"page_nav\">\n";
434 print $cgi->a({-href => "$my_uri?p=$project;a=log"}, "last day") . " | \n" .
435 $cgi->a({-href => "$my_uri?p=$project;a=log;t=7"}, "week") . " | \n" .
436 $cgi->a({-href => "$my_uri?p=$project;a=log;t=31"}, "month") . " | \n" .
437 $cgi->a({-href => "$my_uri?p=$project;a=log;t=365"}, "year") . " | \n" .
438 $cgi->a({-href => "$my_uri?p=$project;a=log;t=0"}, "all") . "<br/>\n";
439 print "<br/><br/>\n" .
441 } elsif ($action eq "rss") {
442 print $cgi->header(-type => 'text/xml', -charset => 'utf-8');
443 print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n".
444 "<rss version=\"0.91\">\n";
446 print "<title>$project</title>\n".
447 "<link> " . $my_url . "/$project/log</link>\n".
448 "<description>$project log</description>\n".
449 "<language>en</language>\n";
452 for (my $i = 0; $i <= $#revlist; $i++) {
453 my $commit = $revlist[$i];
454 my %co = git_commit($commit);
455 my %ad = date_str($co{'author_epoch'});
456 if ($action eq "log") {
457 if ($time_back > 0 && $co{'age'} > $time_back*60*60*24) {
459 print "<div class=\"page_body\"> Last change " . $co{'age_string'} . ".<br/><br/></div>\n";
464 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "log_title"},
465 "<span class=\"log_age\">" . $co{'age_string'} . "</span>" . escapeHTML($co{'title'})) . "\n" .
467 print "<div class=\"log_head\">\n" .
468 "<div class=\"log_link\">\n" .
469 "view " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . " | " .
470 $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "diff") . "<br/>\n" .
472 escapeHTML($co{'author_name'}) . " [" . $ad{'rfc2822'} . "]<br/>\n" .
474 "<div class=\"log_body\">\n";
475 my $comment = $co{'comment'};
476 foreach my $line (@$comment) {
477 last if ($line =~ m/^(signed-off|acked)-by:/i);
478 print escapeHTML($line) . "<br/>\n";
482 } elsif ($action eq "rss") {
485 "\t<title>" . sprintf("%d %s %02d:%02d", $ad{'mday'}, $ad{'month'}, $ad{'hour'}, $ad{'min'}) . " - " . escapeHTML($co{'title'}) . "</title>\n" .
486 "\t<link> " . $my_url . "?p=$project;a=commit;h=$commit</link>\n" .
488 my $comment = $co{'comment'};
489 foreach my $line (@$comment) {
490 print escapeHTML($line) . "\n";
492 print "\t</description>\n" .
496 if ($action eq "log") {
498 } elsif ($action eq "rss") {
499 print "</channel></rss>";
501 } elsif ($action eq "commit") {
502 my %co = git_commit($hash);
503 my %ad = date_str($co{'author_epoch'}, $co{'author_tz'});
504 my %cd = date_str($co{'committer_epoch'}, $co{'committer_tz'});
505 open my $fd, "-|", "$gitbin/git-diff-tree -r " . $co{'parent'} . " $hash";
506 my (@difftree) = map { chomp; $_ } <$fd>;
510 print "<div class=\"page_nav\"> view\n" .
511 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | \n" .
512 $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diffs") . " | \n" .
513 $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash"}, "tree") . "\n" .
514 "<br/><br/></div>\n";
516 $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash", -class => "log_title"}, escapeHTML($co{'title'})) . "\n" .
518 print "<div class=\"log_head\">\n";
519 print "author " . escapeHTML($co{'author'}) . "<br/>\n";
520 print "author-time " . $ad{'rfc2822'};
521 if ($ad{'hour_local'} < 6) { print "<span style=\"color: #cc0000;\">"; }
522 printf(" (%02d:%02d %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
523 if ($ad{'hour_local'} < 6 ) { print "</span>"; }
525 print "committer " . escapeHTML($co{'committer'}) . "<br/>\n";
526 print "commit-time " . $cd{'rfc2822'};
527 printf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'});
529 print "commit   $hash<br/>\n";
530 print "tree  " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'}"}, $co{'tree'}) . "<br/>\n";
531 my $parents = $co{'parents'};
532 foreach my $par (@$parents) {
533 print "parent    " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$par"}, $par) . "<br/>\n";
536 print "<div class=\"page_body\">\n";
537 my $comment = $co{'comment'};
538 foreach my $line (@$comment) {
539 if ($line =~ m/(signed-off|acked)-by:/i) {
540 print "<span style=\"color: #a9a8a1\">" . escapeHTML($line) . "</span><br/>\n";
542 print escapeHTML($line) . "<br/>\n";
545 print "<br/><br/>\n" .
547 foreach my $line (@difftree) {
548 # '*100644->100644 blob 9f91a116d91926df3ba936a80f020a6ab1084d2b->bb90a0c3a91eb52020d0db0e8b4f94d30e02d596 net/ipv4/route.c'
549 # '+100644 blob 4a83ab6cd565d21ab0385bac6643826b83c2fcd4 arch/arm/lib/bitops.h'
550 # '*100664->100644 blob b1a8e3dd5556b61dd771d32307c6ee5d7150fa43->b1a8e3dd5556b61dd771d32307c6ee5d7150fa43 show-files.c'
551 # '*100664->100644 blob d08e895238bac36d8220586fdc28c27e1a7a76d3->d08e895238bac36d8220586fdc28c27e1a7a76d3 update-cache.c'
552 $line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/;
559 if ($type eq "blob") {
561 print "<div class=\"list\">\n" .
562 "$file <span style=\"color: #33cc33;\">[new]</span>\n" .
564 print "<div class=\"link\">\n" .
566 $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, "file") . "<br/><br/>\n" .
568 } elsif ($op eq "-") {
569 print "<div class=\"list\">\n" .
570 "$file <span style=\"color: #cc5555;\">[removed]</span>\n" .
572 print "<div class=\"link\">\n" .
574 $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, "file") . " | " .
575 $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . "<br/><br/>\n" .
577 } elsif ($op eq "*") {
578 $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/;
581 $mode =~ m/^([0-7]{6})->([0-7]{6})$/;
585 $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id", -class => "list"}, $file) . "\n";
586 if ($from_mode != $to_mode) {
587 print "<span style=\"color: #555555;\"> [chmod $mode]</span>";
590 print "<div class=\"link\">\n" .
592 if ($to_id ne $from_id) {
593 print $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id"}, "diff") . " | ";
595 print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id"}, "file") . " | " .
596 $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . "<br/><br/>\n" .
602 } elsif ($action eq "blobdiff") {
604 print "<div class=\"page_nav\">\n";
605 print "<br/><br/></div>\n";
606 print "<div class=\"title\">$hash vs $hash_parent</div>\n";
607 print "<div class=\"page_body\">\n" .
609 git_diff_html($hash_parent, $hash, $hash_parent, $hash);
613 } elsif ($action eq "commitdiff") {
614 my %co = git_commit($hash);
615 open my $fd, "-|", "$gitbin/git-diff-tree -r " . $co{'parent'} . " $hash";
616 my (@difftree) = map { chomp; $_ } <$fd>;
620 print "<div class=\"page_nav\"> view\n" .
621 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | \n" .
622 $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diffs") . " | \n" .
623 $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash"}, "tree") . "\n" .
624 "<br/><br/></div>\n";
626 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "log_title"}, escapeHTML($co{'title'})) . "\n" .
628 print "<div class=\"page_body\">\n" .
630 foreach my $line (@difftree) {
631 # '*100644->100644 blob 8e5f9bbdf4de94a1bc4b4da8cb06677ce0a57716->8da3a306d0c0c070d87048d14a033df02f40a154 Makefile'
632 $line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/;
638 if ($type eq "blob") {
640 git_diff_html("", $file, "", $id);
641 } elsif ($op eq "-") {
642 git_diff_html($file, "", $id, "");
643 } elsif ($op eq "*") {
644 $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/;
646 git_diff_html($file, $file, $1, $2);
651 print "<br/></pre>\n";
654 } elsif ($action eq "history") {
655 if (!(defined($hash))) {
656 $hash = git_head($project);
658 open my $fd, "-|", "$gitbin/git-rev-list $hash";
659 my (@revlist) = map { chomp; $_ } <$fd>;
663 print "<div class=\"page_nav\">\n";
664 print "<br/><br/></div>\n";
665 print "<div class=\"title\">". escapeHTML($file_name) . "</div>\n";
666 print "<div class=\"page_body\">\n" .
669 foreach my $rev (@revlist) {
670 my %co = git_commit($rev);
671 my $parents = $co{'parents'};
673 foreach my $parent (@$parents) {
674 open $fd, "-|", "$gitbin/git-diff-tree -r $parent $rev $file_name";
675 my (@difftree) = map { chomp; $_ } <$fd>;
678 foreach my $line (@difftree) {
679 $line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/;
681 if ($file eq $file_name) {
689 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$rev", -class => "list"},
690 "<span class=\"log_age\">" . $co{'age_string'} . "</span>" . escapeHTML($co{'title'})) . "\n" .
692 print "<div class=\"link\">\n" .
694 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$rev"}, "commit") . " | " .
695 $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$rev"}, "tree") . "<br/><br/>\n" .
701 die_error("", "unknown action");