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