diff --git a/gitweb.cgi b/gitweb.cgi --- a/gitweb.cgi +++ b/gitweb.cgi @@ -178,6 +178,9 @@ if ($action eq "summary") { } elsif ($action eq "shortlog") { git_shortlog(); exit; +} elsif ($action eq "snapshot") { + git_snapshot(); + exit; } else { undef $action; die_error(undef, "Unknown action."); @@ -286,10 +289,10 @@ EOF sub git_page_nav { my ($current, $suppress, $head, $treehead, $treebase, $extra) = @_; $extra = '' if !defined $extra; - my @navs = qw(summary shortlog log commit commitdiff tree); + my @navs = qw(summary shortlog log commit commitdiff tree snapshot); my %arg = map { $_, ''} @navs; if (defined $head) { - for (qw(shortlog log commit commitdiff)) { + for (qw(shortlog log commit commitdiff snapshot)) { $arg{$_} = ";h=$head"; } } @@ -1943,3 +1946,77 @@ sub git_shortlog { print ""; git_footer_html(); } + +sub git_snapshot { + if (!defined $hash) { + $hash = git_read_hash("$project/HEAD"); + } + my %co = git_read_commit($hash); + if (!%co) { + die_error(undef, "Unknown commit object."); + } + my $st = $cgi->param('st'); + if (defined $st) { + return git_serve_snapshot($st); + } + + git_header_html(); + git_page_nav('snapshot', '', $hash, $co{'tree'}, $hash); + print "
| Type | \n" . + "\n" . + " |
|---|---|
| $type | "; + $cgi->param("a", "snapshot"); + print "" . + $cgi->startform(-method => "get", -action => "$my_uri") . + $cgi->hidden(-name => "p") . "\n" . + $cgi->hidden(-name => "a") . "\n" . + $cgi->hidden(-name => "h") . "\n" . + $cgi->hidden(-name => "st", + -value => $types{$type}) . "\n" . + $cgi->submit(-label => 'Download') . "\n" . + $cgi->end_form() . "\n" . + " | "; + print "