Thread (10 messages) flat view 10 messages, 3 authors, 2016-06-15

Re: [PATCH] gitweb: snapshot cleanups & support for offering multiple formats

From: Jakub Narebski <hidden>
Date: 2016-06-15 22:43:22

Possibly related (same subject, not in this thread)

On Tue, 17 July 2007, Matt McCutchen wrote:
 sub feature_snapshot {
-       my ($ctype, $suffix, $command) = @_;
+       my (@fmts) = @_;
 
        my ($val) = git_get_project_config('snapshot');
 
-       if ($val eq 'gzip') {
-               return ('x-gzip', 'gz', 'gzip');
-       } elsif ($val eq 'bzip2') {
-               return ('x-bzip2', 'bz2', 'bzip2');
-       } elsif ($val eq 'zip') {
-               return ('x-zip', 'zip', '');
-       } elsif ($val eq 'none') {
-               return ();
+       if ($val) {
+               @fmts = ($val eq 'none' ? () : split /,/, $val);
+               @fmts = map $known_snapshot_format_aliases{$_} || $_, @fmts;
+               @fmts = grep exists $known_snapshot_formats{$_}, @fmts;
        }
 
-       return ($ctype, $suffix, $command);
-}
I would use more permissive (be forbidding in what you accept) regexp
to split gitweb.snapshot value into list of snapshot formats, so one
could use "tgz, zip", or perhaps even "tgz zip", and not only "tgz,zip"
(no whitespace possible). For example

+               @fmts = ($val eq 'none' ? () : split(/\s*,\s*/, $val));

or even

+               @fmts = ($val eq 'none' ? () : split(/\s*[,\s]\s*/, $val));

to allow "tgz zip".


Your regexp for "tgz, zip" would get 'tgz', ' zip' (with leading space)
as snapshot formats to use.

-- 
Jakub Narebski
Poland
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help