# (C) 2005, Kay Sievers <kay.sievers@vrfy.org>
# (C) 2005, Christian Gierke <ch@gierke.de>
#
-# This program is licensed under the GPL v2, or a later version
+# This program is licensed under the GPLv2
use strict;
use warnings;
use Fcntl ':mode';
my $cgi = new CGI;
-my $version = "244";
+my $version = "247";
my $my_url = $cgi->url();
my $my_uri = $cgi->url(-absolute => 1);
my $rss_link = "";
if (!defined $action || $action eq "summary") {
git_summary();
exit;
-} elsif ($action eq "branches") {
- git_branches();
+} elsif ($action eq "heads") {
+ git_heads();
exit;
} elsif ($action eq "tags") {
git_tags();
if (!defined $searchtext) {
$searchtext = "";
}
+ my $search_hash;
+ if (defined $hash) {
+ $search_hash = $hash;
+ } else {
+ $search_hash = "HEAD";
+ }
$cgi->param("a", "search");
+ $cgi->param("h", $search_hash);
print $cgi->startform(-method => "get", -action => "$my_uri") .
"<div class=\"search\">\n" .
$cgi->hidden(-name => "p") . "\n" .
$cgi->hidden(-name => "a") . "\n" .
+ $cgi->hidden(-name => "h") . "\n" .
$cgi->textfield(-name => "s", -value => $searchtext) . "\n" .
"</div>" .
$cgi->end_form() . "\n";
print "</table\n>";
}
- my $branchlist = git_read_refs("refs/heads");
- if (defined @$branchlist) {
+ my $headlist = git_read_refs("refs/heads");
+ if (defined @$headlist) {
print "<div>\n" .
- $cgi->a({-href => "$my_uri?p=$project;a=branches", -class => "title"}, "branches") .
+ $cgi->a({-href => "$my_uri?p=$project;a=heads", -class => "title"}, "heads") .
"</div>\n";
my $i = 16;
print "<table cellspacing=\"0\">\n";
my $alternate = 0;
- foreach my $entry (@$branchlist) {
+ foreach my $entry (@$headlist) {
my %tag = %$entry;
if ($alternate) {
print "<tr class=\"dark\">\n";
"</td>\n" .
"</tr>";
} else {
- print "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=branches"}, "...") . "</td>\n" .
+ print "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=heads"}, "...") . "</td>\n" .
"</tr>";
last;
}
git_footer_html();
}
-sub git_branches {
+sub git_heads {
my $head = git_read_hash("$project/HEAD");
git_header_html();
print "<div class=\"page_nav\">\n" .
$hash = git_get_hash_by_path($base, $file_name, "blob");
}
open my $fd, "-|", "$gitbin/git-cat-file blob $hash" or die_error(undef, "Open failed.");
- my $base = $file_name || "";
git_header_html();
if (defined $hash_base && (my %co = git_read_commit($hash_base))) {
print "<div class=\"page_nav\">\n" .
" | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") .
" | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "commitdiff") .
" | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash_base"}, "tree") . "<br/>\n";
- print $cgi->a({-href => "$my_uri?p=$project;a=blob_plain;h=$hash"}, "plain") . "<br/>\n" .
- "</div>\n";
- print "<div>" .
+ if (defined $file_name) {
+ print $cgi->a({-href => "$my_uri?p=$project;a=blob_plain;h=$hash;f=$file_name"}, "plain") . "<br/>\n";
+ } else {
+ print $cgi->a({-href => "$my_uri?p=$project;a=blob_plain;h=$hash"}, "plain") . "<br/>\n";
+ }
+ print "</div>\n".
+ "<div>" .
$cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base", -class => "title"}, escapeHTML($co{'title'})) .
"</div>\n";
} else {
}
sub git_blob_plain {
- print $cgi->header(-type => "text/plain", -charset => 'utf-8');
+ my $save_as = "$hash.txt";
+ if (defined $file_name) {
+ $save_as = $file_name;
+ }
+ print $cgi->header(-type => "text/plain", -charset => 'utf-8', '-content-disposition' => "inline; filename=\"$save_as\"");
open my $fd, "-|", "$gitbin/git-cat-file blob $hash" or return;
undef $/;
print <$fd>;
}
close $fd;
- print $cgi->header(-type => "text/plain", -charset => 'utf-8');
+ print $cgi->header(-type => "text/plain", -charset => 'utf-8', '-content-disposition' => "inline; filename=\"git-$hash.patch\"");
my %co = git_read_commit($hash);
my %ad = date_str($co{'author_epoch'}, $co{'author_tz'});
my $comment = $co{'comment'};