]>
Lady’s Gitweb - Gitweb/blob - gitweb.pl
8474a4555b89859f2d35ccc2e51416116326989d73482f75f73e51e0a9068840
3 # This file is licensed under the GPL v2, or a later version
4 # (C) 2005, Kay Sievers <kay.sievers@vrfy.org>
5 # (C) 2005, Christian Gierke <ch@gierke.de>
9 use CGI
qw(:standard :escapeHTML);
10 use CGI
::Carp
qw(fatalsToBrowser);
13 my $gitbin = "/home/kay/bin/git";
14 my $gitroot = "/home/kay/public_html";
16 my $myself = $cgi->url(-relative
=> 1);
18 my $project = $cgi->param("project") || "";
19 my $action = $cgi->param("action") || "";
20 my $hash = $cgi->param("hash") || "";
21 my $parent = $cgi->param("parent") || "";
22 my $view_back = $cgi->param("view_back") || 60*60*24;
23 my $projectroot = "$gitroot/$project";
24 $ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/.git/objects";
26 $hash =~ s/[^0-9a-fA-F]//g;
27 $parent =~ s/[^0-9a-fA-F]//g;
28 $project =~ s/[^0-9a-zA-Z\-\._]//g;
31 print $cgi->header(-type
=> 'text/html; charset: utf-8');
33 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
36 <title>git - $project $action</title>
37 <style type="text/css">
38 body { font-family: sans-serif; font-size: 12px; margin:25px; }
39 div.body { border-width:1px; border-style:solid; border-color:#D9D8D1; }
40 div.head1 { font-size:20px; padding:8px; background-color: #D9D8D1; font-weight:bold; }
41 div.head1 a:visited { color:#0000cc; }
42 div.head1 a:hover { color:#880000; }
43 div.head1 a:active { color:#880000; }
44 div.head2 { padding:8px; }
45 div.head2 a:visited { color:#0000cc; }
46 div.head2 a:hover { color:#880000; }
47 div.head2 a:active { color:#880000; }
48 div.main { padding:8px; font-family: sans-serif; font-size: 12px; }
49 table { padding:0px; margin:0px; width:100%; }
50 tr { vertical-align:top; }
51 td { padding:8px; margin:0px; font-family: sans-serif; font-size: 12px; }
52 td.head1 { background-color: #D9D8D1; font-weight:bold; }
53 td.head1 a { color:#000000; text-decoration:none; }
54 td.head1 a:hover { color:#880000; text-decoration:underline; }
55 td.head1 a:visited { color:#000000; }
56 td.head2 { background-color: #EDECE6; font-family: monospace; font-size:12px; }
57 td.head3 { background-color: #EDECE6; font-size:10px; }
58 div.add { color: #008800; }
59 div.subtract { color: #CC0000; }
60 div.diff_head { color: #000099; }
61 div.diff_head a:visited { color:#0000cc; }
62 div.diff_line { color: #990099; }
64 a:hover { color:#880000; }
65 a:visited { color:#880000; }
66 a:active { color:#880000; }
71 print "<div class=\"body\">\n";
72 print "<div class=\"head1\">";
73 print "<a href=\"http://kernel.org/pub/software/scm/git/\"><img src=\"git_logo.png\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/></a>";
74 print $cgi->a({-href
=> "$myself"}, "projects");
76 print " / " . $cgi->a({-href
=> "$myself?project=$project;action=log;view_back=" . 60*60*24}, $project);
86 print $cgi->end_html();
90 my $old_name = shift || "/dev/null";
91 my $new_name = shift || "/dev/null";
95 my $tmp_old = "/dev/null";
96 my $tmp_new = "/dev/null";
97 my $old_label = "/dev/null";
98 my $new_label = "/dev/null";
100 # create temp from-file
102 open my $fd2, "> $gittmp/$old";
103 open my $fd, "-|", "$gitbin/cat-file", "blob", $old;
104 while (my $line = <$fd>) {
109 $tmp_old = "$gittmp/$old";
110 $old_label = "a/$old_name";
115 open my $fd2, "> $gittmp/$new";
116 open my $fd, "-|", "$gitbin/cat-file", "blob", $new;
117 while (my $line = <$fd>) {
122 $tmp_new = "$gittmp/$new";
123 $new_label = "a/$new_name";
126 open my $fd, "-|", "/usr/bin/diff", "-L", $old_label, "-L", $new_label, "-u", "-p", $tmp_old, $tmp_new;
127 print '<div class="diff_head">===== ';
129 print $cgi->a({-href
=> "$myself?project=$project;action=blob;hash=$old"}, $old);
135 print $cgi->a({-href
=> "$myself?project=$project;action=blob;hash=$new"}, $new);
139 print ' =====</div>';
140 while (my $line = <$fd>) {
141 my $char = substr($line,0,1);
142 print '<div class="add">' if $char eq '+';
143 print '<div class="subtract">' if $char eq '-';
144 print '<div class="diff_line">' if $char eq '@';
145 print escapeHTML
($line);
146 print '</div>' if $char eq '+' or $char eq '-' or $char eq '@';
149 unlink("$gittmp/$new");
150 unlink("$gittmp/$old");
153 if ($project eq "") {
154 open my $fd, "-|", "ls", "-1", $gitroot;
155 my (@path) = map { chomp; $_ } <$fd>;
158 print "<br/><br/><div class=\"main\">\n";
159 foreach my $line (@path) {
160 if (-e
"$gitroot/$line/.git/HEAD") {
161 print $cgi->a({-href
=> "$myself?project=$line"}, $line) . "<br/>\n";
170 print $cgi->redirect("$myself?project=$project;action=log;view_back=$view_back");
174 if ($action eq "blob") {
176 print "<br/><br/><div class=\"main\">\n";
178 open my $fd, "-|", "$gitbin/cat-file", "blob", $hash;
180 while (my $line = <$fd>) {
182 print "$nr\t" . escapeHTML
($line);;
188 } elsif ($action eq "tree") {
190 open my $fd, "$projectroot/.git/HEAD";
196 open my $fd, "-|", "$gitbin/ls-tree", $hash;
197 my (@entries) = map { chomp; $_ } <$fd>;
200 print "<br/><br/><div class=\"main\">\n";
202 foreach my $line (@entries) {
203 #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c'
204 $line =~ m/^([0-9]+)\t(.*)\t(.*)\t(.*)$/;
208 if ($t_type eq "blob") {
209 print "BLOB\t" . $cgi->a({-href
=> "$myself?project=$project;action=blob;hash=$3"}, $4) . "\n";
210 } elsif ($t_type eq "tree") {
211 print "TREE\t" . $cgi->a({-href
=> "$myself?project=$project;action=tree;hash=$3"}, $4) . "\n";
217 } elsif ($action eq "log" || $action eq "show_log" ) {
218 open my $fd, "$projectroot/.git/HEAD";
222 open $fd, "-|", "$gitbin/rev-tree", $head;
223 my (@revtree) = map { chomp; $_ } <$fd>;
226 print "<div class=\"head2\">\n";
228 print $cgi->a({-href
=> "$myself?project=$project;action=log;view_back=" . 60*60*24}, "last day") . " | ";
229 print $cgi->a({-href
=> "$myself?project=$project;action=log;view_back=" . 60*60*24*7}, "week") . " | ";
230 print $cgi->a({-href
=> "$myself?project=$project;action=log;view_back=" . 60*60*24*30}, "month") . " | ";
231 print $cgi->a({-href
=> "$myself?project=$project;action=log;view_back=" . 60*60*24*365}, "year") . " | ";
232 print $cgi->a({-href
=> "$myself?project=$project;action=log;view_back=-1"}, "all") . "<br/>\n";
233 print "<br/><br/>\n";
235 print "<table cellspacing=\"0\" class=\"log\">\n";
236 foreach my $rev (reverse sort @revtree) {
237 last if !($rev =~ m/^([0-9]+) ([0-9a-fA-F]+).* ([0-9a-fA-F]+)/);
248 my $committer_timezone;
252 open my $fd, "-|", "$gitbin/cat-file", "commit", $commit;
253 while (my $line = <$fd>) {
256 if ($line =~ m/^tree (.*)$/) {
258 } elsif ($line =~ m/^parent (.*)$/) {
260 } elsif ($line =~ m/^committer (.*>) ([0-9]+) (.*)$/) {
262 $committer_time = $2;
263 $committer_timezone = $3;
264 } elsif ($line =~ m/^author (.*>) ([0-9]+) (.*)$/) {
267 $author_timezone = $3;
268 $author =~ m/^(.*) </;
273 $shortlog = escapeHTML
($shortlog);
274 $comment = $shortlog . "<br/>";
275 while (my $line = <$fd>) {
277 $comment .= escapeHTML
($line) . "<br/>\n";
280 my $age = time-
$committer_time;
281 last if ($view_back > 0 && $age > $view_back);
284 if ($age > 60*60*24*365*2) {
285 $age_string = int $age/60/60/24/365;
286 $age_string .= " years ago";
287 } elsif ($age > 60*60*24*365/12*2) {
288 $age_string = int $age/60/60/24/365/12;
289 $age_string .= " months ago";
290 } elsif ($age > 60*60*24*7*2) {
291 $age_string = int $age/60/60/24/7;
292 $age_string .= " weeks ago";
293 } elsif ($age > 60*60*24*2) {
294 $age_string = int $age/60/60/24;
295 $age_string .= " days ago";
296 } elsif ($age > 60*60*2) {
297 $age_string = int $age/60/60;
298 $age_string .= " hours ago";
299 } elsif ($age > 60*2) {
300 $age_string = int $age/60;
301 $age_string .= " minutes ago";
304 print "<td class=\"head1\">" . $age_string . "</td>\n";
305 print "<td class=\"head1\">" . $cgi->a({-href
=> "$myself?project=$project;action=commit;hash=$commit;parent=$parent"}, $shortlog) . "</td>";
308 print "<td class=\"head3\">";
309 print $cgi->a({-href
=> "$myself?project=$project;action=diffs;hash=$commit;parent=$parent"}, "view diff") . "<br/>\n";
310 print $cgi->a({-href
=> "$myself?project=$project;action=commit;hash=$commit;parent=$parent"}, "view commit") . "<br/>\n";
311 print $cgi->a({-href
=> "$myself?project=$project;action=tree;hash=$tree"}, "view tree") . "<br/>\n";
313 print "<td class=\"head2\">\n";
314 print "author " . escapeHTML
($author) . " [" . gmtime($author_time) . " " . $author_timezone . "]<br/>\n";
315 print "committer " . escapeHTML
($committer) . " [" . gmtime($committer_time) . " " . $committer_timezone . "]<br/>\n";
316 print "commit $commit<br/>\n";
317 print "tree $tree<br/>\n";
318 foreach my $par (@parents) {
319 print "parent $par<br/>\n";
326 print "$comment<br/><br/>\n";
332 } elsif ($action eq "commit") {
333 open my $fd, "-|", "$gitbin/diff-tree", "-r", $parent, $hash;
334 my (@difftree) = map { chomp; $_ } <$fd>;
338 print "<div class=\"head2\">\n";
339 print "view " . $cgi->a({-href
=> "$myself?project=$project;action=diffs;hash=$hash;parent=$parent"}, "diff") . "<br/><br/>\n";
341 foreach my $line (@difftree) {
342 # '*100644->100644 blob 9f91a116d91926df3ba936a80f020a6ab1084d2b->bb90a0c3a91eb52020d0db0e8b4f94d30e02d596 net/ipv4/route.c'
343 # '+100644 blob 4a83ab6cd565d21ab0385bac6643826b83c2fcd4 arch/arm/lib/bitops.h'
344 $line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/;
350 if ($type eq "blob") {
352 print "NEW\t" . $cgi->a({-href
=> "$myself?project=$project;action=blob;hash=$id"}, $file) . "\n";
353 } elsif ($op eq "-") {
354 print "DEL\t" . $cgi->a({-href
=> "$myself?project=$project;action=blob;hash=$id"}, $file) . "\n";
355 } elsif ($op eq "*") {
356 $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/;
359 print "CHANGED\t" . $cgi->a({-href
=> "$myself?project=$project;action=diff;hash=$old;parent=$new"}, $file) . "\n";
366 } elsif ($action eq "diff") {
368 print "<br/><br/><div class=\"main\">\n";
370 git_diff
($hash, $parent, $hash, $parent);
374 } elsif ($action eq "diffs") {
375 open my $fd, "-|", "$gitbin/diff-tree", "-r", $parent, $hash;
376 my (@difftree) = map { chomp; $_ } <$fd>;
380 print "<div class=\"head2\">\n";
381 print "view " . $cgi->a({-href
=> "$myself?project=$project;action=commit;hash=$hash;parent=$parent"}, "commit") . "<br/><br/>\n";
383 foreach my $line (@difftree) {
384 # '*100644->100644 blob 8e5f9bbdf4de94a1bc4b4da8cb06677ce0a57716->8da3a306d0c0c070d87048d14a033df02f40a154 Makefile'
385 $line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/;
391 if ($type eq "blob") {
393 git_diff
("", $file, "", $id);
394 } elsif ($op eq "-") {
395 git_diff
($file, "", $id, "");
396 } elsif ($op eq "*") {
397 $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/;
398 git_diff
($file, $file, $1, $2);
407 print "<br/><br/><div class=\"main\">\n";
408 print "unknown action\n";
This page took 0.945314 seconds and 3 git commands to generate.