summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d16d093)
raw | patch | inline | side by side (parent: d16d093)
author | Aneesh Kumar K.V <aneesh.kumar@gmail.com> | |
Thu, 17 Aug 2006 15:29:46 +0000 (20:59 +0530) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Thu, 17 Aug 2006 17:41:58 +0000 (10:41 -0700) |
This adds snapshort support in gitweb. To enable one need to
set gitweb.snapshot = true in the config file.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@hp.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
set gitweb.snapshot = true in the config file.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@hp.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
gitweb/gitweb.perl | patch | blob | history |
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 36d3082152dda6245ddc067519d2014f4b05f2f9..941dce0e887f3b100b20910507417a408c279438 100755 (executable)
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
use Encode;
use Fcntl ':mode';
use File::Find qw();
+use File::Basename qw(basename);
binmode STDOUT, ':utf8';
our $cgi = new CGI;
"tag" => \&git_tag,
"tags" => \&git_tags,
"tree" => \&git_tree,
+ "snapshot" => \&git_snapshot,
);
$action = 'summary' if (!defined($action));
sub git_shortlog_body {
# uses global variable $project
my ($revlist, $from, $to, $refs, $extra) = @_;
+ my $have_snapshot = git_get_project_config_bool('snapshot');
$from = 0 unless defined $from;
$to = $#{$revlist} if (!defined $to || $#{$revlist} < $to);
print "</td>\n" .
"<td class=\"link\">" .
$cgi->a({-href => href(action=>"commit", hash=>$commit)}, "commit") . " | " .
- $cgi->a({-href => href(action=>"commitdiff", hash=>$commit)}, "commitdiff") .
- "</td>\n" .
+ $cgi->a({-href => href(action=>"commitdiff", hash=>$commit)}, "commitdiff");
+ if ($have_snapshot) {
+ print " | " . $cgi->a({-href => href(action=>"snapshot", hash=>$commit)}, "snapshot");
+ }
+ print "</td>\n" .
"</tr>\n";
}
if (defined $extra) {
git_footer_html();
}
+sub git_snapshot {
+
+ if (!defined $hash) {
+ $hash = git_get_head_hash($project);
+ }
+
+ my $filename = basename($project) . "-$hash.tar.gz";
+
+ print $cgi->header(-type => 'application/x-tar',
+ -content-encoding => 'gzip',
+ '-content-disposition' => "inline; filename=\"$filename\"",
+ -status => '200 OK');
+
+ open my $fd, "-|", "$GIT tar-tree $hash \'$project\' | gzip" or
+ die_error(undef, "Execute git-tar-tree failed.");
+ binmode STDOUT, ':raw';
+ print <$fd>;
+ binmode STDOUT, ':utf8'; # as set at the beginning of gitweb.cgi
+ close $fd;
+
+
+}
+
sub git_log {
my $head = git_get_head_hash($project);
if (!defined $hash) {
}
my $refs = git_get_references();
my $ref = format_ref_marker($refs, $co{'id'});
+ my $have_snapshot = git_get_project_config_bool('snapshot');
my $formats_nav = '';
if (defined $file_name && defined $co{'parent'}) {
my $parent = $co{'parent'};
"<td class=\"sha1\">" .
$cgi->a({-href => href(action=>"tree", hash=>$co{'tree'}, hash_base=>$hash), class => "list"}, $co{'tree'}) .
"</td>" .
- "<td class=\"link\">" . $cgi->a({-href => href(action=>"tree", hash=>$co{'tree'}, hash_base=>$hash)}, "tree") .
- "</td>" .
+ "<td class=\"link\">" . $cgi->a({-href => href(action=>"tree", hash=>$co{'tree'}, hash_base=>$hash)}, "tree");
+ if ($have_snapshot) {
+ print " | " . $cgi->a({-href => href(action=>"snapshot", hash=>$hash)}, "snapshot");
+ }
+ print "</td>" .
"</tr>\n";
my $parents = $co{'parents'};
foreach my $par (@$parents) {