summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 061cc7c)
raw | patch | inline | side by side (parent: 061cc7c)
author | Kay Sievers <kay.sievers@suse.de> | |
Sun, 7 Aug 2005 18:16:07 +0000 (20:16 +0200) | ||
committer | Kay Sievers <kay.sievers@suse.de> | |
Sun, 7 Aug 2005 18:16:07 +0000 (20:16 +0200) |
gitweb.cgi | patch | blob | history |
diff --git a/gitweb.cgi b/gitweb.cgi
index c702c9a2ef3850f47da92adcbfe80365896f4a70..89c3df736f9349170b9f78da37136470436243d6 100755 (executable)
--- a/gitweb.cgi
+++ b/gitweb.cgi
my $cgi = new CGI;
-my $version = "056";
+my $version = "057";
my $projectroot = "/home/kay/public_html/pub/scm";
my $defaultprojects = "linux/kernel/git";
my $gitbin = "/home/kay/bin/git";
my $action = $cgi->param('a');
my $hash = $cgi->param('h');
my $hash_parent = $cgi->param('hp');
+my $file_name = $cgi->param('f');
my $time_back = $cgi->param('t');
$ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$project/objects";
if (defined($project) && $project =~ /(^|\/)(|\.|\.\.)($|\/)/) {
die_error("", "Invalid project parameter.");
}
+if (defined($file_name) && $file_name =~ /(^|\/)(|\.|\.\.)($|\/)/) {
+ die_error("", "Invalid file parameter.");
+}
if (defined($action) && !$action =~ m/^[0-9a-zA-Z\.\-]+$/) {
die_error("", "Invalid action parameter.");
}
}
if (defined($time_back) && !($time_back =~ m/^[0-9]+$/)) {
die_error("", "Invalid time parameter.");
-} else {
- $time_back = 1;
}
sub git_header_html {
exit;
}
-if ($action eq "") {
+if (!defined($action)) {
$action = "log";
}
+if (!defined($time_back)) {
+ $time_back = 1;
+}
+
if ($action eq "blob") {
git_header_html();
print "<div class=\"page_body\"><pre><br/><br/>\n";
git_footer_html();
} elsif ($action eq "log" || $action eq "rss") {
open my $fd, "-|", "$gitbin/rev-list " . git_head($project);
- my (@revtree) = map { chomp; $_ } <$fd>;
+ my (@revlist) = map { chomp; $_ } <$fd>;
close $fd;
if ($action eq "log") {
"<language>en</language>\n";
}
- for (my $i = 0; $i <= $#revtree; $i++) {
- my $commit = $revtree[$i];
+ for (my $i = 0; $i <= $#revlist; $i++) {
+ my $commit = $revlist[$i];
my %co = git_commit($commit);
my %ad = date_str($co{'author_epoch'});
my $age = time - $co{'committer_epoch'};
last if ($i >= 20);
print "<item>\n" .
"\t<title>" . sprintf("%d %s %02d:%02d", $ad{'mday'}, $ad{'month'}, $ad{'hour'}, $ad{'min'}) . " - " . escapeHTML($co{'title'}) . "</title>\n" .
- "\t<link> " . $my_url . "?p=$project;a==commit;h=$commit</link>\n" .
+ "\t<link> " . $my_url . "?p=$project;a=commit;h=$commit</link>\n" .
"\t<description>";
my $comment = $co{'comment'};
foreach my $line (@$comment) {
$id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/;
my $from = $1;
my $to = $2;
- print "$modestr " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to;hp=$from"}, $file) . "\n";
+ print "$modestr " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to;hp=$from"}, $file) . " (" .
+ $cgi->a({-href => "$my_uri?p=$project;a=filerevision;h=$hash;f=$file"}, "history") . ")\n";
}
}
}
print "<br/></pre>\n";
print "</div>";
git_footer_html();
+} elsif ($action eq "filerevision") {
+ open my $fd, "-|", "$gitbin/rev-list $hash";
+ my (@revlist) = map { chomp; $_ } <$fd>;
+ close $fd;
+
+ git_header_html();
+ print "<div class=\"page_body\">\n" .
+ "<pre>\n";
+ foreach my $rev (@revlist) {
+ my %co = git_commit($rev);
+ my $parents = $co{'parents'};
+ foreach my $parent (@$parents) {
+ open $fd, "-|", "$gitbin/diff-tree -r $parent $rev $file_name";
+ my (@difftree) = map { chomp; $_ } <$fd>;
+ close $fd;
+
+ foreach my $line (@difftree) {
+ $line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/;
+ my $file = $5;
+ if ($file eq $file_name) {
+ print $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$rev"}, $rev) . " (" . $co{'title'} .")\n";
+ last;
+ }
+ }
+ }
+ }
+ print "<br/></pre>\n";
+ print "</div>";
+ git_footer_html();
} else {
die_error("", "unknown action");
}