Skip to content

Commit

Permalink
Merge branch 'mr/gitweb-xz'
Browse files Browse the repository at this point in the history
* mr/gitweb-xz:
  gitweb: add support for XZ compressed snapshots
  gitweb: update INSTALL regarding specific snapshot settings
  gitweb: support to globally disable a snapshot format
  • Loading branch information
Junio C Hamano committed Aug 24, 2009
2 parents b5a8dc7 + cbdefb5 commit dad1a45
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
9 changes: 9 additions & 0 deletions gitweb/INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,15 @@ GITWEB_CONFIG file:
$feature{'snapshot'}{'default'} = ['zip', 'tgz'];
$feature{'snapshot'}{'override'} = 1;

If you allow overriding for the snapshot feature, you can specify which
snapshot formats are globally disabled. You can also add any command line
options you want (such as setting the compression level). For instance,
you can disable Zip compressed snapshots and set GZip to run at level 6 by
adding the following lines to your $GITWEB_CONFIG:

$known_snapshot_formats{'zip'}{'disabled'} = 1;
$known_snapshot_formats{'tgz'}{'compressor'} = ['gzip','-6'];


Gitweb repositories
-------------------
Expand Down
17 changes: 15 additions & 2 deletions gitweb/gitweb.perl
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ BEGIN
# 'suffix' => filename suffix,
# 'format' => --format for git-archive,
# 'compressor' => [compressor command and arguments]
# (array reference, optional)}
# (array reference, optional)
# 'disabled' => boolean (optional)}
#
'tgz' => {
'display' => 'tar.gz',
Expand All @@ -176,6 +177,14 @@ BEGIN
'format' => 'tar',
'compressor' => ['bzip2']},

'txz' => {
'display' => 'tar.xz',
'type' => 'application/x-xz',
'suffix' => '.tar.xz',
'format' => 'tar',
'compressor' => ['xz'],
'disabled' => 1},

'zip' => {
'display' => 'zip',
'type' => 'application/x-zip',
Expand All @@ -188,6 +197,7 @@ BEGIN
our %known_snapshot_format_aliases = (
'gzip' => 'tgz',
'bzip2' => 'tbz2',
'xz' => 'txz',

# backward compatibility: legacy gitweb config support
'x-gzip' => undef, 'gz' => undef,
Expand Down Expand Up @@ -494,7 +504,8 @@ sub filter_snapshot_fmts {
exists $known_snapshot_format_aliases{$_} ?
$known_snapshot_format_aliases{$_} : $_} @fmts;
@fmts = grep {
exists $known_snapshot_formats{$_} } @fmts;
exists $known_snapshot_formats{$_} &&
!$known_snapshot_formats{$_}{'disabled'}} @fmts;
}

our $GITWEB_CONFIG = $ENV{'GITWEB_CONFIG'} || "++GITWEB_CONFIG++";
Expand Down Expand Up @@ -5181,6 +5192,8 @@ sub git_snapshot {
die_error(400, "Unknown snapshot format");
} elsif (!grep($_ eq $format, @snapshot_fmts)) {
die_error(403, "Unsupported snapshot format");
} elsif ($known_snapshot_formats{$format}{'disabled'}) {
die_error(403, "Snapshot format not allowed");
}

if (!defined $hash) {
Expand Down

0 comments on commit dad1a45

Please sign in to comment.