643787f1824093504b631edd259a8e36036956f7
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 = "048";
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_time_epoch'} = $2;
134 $co{'author_timezone'} = $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_time_epoch'} = $2;
140 $co{'committer_timezone'} = $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{'rfc2822_local'} = sprintf "%s, %d %s %4d %02d:%02d:%02d %s", $days[$wday], $mday, $months[$mon], 1900+$year, $hour ,$min, $sec, $tz;
258 return %date;
259}
260
261if ($action eq "git-logo.png") {
262 print $cgi->header(-type => 'image/png', -expires => '+1d');
263 print "\211\120\116\107\015\012\032\012\000\000\000\015\111\110\104\122".
264 "\000\000\000\110\000\000\000\033\004\003\000\000\000\055\331\324".
265 "\055\000\000\000\030\120\114\124\105\377\377\377\140\140\135\260".
266 "\257\252\000\200\000\316\315\307\300\000\000\350\350\346\367\367".
267 "\366\225\014\247\107\000\000\000\163\111\104\101\124\050\317\143".
268 "\110\147\040\004\112\134\030\012\010\052\142\123\141\040\002\010".
269 "\015\151\105\254\241\241\001\060\014\223\140\066\046\122\221\261".
270 "\001\021\326\341\125\144\154\154\314\154\154\014\242\014\160\052".
271 "\142\006\052\301\142\035\263\001\002\123\244\010\350\000\003\030".
272 "\046\126\021\324\341\040\227\033\340\264\016\065\044\161\051\202".
273 "\231\060\270\223\012\021\271\105\210\301\215\240\242\104\041\006".
274 "\047\101\202\100\205\301\105\211\040\160\001\000\244\075\041\305".
275 "\022\034\232\376\000\000\000\000\111\105\116\104\256\102\140\202";
276 exit;
277}
278
279# show list of default projects
280if ($project eq "") {
281 opendir(my $fd, "$projectroot/$defaultprojects");
282 my (@path) = sort grep(!/^\./, readdir($fd));
283 closedir($fd);
284 git_header_html();
285 print "<div class=\"page_body\">\n";
286 print "<br/><br/>\n";
287 foreach my $line (@path) {
288 if (-e "$projectroot/$defaultprojects/$line/.git/HEAD") {
289 print $cgi->a({-href => "$my_uri?p=$defaultprojects/$line;a=log"}, "$defaultprojects/$line") . "<br/>\n";
290 }
291 }
292 print "<br/></div>";
293 git_footer_html();
294 exit;
295}
296
297if ($action eq "") {
298 $action = "log";
299}
300
301if ($action eq "blob") {
302 git_header_html();
303 print "<div class=\"page_body\"><pre><br/><br/>\n";
304 open my $fd, "-|", "$gitbin/cat-file blob $hash";
305 my $nr;
306 while (my $line = <$fd>) {
307 $nr++;
308 printf "<span style =\"color: #999999;\">%4i\t</span>%s", $nr, escapeHTML($line);;
309 }
310 close $fd;
311 print "<br/><br/></pre>\n";
312 print "</div>";
313 git_footer_html();
314} elsif ($action eq "tree") {
315 if ($hash eq "") {
316 $hash = git_head($project);
317 }
318 open my $fd, "-|", "$gitbin/ls-tree $hash";
319 my (@entries) = map { chomp; $_ } <$fd>;
320 close $fd;
321 git_header_html();
322 print "<div class=\"page_body\">\n";
323 print "<br/><pre>\n";
324 foreach my $line (@entries) {
325 #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c'
326 $line =~ m/^([0-9]+)\t(.*)\t(.*)\t(.*)$/;
327 my $t_mode = $1;
328 my $t_type = $2;
329 my $t_hash = $3;
330 my $t_name = $4;
331 if ($t_type eq "blob") {
332 print mode_str($t_mode). " " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash"}, $t_name) . "\n";
333 } elsif ($t_type eq "tree") {
334 print mode_str($t_mode). " " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$t_hash"}, $t_name) . "\n";
335 }
336 }
337 print "</pre>\n";
338 print "<br/></div>";
339 git_footer_html();
340} elsif ($action eq "log" || $action eq "rss") {
341 open my $fd, "-|", "$gitbin/rev-list " . git_head($project);
342 my (@revtree) = map { chomp; $_ } <$fd>;
343 close $fd;
344
345 if ($action eq "log") {
346 git_header_html();
347 print "<div class=\"page_nav\">\n";
348 print "view ";
349 print $cgi->a({-href => "$my_uri?p=$project;a=log"}, "last day") . " | \n" .
350 $cgi->a({-href => "$my_uri?p=$project;a=log;t=7"}, "week") . " | \n" .
351 $cgi->a({-href => "$my_uri?p=$project;a=log;t=31"}, "month") . " | \n" .
352 $cgi->a({-href => "$my_uri?p=$project;a=log;t=365"}, "year") . " | \n" .
353 $cgi->a({-href => "$my_uri?p=$project;a=log;t=0"}, "all") . "<br/>\n";
354 print "<br/><br/>\n" .
355 "</div>\n";
356 } elsif ($action eq "rss") {
357 print $cgi->header(-type => 'text/xml', -charset => 'utf-8');
358 print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n".
359 "<rss version=\"0.91\">\n";
360 print "<channel>\n";
361 print "<title>$project</title>\n".
362 "<link> " . $my_url . "/$project/log</link>\n".
363 "<description>$project log</description>\n".
364 "<language>en</language>\n";
365 }
366
367 for (my $i = 0; $i <= $#revtree; $i++) {
368 my $commit = $revtree[$i];
369 my %co = git_commit($commit);
370 my %ad = date_str($co{'author_time_epoch'});
371 my $age = time - $co{'committer_time_epoch'};
372 my $age_string;
373 if ($age > 60*60*24*365*2) {
374 $age_string = int $age/60/60/24/365;
375 $age_string .= " years ago";
376 } elsif ($age > 60*60*24*365/12*2) {
377 $age_string = int $age/60/60/24/365/12;
378 $age_string .= " months ago";
379 } elsif ($age > 60*60*24*7*2) {
380 $age_string = int $age/60/60/24/7;
381 $age_string .= " weeks ago";
382 } elsif ($age > 60*60*24*2) {
383 $age_string = int $age/60/60/24;
384 $age_string .= " days ago";
385 } elsif ($age > 60*60*2) {
386 $age_string = int $age/60/60;
387 $age_string .= " hours ago";
388 } elsif ($age > 60*2) {
389 $age_string = int $age/60;
390 $age_string .= " minutes ago";
391 }
392 if ($action eq "log") {
393 if ($time_back > 0 && $age > $time_back*60*60*24) {
394 if ($i == 0) {
395 print "<div class=\"page_body\"> Last change $age_string.<br/><br/></div>\n";
396 }
397 last;
398 }
399 print "<div><a href=\"$my_uri?p=$project;a=commit;h=$commit\" class=\"log_title\">\n" .
400 "<span class=\"log_age\">" . $age_string . "</span>\n" . escapeHTML($co{'title'}) . "</a>\n" .
401 "</div>\n";
402 print "<div class=\"log_head\">\n" .
403 "<div class=\"log_functions\">\n" .
404 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "view commit") . "<br/>\n" .
405 $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "view diff") . "<br/>\n" .
406 "</div>\n" .
407 escapeHTML($co{'author_name'}) . " [" . $ad{'rfc2822'} . "]<br/>\n" .
408 "</div>\n" .
409 "<div class=\"log_body\">\n";
410 my $comment = $co{'comment'};
411 foreach my $line (@$comment) {
412 if ($line =~ m/^(signed-off|acked)-by:/i) {
413 print '<div class="signed_off">' . escapeHTML($line) . "<br/></div>\n";
414 } else {
415 print escapeHTML($line) . "<br/>\n";
416 }
417 }
418 print "<br/><br/>\n" .
419 "</div>\n";
420 } elsif ($action eq "rss") {
421 last if ($i >= 20);
422 print "<item>\n" .
423 "\t<title>" . sprintf("%d %s %02d:%02d", $ad{'mday'}, $ad{'month'}, $ad{'hour'}, $ad{'min'}) . " - " . escapeHTML($co{'title'}) . "</title>\n" .
424 "\t<link> " . $my_url . "?p=$project;a==commit;h=$commit</link>\n" .
425 "\t<description>";
426 my $comment = $co{'comment'};
427 foreach my $line (@$comment) {
428 print escapeHTML($line) . "\n";
429 }
430 print "\t</description>\n" .
431 "</item>\n";
432 }
433 }
434 if ($action eq "log") {
435 git_footer_html();
436 } elsif ($action eq "rss") {
437 print "</channel></rss>";
438 }
439} elsif ($action eq "commit") {
440 my %co = git_commit($hash);
441 my %ad = date_str($co{'author_time_epoch'}, $co{'author_time_zone'});
442 my %cd = date_str($co{'committer_time_epoch'}, $co{'committer_time_zone'});
443 open my $fd, "-|", "$gitbin/diff-tree -r " . $co{'parent'} . " $hash";
444 my (@difftree) = map { chomp; $_ } <$fd>;
445 close $fd;
446
447 git_header_html();
448 print "<div class=\"page_nav\"> view\n" .
449 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | \n" .
450 $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diff") . "\n" .
451 "<br/><br/></div>\n";
452 print "<a class=\"log_title\" href=\"$my_uri?p=$project;a=commitdiff;h=$hash\">$co{'title'}</a>\n";
453 print "<div class=\"log_head\">" .
454 "author " . escapeHTML($co{'author'}) . " [" . $ad{'rfc2822'} . "]<br/>\n";
455 if ($ad{'hour'} < 7 ) { print "<span style=\"color: #990000;\">"; }
456 if ($ad{'hour'} < 7 ) { print "</span>"; }
457 print "committer " . escapeHTML($co{'committer'}) . " [" . $cd{'rfc2822'} . "]<br/>\n" .
458 "commit $hash<br/>\n" .
459 "tree " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'}"}, $co{'tree'}) . "<br/>\n";
460 my $parents = $co{'parents'};
461 foreach my $par (@$parents) {
462 print "parent " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$par"}, $par) . "<br/>\n";
463 }
464 print "</div>\n";
465 print "<div class=\"page_body\">\n";
466 my $comment = $co{'comment'};
467 foreach my $line (@$comment) {
468 if ($line =~ m/(signed-off|acked)-by:/i) {
469 print '<div class="signed_off">' . escapeHTML($line) . "<br/></div>\n";
470 } else {
471 print escapeHTML($line) . "<br/>\n";
472 }
473 }
474 print "<br/><br/>\n";
475 print "<pre>\n";
476 foreach my $line (@difftree) {
477 # '*100644->100644 blob 9f91a116d91926df3ba936a80f020a6ab1084d2b->bb90a0c3a91eb52020d0db0e8b4f94d30e02d596 net/ipv4/route.c'
478 # '+100644 blob 4a83ab6cd565d21ab0385bac6643826b83c2fcd4 arch/arm/lib/bitops.h'
479 $line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/;
480 my $op = $1;
481 my $mode = $2;
482 my $type = $3;
483 my $id = $4;
484 my $file = $5;
485 $mode =~ m/^([0-7]{6})/;
486 my $modestr = mode_str($1);
487 if ($type eq "blob") {
488 if ($op eq "+") {
489 print "$modestr " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$id"}, $file) . " (new)\n";
490 } elsif ($op eq "-") {
491 print "$modestr " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;hp=$id"}, $file) . " (removed)\n";
492 } elsif ($op eq "*") {
493 $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/;
494 my $from = $1;
495 my $to = $2;
496 print "$modestr " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to;hp=$from"}, $file) . "\n";
497 }
498 }
499 }
500 print "</pre>\n" .
501 "<br/></div>";
502 git_footer_html();
503} elsif ($action eq "blobdiff") {
504 git_header_html();
505 print "<div class=\"page_body\"><br/><br/>\n" .
506 "<pre>\n";
507 git_diff_html($hash_parent, $hash, $hash_parent, $hash);
508 print "</pre>\n" .
509 "<br/></div>";
510 git_footer_html();
511} elsif ($action eq "commitdiff") {
512 my %co = git_commit($hash);
513 open my $fd, "-|", "$gitbin/diff-tree -r " . $co{'parent'} . " $hash";
514 my (@difftree) = map { chomp; $_ } <$fd>;
515 close $fd;
516
517 git_header_html();
518 print "<div class=\"page_nav\"> view\n" .
519 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | \n" .
520 $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diff") . "\n" .
521 "<br/><br/></div>\n";
522 print $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "log_title"}, $co{'title'}) ."\n";
523 print "<div class=\"page_body\">\n" .
524 "<pre>\n";
525 foreach my $line (@difftree) {
526 # '*100644->100644 blob 8e5f9bbdf4de94a1bc4b4da8cb06677ce0a57716->8da3a306d0c0c070d87048d14a033df02f40a154 Makefile'
527 $line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/;
528 my $op = $1;
529 my $mode = $2;
530 my $type = $3;
531 my $id = $4;
532 my $file = $5;
533 if ($type eq "blob") {
534 if ($op eq "+") {
535 git_diff_html("", $file, "", $id);
536 } elsif ($op eq "-") {
537 git_diff_html($file, "", $id, "");
538 } elsif ($op eq "*") {
539 $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/;
540 git_diff_html($file, $file, $1, $2);
541 }
542 }
543 }
544 print "<br/></pre>\n";
545 print "</div>";
546 git_footer_html();
547} else {
548 git_header_html();
549 print "<div class=\"page_body\">\n" .
550 "<br/><br/>\n";
551 print "unknown action\n";
552 print "<br/></div>\n";
553 git_footer_html();
554}