096786b932b5399cb4a50db3f66640c07e57132f
1#!/usr/bin/perl
2
3# gitweb.pl - simple web interface to track changes in git repositories
4#
5# (C) 2005, Kay Sievers <kay.sievers@vrfy.org>
6# (C) 2005, Christian Gierke <ch@gierke.de>
7#
8# This file is licensed under the GPL v2, or a later version
9
10use strict;
11use warnings;
12use CGI qw(:standard :escapeHTML);
13use CGI::Carp qw(fatalsToBrowser);
14
15my $cgi = new CGI;
16
17my $version = "049";
18my $projectroot = "/";
19my $defaultprojects = "home/kay/public_html";
20my $gitbin = "/home/kay/bin/git";
21my $gittmp = "/tmp";
22my $my_url = $cgi->url();
23my $my_uri = $cgi->url(-absolute => 1);
24
25my $project = $cgi->param('p');
26my $action = $cgi->param('a');
27my $hash = $cgi->param('h');
28my $hash_parent = $cgi->param('hp');
29my $time_back = $cgi->param('t');
30if (!(defined($time_back))) {
31 $time_back = 1;
32}
33$ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$project/.git/objects";
34
35# sanitize input
36$action =~ s/[^0-9a-zA-Z\.\-]//g;
37$project =~ s/\/\.//g;
38$project =~ s/^\/+//g;
39$project =~ s/\/+$//g;
40$project =~ s/|//g;
41$hash =~ s/[^0-9a-fA-F]//g;
42$hash_parent =~ s/[^0-9a-fA-F]//g;
43$time_back =~ s/[^0-9]+//g;
44
45sub git_header_html {
46 print $cgi->header(-type => 'text/html', -charset => 'utf-8');
47print <<EOF;
48<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
49<html>
50<head>
51 <title>git - $project $action</title>
52 <link rel="alternate" title="$project log" href="$my_uri?p=$project;a=rss" type="application/rss+xml"/>
53 <style type="text/css">
54 body { font-family: sans-serif; font-size: 12px; margin:0px; }
55 a { color:#0000cc; }
56 a:hover { color:#880000; }
57 a:visited { color:#880000; }
58 a:active { color:#880000; }
59 div.page_header { margin:15px 25px 0px; height:25px; padding:8px; font-size:18px; clear:both; font-weight:bold; background-color: #d9d8d1; }
60 div.page_header a:visited { color:#0000cc; }
61 div.page_nav { margin:0px 25px; padding:8px; clear:both; border: solid #d9d8d1; border-width:0px 1px; }
62 div.page_nav a:visited { color:#0000cc; }
63 div.page_footer { margin:0px 25px 15px; height:17px; padding:4px; padding-left:8px; clear:both; background-color: #d9d8d1; }
64 div.page_footer_text { float:left; color:#888888; font-size:10px;}
65 div.page_body { margin:0px 25px; padding:8px; clear:both; border: solid #d9d8d1; border-width:0px 1px; }
66 a.log_title { display:block; margin:0px 25px; padding:8px; clear:both; font-weight:bold; background-color: #d9d8d1; text-decoration:none; color:#000000; }
67 a.log_title:hover { background-color: #c9c8c1; }
68 a.xml_logo { float:right; border:1px solid;
69 border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e; width:35px; color:#ffffff; background-color:#ff6600;
70 font-weight:bold; font-family:sans-serif; text-align:center; font-size:11px; display:block; text-decoration:none;
71 }
72 a.xml_logo:hover { background-color:#ee5500; }
73 div.log_head { margin:0px 25px; min-height: 30px; padding:8px; clear:both;
74 border: solid #d9d8d1; border-width:0px 1px; font-family:monospace; background-color: #edece6;
75 }
76 div.log_body { margin:0px 25px; padding:8px; padding-left:150px; clear:both; border: solid #d9d8d1; border-width:0px 1px; }
77 span.log_age { position:relative; float:left; width:142px; }
78 div.log_functions { font-size:10px; font-family:sans-serif; position:relative; float:left; width:142px; }
79 div.signed_off { color: #a9a8a1; }
80 </style>
81</head>
82<body>
83EOF
84 print "<div class=\"page_header\">\n" .
85 "<a href=\"http://kernel.org/pub/software/scm/git/\">" .
86 "<img src=\"$my_uri?a=git-logo.png\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/></a>";
87 if ($defaultprojects ne "") {
88 print $cgi->a({-href => "$my_uri"}, "projects") . " / ";
89 }
90 if ($project ne "") {
91 print $cgi->a({-href => "$my_uri?p=$project;a=log"}, $project);
92 }
93 if ($action ne "") {
94 print " / $action";
95 }
96 print "</div>\n";
97}
98
99sub git_footer_html {
100 print "<div class=\"page_footer\">";
101 print "<div class=\"page_footer_text\">version $version</div>";
102 if ($project ne '') {
103 print $cgi->a({-href => "$my_uri?p=$project;a=rss", -class => "xml_logo"}, "XML") . "\n";
104 }
105 print "</div>";
106 print "</body>\n</html>";
107}
108
109sub git_head {
110 my $path = shift;
111 open my $fd, "$projectroot/$path/.git/HEAD";
112 my $head = <$fd>;
113 close $fd;
114 chomp $head;
115 return $head;
116}
117
118sub git_commit {
119 my $commit = shift;
120 my %co;
121 my @parents;
122
123 open my $fd, "-|", "$gitbin/cat-file commit $commit";
124 while (my $line = <$fd>) {
125 chomp($line);
126 last if $line eq "";
127 if ($line =~ m/^tree (.*)$/) {
128 $co{'tree'} = $1;
129 } elsif ($line =~ m/^parent (.*)$/) {
130 push @parents, $1;
131 } elsif ($line =~ m/^author (.*) ([0-9]+) (.*)$/) {
132 $co{'author'} = $1;
133 $co{'author_epoch'} = $2;
134 $co{'author_tz'} = $3;
135 $co{'author_name'} = $co{'author'};
136 $co{'author_name'} =~ s/ <.*//;
137 } elsif ($line =~ m/^committer (.*) ([0-9]+) (.*)$/) {
138 $co{'committer'} = $1;
139 $co{'committer_epoch'} = $2;
140 $co{'committer_tz'} = $3;
141 $co{'committer_name'} = $co{'committer'};
142 $co{'committer_name'} =~ s/ <.*//;
143 }
144 }
145 $co{'parents'} = \@parents;
146 $co{'parent'} = $parents[0];
147 my (@comment) = map { chomp; $_ } <$fd>;
148 $co{'comment'} = \@comment;
149 $co{'title'} = $comment[0];
150 close $fd;
151 return %co;
152}
153
154sub git_diff_html {
155 my $from_name = shift || "/dev/null";
156 my $to_name = shift || "/dev/null";
157 my $from = shift;
158 my $to = shift;
159
160 my $from_tmp = "/dev/null";
161 my $to_tmp = "/dev/null";
162 my $from_label = "/dev/null";
163 my $to_label = "/dev/null";
164 my $pid = $$;
165
166 # create tmp from-file
167 if ($from ne "") {
168 $from_tmp = "$gittmp/gitweb_" . $$ . "_from";
169 open my $fd2, "> $from_tmp";
170 open my $fd, "-|", "$gitbin/cat-file blob $from";
171 my @file = <$fd>;
172 print $fd2 @file;
173 close $fd2;
174 close $fd;
175 $from_label = "a/$from_name";
176 }
177
178 # create tmp to-file
179 if ($to ne "") {
180 $to_tmp = "$gittmp/gitweb_" . $$ . "_to";
181 open my $fd2, "> $to_tmp";
182 open my $fd, "-|", "$gitbin/cat-file blob $to";
183 my @file = <$fd>;
184 print $fd2 @file;
185 close $fd2;
186 close $fd;
187 $to_label = "b/$to_name";
188 }
189
190 open my $fd, "-|", "/usr/bin/diff -u -p -L $from_label -L $to_label $from_tmp $to_tmp";
191 print "<span style=\"color: #000099;\">===== ";
192 if ($from ne "") {
193 print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$from"}, $from);
194 } else {
195 print $from_name;
196 }
197 print " vs ";
198 if ($to ne "") {
199 print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to"}, $to);
200 } else {
201 print $to_name;
202 }
203 print " =====</span>\n";
204 while (my $line = <$fd>) {
205 my $char = substr($line,0,1);
206 print '<span style="color: #008800;">' if $char eq '+';
207 print '<span style="color: #CC0000;">' if $char eq '-';
208 print '<span style="color: #990099;">' if $char eq '@';
209 print escapeHTML($line);
210 print '</span>' if $char eq '+' or $char eq '-' or $char eq '@';
211 }
212 close $fd;
213
214 if ($from ne "") {
215 unlink("$from_tmp");
216 }
217 if ($to ne "") {
218 unlink("$to_tmp");
219 }
220}
221
222sub mode_str {
223 my $perms = oct shift;
224 my $modestr;
225 if ($perms & 040000) {
226 $modestr .= 'drwxrwxr-x';
227 } else {
228 # git cares only about the executable bit
229 if ($perms & 0100) {
230 $modestr .= '-rwxrwxr-x';
231 } else {
232 $modestr .= '-rw-rw-r--';
233 };
234 }
235 return $modestr;
236}
237
238sub date_str {
239 my $epoch = shift;
240 my $tz = shift || "-0000";
241
242 my %date;
243 my @months = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
244 my @days = ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
245 my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($epoch);
246 $date{'hour'} = $hour;
247 $date{'minute'} = $min;
248 $date{'mday'} = $mday;
249 $date{'day'} = $days[$wday];
250 $date{'month'} = $months[$mon];
251 $date{'rfc2822'} = sprintf "%s, %d %s %4d %02d:%02d:%02d +0000", $days[$wday], $mday, $months[$mon], 1900+$year, $hour ,$min, $sec;
252 $date{'mday-time'} = sprintf "%d %s %02d:%02d", $mday, $months[$mon], $hour ,$min;
253
254 $tz =~ m/((-|\+)[0-9][0-9])([0-9][0-9])/;
255 my $local = $epoch + (($1 + ($2/60)) * 3600);
256 ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($local);
257 $date{'hour_local'} = $hour;
258 $date{'minute_local'} = $min;
259 $date{'tz_local'} = $tz;
260 return %date;
261}
262
263if ($action eq "git-logo.png") {
264 print $cgi->header(-type => 'image/png', -expires => '+1d');
265 print "\211\120\116\107\015\012\032\012\000\000\000\015\111\110\104\122".
266 "\000\000\000\110\000\000\000\033\004\003\000\000\000\055\331\324".
267 "\055\000\000\000\030\120\114\124\105\377\377\377\140\140\135\260".
268 "\257\252\000\200\000\316\315\307\300\000\000\350\350\346\367\367".
269 "\366\225\014\247\107\000\000\000\163\111\104\101\124\050\317\143".
270 "\110\147\040\004\112\134\030\012\010\052\142\123\141\040\002\010".
271 "\015\151\105\254\241\241\001\060\014\223\140\066\046\122\221\261".
272 "\001\021\326\341\125\144\154\154\314\154\154\014\242\014\160\052".
273 "\142\006\052\301\142\035\263\001\002\123\244\010\350\000\003\030".
274 "\046\126\021\324\341\040\227\033\340\264\016\065\044\161\051\202".
275 "\231\060\270\223\012\021\271\105\210\301\215\240\242\104\041\006".
276 "\047\101\202\100\205\301\105\211\040\160\001\000\244\075\041\305".
277 "\022\034\232\376\000\000\000\000\111\105\116\104\256\102\140\202";
278 exit;
279}
280
281# show list of default projects
282if ($project eq "") {
283 opendir(my $fd, "$projectroot/$defaultprojects");
284 my (@path) = sort grep(!/^\./, readdir($fd));
285 closedir($fd);
286 git_header_html();
287 print "<div class=\"page_body\">\n";
288 print "<br/><br/>\n";
289 foreach my $line (@path) {
290 if (-e "$projectroot/$defaultprojects/$line/.git/HEAD") {
291 print $cgi->a({-href => "$my_uri?p=$defaultprojects/$line;a=log"}, "$defaultprojects/$line") . "<br/>\n";
292 }
293 }
294 print "<br/></div>";
295 git_footer_html();
296 exit;
297}
298
299if ($action eq "") {
300 $action = "log";
301}
302
303if ($action eq "blob") {
304 git_header_html();
305 print "<div class=\"page_body\"><pre><br/><br/>\n";
306 open my $fd, "-|", "$gitbin/cat-file blob $hash";
307 my $nr;
308 while (my $line = <$fd>) {
309 $nr++;
310 printf "<span style =\"color: #999999;\">%4i\t</span>%s", $nr, escapeHTML($line);;
311 }
312 close $fd;
313 print "<br/><br/></pre>\n";
314 print "</div>";
315 git_footer_html();
316} elsif ($action eq "tree") {
317 if ($hash eq "") {
318 $hash = git_head($project);
319 }
320 open my $fd, "-|", "$gitbin/ls-tree $hash";
321 my (@entries) = map { chomp; $_ } <$fd>;
322 close $fd;
323 git_header_html();
324 print "<div class=\"page_body\">\n";
325 print "<br/><pre>\n";
326 foreach my $line (@entries) {
327 #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c'
328 $line =~ m/^([0-9]+)\t(.*)\t(.*)\t(.*)$/;
329 my $t_mode = $1;
330 my $t_type = $2;
331 my $t_hash = $3;
332 my $t_name = $4;
333 if ($t_type eq "blob") {
334 print mode_str($t_mode). " " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash"}, $t_name) . "\n";
335 } elsif ($t_type eq "tree") {
336 print mode_str($t_mode). " " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$t_hash"}, $t_name) . "\n";
337 }
338 }
339 print "</pre>\n";
340 print "<br/></div>";
341 git_footer_html();
342} elsif ($action eq "log" || $action eq "rss") {
343 open my $fd, "-|", "$gitbin/rev-list " . git_head($project);
344 my (@revtree) = map { chomp; $_ } <$fd>;
345 close $fd;
346
347 if ($action eq "log") {
348 git_header_html();
349 print "<div class=\"page_nav\">\n";
350 print "view ";
351 print $cgi->a({-href => "$my_uri?p=$project;a=log"}, "last day") . " | \n" .
352 $cgi->a({-href => "$my_uri?p=$project;a=log;t=7"}, "week") . " | \n" .
353 $cgi->a({-href => "$my_uri?p=$project;a=log;t=31"}, "month") . " | \n" .
354 $cgi->a({-href => "$my_uri?p=$project;a=log;t=365"}, "year") . " | \n" .
355 $cgi->a({-href => "$my_uri?p=$project;a=log;t=0"}, "all") . "<br/>\n";
356 print "<br/><br/>\n" .
357 "</div>\n";
358 } elsif ($action eq "rss") {
359 print $cgi->header(-type => 'text/xml', -charset => 'utf-8');
360 print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n".
361 "<rss version=\"0.91\">\n";
362 print "<channel>\n";
363 print "<title>$project</title>\n".
364 "<link> " . $my_url . "/$project/log</link>\n".
365 "<description>$project log</description>\n".
366 "<language>en</language>\n";
367 }
368
369 for (my $i = 0; $i <= $#revtree; $i++) {
370 my $commit = $revtree[$i];
371 my %co = git_commit($commit);
372 my %ad = date_str($co{'author_epoch'});
373 my $age = time - $co{'committer_epoch'};
374 my $age_string;
375 if ($age > 60*60*24*365*2) {
376 $age_string = int $age/60/60/24/365;
377 $age_string .= " years ago";
378 } elsif ($age > 60*60*24*365/12*2) {
379 $age_string = int $age/60/60/24/365/12;
380 $age_string .= " months ago";
381 } elsif ($age > 60*60*24*7*2) {
382 $age_string = int $age/60/60/24/7;
383 $age_string .= " weeks ago";
384 } elsif ($age > 60*60*24*2) {
385 $age_string = int $age/60/60/24;
386 $age_string .= " days ago";
387 } elsif ($age > 60*60*2) {
388 $age_string = int $age/60/60;
389 $age_string .= " hours ago";
390 } elsif ($age > 60*2) {
391 $age_string = int $age/60;
392 $age_string .= " minutes ago";
393 }
394 if ($action eq "log") {
395 if ($time_back > 0 && $age > $time_back*60*60*24) {
396 if ($i == 0) {
397 print "<div class=\"page_body\"> Last change $age_string.<br/><br/></div>\n";
398 }
399 last;
400 }
401 print "<div><a href=\"$my_uri?p=$project;a=commit;h=$commit\" class=\"log_title\">\n" .
402 "<span class=\"log_age\">" . $age_string . "</span>\n" . escapeHTML($co{'title'}) . "</a>\n" .
403 "</div>\n";
404 print "<div class=\"log_head\">\n" .
405 "<div class=\"log_functions\">\n" .
406 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "view commit") . "<br/>\n" .
407 $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "view diff") . "<br/>\n" .
408 "</div>\n" .
409 escapeHTML($co{'author_name'}) . " [" . $ad{'rfc2822'} . "]<br/>\n" .
410 "</div>\n" .
411 "<div class=\"log_body\">\n";
412 my $comment = $co{'comment'};
413 foreach my $line (@$comment) {
414 if ($line =~ m/^(signed-off|acked)-by:/i) {
415 print '<div class="signed_off">' . escapeHTML($line) . "<br/></div>\n";
416 } else {
417 print escapeHTML($line) . "<br/>\n";
418 }
419 }
420 print "<br/><br/>\n" .
421 "</div>\n";
422 } elsif ($action eq "rss") {
423 last if ($i >= 20);
424 print "<item>\n" .
425 "\t<title>" . sprintf("%d %s %02d:%02d", $ad{'mday'}, $ad{'month'}, $ad{'hour'}, $ad{'min'}) . " - " . escapeHTML($co{'title'}) . "</title>\n" .
426 "\t<link> " . $my_url . "?p=$project;a==commit;h=$commit</link>\n" .
427 "\t<description>";
428 my $comment = $co{'comment'};
429 foreach my $line (@$comment) {
430 print escapeHTML($line) . "\n";
431 }
432 print "\t</description>\n" .
433 "</item>\n";
434 }
435 }
436 if ($action eq "log") {
437 git_footer_html();
438 } elsif ($action eq "rss") {
439 print "</channel></rss>";
440 }
441} elsif ($action eq "commit") {
442 my %co = git_commit($hash);
443 my %ad = date_str($co{'author_epoch'}, $co{'author_tz'});
444 my %cd = date_str($co{'committer_epoch'}, $co{'committer_tz'});
445 open my $fd, "-|", "$gitbin/diff-tree -r " . $co{'parent'} . " $hash";
446 my (@difftree) = map { chomp; $_ } <$fd>;
447 close $fd;
448
449 git_header_html();
450 print "<div class=\"page_nav\"> view\n" .
451 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | \n" .
452 $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diff") . "\n" .
453 "<br/><br/></div>\n";
454 print "<a class=\"log_title\" href=\"$my_uri?p=$project;a=commitdiff;h=$hash\">$co{'title'}</a>\n";
455 print "<div class=\"log_head\">\n";
456 print "author " . escapeHTML($co{'author'}) . "<br/>\n";
457 print "author-time " . $ad{'rfc2822'};
458 if ($ad{'hour_local'} < 6) { print "<span style=\"color: #cc0000;\">"; }
459 printf(" (%02d:%02d %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
460 if ($ad{'hour_local'} < 6 ) { print "</span>"; }
461 print "<br/>\n";
462 print "committer " . escapeHTML($co{'committer'}) . "<br/>\n";
463 print "commit-time " . $ad{'rfc2822'};
464 printf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'});
465 print "<br/>\n";
466 print "commit   $hash<br/>\n";
467 print "tree  " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'}"}, $co{'tree'}) . "<br/>\n";
468 my $parents = $co{'parents'};
469 foreach my $par (@$parents) {
470 print "parent    " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$par"}, $par) . "<br/>\n";
471 }
472 print "</div>\n";
473 print "<div class=\"page_body\">\n";
474 my $comment = $co{'comment'};
475 foreach my $line (@$comment) {
476 if ($line =~ m/(signed-off|acked)-by:/i) {
477 print '<div class="signed_off">' . escapeHTML($line) . "<br/></div>\n";
478 } else {
479 print escapeHTML($line) . "<br/>\n";
480 }
481 }
482 print "<br/><br/>\n";
483 print "<pre>\n";
484 foreach my $line (@difftree) {
485 # '*100644->100644 blob 9f91a116d91926df3ba936a80f020a6ab1084d2b->bb90a0c3a91eb52020d0db0e8b4f94d30e02d596 net/ipv4/route.c'
486 # '+100644 blob 4a83ab6cd565d21ab0385bac6643826b83c2fcd4 arch/arm/lib/bitops.h'
487 $line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/;
488 my $op = $1;
489 my $mode = $2;
490 my $type = $3;
491 my $id = $4;
492 my $file = $5;
493 $mode =~ m/^([0-7]{6})/;
494 my $modestr = mode_str($1);
495 if ($type eq "blob") {
496 if ($op eq "+") {
497 print "$modestr " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$id"}, $file) . " (new)\n";
498 } elsif ($op eq "-") {
499 print "$modestr " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;hp=$id"}, $file) . " (removed)\n";
500 } elsif ($op eq "*") {
501 $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/;
502 my $from = $1;
503 my $to = $2;
504 print "$modestr " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to;hp=$from"}, $file) . "\n";
505 }
506 }
507 }
508 print "</pre>\n" .
509 "<br/></div>";
510 git_footer_html();
511} elsif ($action eq "blobdiff") {
512 git_header_html();
513 print "<div class=\"page_body\"><br/><br/>\n" .
514 "<pre>\n";
515 git_diff_html($hash_parent, $hash, $hash_parent, $hash);
516 print "</pre>\n" .
517 "<br/></div>";
518 git_footer_html();
519} elsif ($action eq "commitdiff") {
520 my %co = git_commit($hash);
521 open my $fd, "-|", "$gitbin/diff-tree -r " . $co{'parent'} . " $hash";
522 my (@difftree) = map { chomp; $_ } <$fd>;
523 close $fd;
524
525 git_header_html();
526 print "<div class=\"page_nav\"> view\n" .
527 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | \n" .
528 $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diff") . "\n" .
529 "<br/><br/></div>\n";
530 print $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "log_title"}, $co{'title'}) ."\n";
531 print "<div class=\"page_body\">\n" .
532 "<pre>\n";
533 foreach my $line (@difftree) {
534 # '*100644->100644 blob 8e5f9bbdf4de94a1bc4b4da8cb06677ce0a57716->8da3a306d0c0c070d87048d14a033df02f40a154 Makefile'
535 $line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/;
536 my $op = $1;
537 my $mode = $2;
538 my $type = $3;
539 my $id = $4;
540 my $file = $5;
541 if ($type eq "blob") {
542 if ($op eq "+") {
543 git_diff_html("", $file, "", $id);
544 } elsif ($op eq "-") {
545 git_diff_html($file, "", $id, "");
546 } elsif ($op eq "*") {
547 $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/;
548 git_diff_html($file, $file, $1, $2);
549 }
550 }
551 }
552 print "<br/></pre>\n";
553 print "</div>";
554 git_footer_html();
555} else {
556 git_header_html();
557 print "<div class=\"page_body\">\n" .
558 "<br/><br/>\n";
559 print "unknown action\n";
560 print "<br/></div>\n";
561 git_footer_html();
562}