* 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
This commit is contained in:
Junio C Hamano 2009-08-23 17:19:06 -07:00
Родитель b5a8dc7e06 cbdefb5ac4
Коммит dad1a454d5
2 изменённых файлов: 24 добавлений и 2 удалений

Просмотреть файл

@ -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
-------------------

Просмотреть файл

@ -160,7 +160,8 @@ our %known_snapshot_formats = (
# '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',
@ -176,6 +177,14 @@ our %known_snapshot_formats = (
'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',
@ -188,6 +197,7 @@ our %known_snapshot_formats = (
our %known_snapshot_format_aliases = (
'gzip' => 'tgz',
'bzip2' => 'tbz2',
'xz' => 'txz',
# backward compatibility: legacy gitweb config support
'x-gzip' => undef, 'gz' => undef,
@ -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++";
@ -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) {