Skip to content

Commit dad1a45

Browse files
committed
Merge branch 'mr/gitweb-xz'
* 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
2 parents b5a8dc7 + cbdefb5 commit dad1a45

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

gitweb/INSTALL

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,15 @@ GITWEB_CONFIG file:
123123
$feature{'snapshot'}{'default'} = ['zip', 'tgz'];
124124
$feature{'snapshot'}{'override'} = 1;
125125

126+
If you allow overriding for the snapshot feature, you can specify which
127+
snapshot formats are globally disabled. You can also add any command line
128+
options you want (such as setting the compression level). For instance,
129+
you can disable Zip compressed snapshots and set GZip to run at level 6 by
130+
adding the following lines to your $GITWEB_CONFIG:
131+
132+
$known_snapshot_formats{'zip'}{'disabled'} = 1;
133+
$known_snapshot_formats{'tgz'}{'compressor'} = ['gzip','-6'];
134+
126135

127136
Gitweb repositories
128137
-------------------

gitweb/gitweb.perl

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ BEGIN
160160
# 'suffix' => filename suffix,
161161
# 'format' => --format for git-archive,
162162
# 'compressor' => [compressor command and arguments]
163-
# (array reference, optional)}
163+
# (array reference, optional)
164+
# 'disabled' => boolean (optional)}
164165
#
165166
'tgz' => {
166167
'display' => 'tar.gz',
@@ -176,6 +177,14 @@ BEGIN
176177
'format' => 'tar',
177178
'compressor' => ['bzip2']},
178179

180+
'txz' => {
181+
'display' => 'tar.xz',
182+
'type' => 'application/x-xz',
183+
'suffix' => '.tar.xz',
184+
'format' => 'tar',
185+
'compressor' => ['xz'],
186+
'disabled' => 1},
187+
179188
'zip' => {
180189
'display' => 'zip',
181190
'type' => 'application/x-zip',
@@ -188,6 +197,7 @@ BEGIN
188197
our %known_snapshot_format_aliases = (
189198
'gzip' => 'tgz',
190199
'bzip2' => 'tbz2',
200+
'xz' => 'txz',
191201

192202
# backward compatibility: legacy gitweb config support
193203
'x-gzip' => undef, 'gz' => undef,
@@ -494,7 +504,8 @@ sub filter_snapshot_fmts {
494504
exists $known_snapshot_format_aliases{$_} ?
495505
$known_snapshot_format_aliases{$_} : $_} @fmts;
496506
@fmts = grep {
497-
exists $known_snapshot_formats{$_} } @fmts;
507+
exists $known_snapshot_formats{$_} &&
508+
!$known_snapshot_formats{$_}{'disabled'}} @fmts;
498509
}
499510

500511
our $GITWEB_CONFIG = $ENV{'GITWEB_CONFIG'} || "++GITWEB_CONFIG++";
@@ -5181,6 +5192,8 @@ sub git_snapshot {
51815192
die_error(400, "Unknown snapshot format");
51825193
} elsif (!grep($_ eq $format, @snapshot_fmts)) {
51835194
die_error(403, "Unsupported snapshot format");
5195+
} elsif ($known_snapshot_formats{$format}{'disabled'}) {
5196+
die_error(403, "Snapshot format not allowed");
51845197
}
51855198

51865199
if (!defined $hash) {

0 commit comments

Comments
 (0)