From: Jakub Narebski <jnareb@gmail.com>
To: git@vger.kernel.org
Subject: Re: [PATCH] gitweb: snapshot cleanups & support for offering multiple formats
Date: Wed, 11 Jul 2007 01:41:59 +0200 [thread overview]
Message-ID: <f715g6$2sv$1@sea.gmane.org> (raw)
In-Reply-To: 1184023318.9703.1.camel@mattlaptop2
Matt McCutchen wrote:
> - Centralize knowledge about snapshot formats (mime types, extensions,
> commands) in %known_snapshot_formats and improve how some of that
> information is specified. In particular, zip files are no longer a
> special case.
>
> - Add support for offering multiple snapshot formats to the user so
> that he/she can download a snapshot in the format he/she prefers.
> The site-wide or project configuration now gives a list of formats
> to offer, and the "_snapshot_" link is replaced with, say,
> "snapshot (_tbz2_ _zip_)".
>
> - Fix out-of-date "tarball" -> "archive" in comment.
>
> Alert for gitweb site administrators: This patch changes the format of
> $feature{'snapshot'}{'default'} in gitweb_config.perl from a list of three
> pieces of information about a single format to a list of one or more formats
> you wish to offer from the set ('tgz', 'tbz2', 'zip'). Update your
> gitweb_config.perl appropriately.
Quite nice and I think needed refactoring of a snapshot code. Nevertheless
I have some comments on the changes introduced by this patch; not only
change to gitweb_config.perl is needed (which gitweb admin has control
over), but also repo config for individual repositories might need to
be changed (which gitweb admin might not have control over, and which is
much harder to do).
> +# information about snapshot formats that gitweb is capable of serving
> +# name => [mime type, filename suffix, --format for git-archive,
> +# compressor command suffix]
> +our %known_snapshot_formats = (
> + 'tgz' => ['application/x-gzip' , '.tar.gz' , 'tar', '| gzip' ],
> + 'tbz2' => ['application/x-bzip2', '.tar.bz2', 'tar', '| bzip2'],
> + 'zip' => ['application/zip' , '.zip' , 'zip', '' ],
> +);
First, is full mimetype really needed? Earlier code assumed that mimetype
for snapshot is of the form of application/<something>, and it provided
only <something>.
Second, I'd rather have 'gzip' and 'bzip2' aliases to 'tgz' and 'tbz2',
so the old config continues to work. I can see that it would be hard
to do without special-casing code, or changing the assumption that list
of default available snapshot formats is keys of above hash.
> - # and in project config gitweb.snapshot = none|gzip|bzip2|zip;
> + # and in project config, a comma-separated list of formats or "none"
> + # to disable. Example: gitweb.snapshot = tbz2,zip;
I would relax the syntax, so "tbz2, zip" would also work, or even
"tbz2 zip". I'd like for old config to also work, meaning that "gzip"
would be the same as "tgz" and "bzip2" as "tbz2".
> - 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 ();
Very nice getting rid of this swith-like statement...
> + if ($val) {
> + @fmts = ($val eq 'none' ? () : split /,/, $val);
... but I would relax this regexp.
> +# Generates undef or something like "snapshot (tbz2 zip)", linked.
> +# Pass the hash.
> +sub format_snapshot_links {
> + my ($hash) = @_;
> + my @snapshot_fmts = gitweb_check_feature('snapshot');
> + if (@snapshot_fmts) {
> + return "snapshot (" . join(' ', map $cgi->a(
> + {-href => href(action=>"snapshot", hash=>$hash, snapshot_format=>$_)}, "$_"),
> + @snapshot_fmts)
> + . ")";
> + } else {
> + return undef;
> + }
> +}
Nice separation into subroutine.
--
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
next prev parent reply other threads:[~2007-07-10 23:42 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-28 18:02 [PATCH] gitweb: snapshot cleanups & support for offering multiple formats Matt McCutchen
2007-07-07 20:52 ` Junio C Hamano
2007-07-08 9:06 ` Junio C Hamano
2007-07-11 15:55 ` Jakub Narebski
2007-07-11 21:26 ` Junio C Hamano
2007-07-12 1:15 ` Matt McCutchen
2007-07-12 11:07 ` Jakub Narebski
2007-07-17 18:03 ` Matt McCutchen
2007-07-17 19:11 ` Matt McCutchen
2007-07-18 23:40 ` Jakub Narebski
2007-07-19 1:12 ` Junio C Hamano
2007-07-19 3:30 ` Luben Tuikov
2007-07-19 7:30 ` Jakub Narebski
2007-07-19 7:40 ` Luben Tuikov
2007-07-25 18:39 ` [RFC/PATCH] gitweb: Enable transparent compression form HTTP output Jakub Narebski
2007-08-25 18:03 ` Petr Baudis
2007-08-25 22:09 ` Jakub Narebski
2007-08-25 22:14 ` Petr Baudis
2007-08-27 11:01 ` Jakub Narebski
2007-07-19 9:05 ` [PATCH] gitweb: snapshot cleanups & support for offering multiple formats Jakub Narebski
2007-07-20 4:29 ` Junio C Hamano
2007-07-19 9:14 ` Jakub Narebski
2007-07-21 23:30 ` Jakub Narebski
2007-07-22 5:26 ` Junio C Hamano
2007-07-22 15:05 ` Matt McCutchen
2007-07-22 21:41 ` [PATCH] gitweb: Fix support for legacy gitweb config for snapshots Jakub Narebski
2007-07-22 23:10 ` Matt McCutchen
2007-07-22 23:35 ` Junio C Hamano
2007-07-08 21:54 ` [PATCH] gitweb: snapshot cleanups & support for offering multiple formats Junio C Hamano
2007-07-09 22:52 ` Matt McCutchen
2007-07-09 23:21 ` Matt McCutchen
2007-07-10 23:41 ` Jakub Narebski [this message]
2007-07-09 23:48 ` Junio C Hamano
2007-07-10 1:14 ` Matt McCutchen
2007-07-10 1:14 ` Matt McCutchen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='f715g6$2sv$1@sea.gmane.org' \
--to=jnareb@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).