From: Jakub Narebski <jnareb@gmail.com>
To: "Matt McCutchen" <hashproduct@gmail.com>
Cc: "Junio C Hamano" <gitster@pobox.com>,
git@vger.kernel.org, "Petr Baudis" <pasky@suse.cz>,
"Luben Tuikov" <ltuikov@yahoo.com>
Subject: [PATCH] gitweb: Fix support for legacy gitweb config for snapshots
Date: Sun, 22 Jul 2007 23:41:20 +0200 [thread overview]
Message-ID: <200707222341.21538.jnareb@gmail.com> (raw)
In-Reply-To: <3bbc18d20707220805hd95c4ccsc48f140888403391@mail.gmail.com>
Earlier commit which cleaned up snapshot support and introduced
support for multiple snapshot formats changed the format of
$feature{'snapshot'}{'default'} (gitweb configuration) and
gitweb.snapshot configuration variable (repository configuration).
It supported old gitweb.snapshot values of 'gzip', 'bzip2' and 'zip'
and tried to support, but failed to do that, old values of
$feature{'snapshot'}{'default'}; at least those corresponding to
old gitweb.snapshot values of 'gzip', 'bzip2' and 'zip', i.e.
['x-gzip', 'gz', 'gzip']
['x-bzip2', 'bz2', 'bzip2']
['x-zip', 'zip', '']
This commit moves legacy configuration support out of feature_snapshot
subroutine to separate filter_snapshot_fmts subroutine. The
filter_snapshot_fmts is used on result on result of
gitweb_check_feature('snapshot'). This way feature_snapshot deals
_only_ with repository config.
As a byproduct you can now use 'gzip' and 'bzip2' as aliases to 'tgz'
and 'tbz2' also in $feature{'snapshot'}{'default'}, not only in
gitweb.snapshot.
While at it do some whitespace cleanup: use tabs for indent, but
spaces for align.
Noticed-by: Matt McCutchen <hashproduct@gmail.com>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
On Sun, 22 July 2007, Matt McCutchen wrote:
> That said: the backward compatibility code for gitweb _site_
> configuration is broken because it is inside an if statement that only
> runs for gitweb _repository_ configuration.
Sorry for sending not fully tested code. This should fix that.
This commit _is_ rudimentally tested.
gitweb/gitweb.perl | 27 ++++++++++++++++++++-------
1 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index c4f8824..fdfce31 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -307,10 +307,6 @@ sub feature_snapshot {
if ($val) {
@fmts = ($val eq 'none' ? () : split /\s*[,\s]\s*/, $val);
- @fmts = grep { defined } map {
- exists $known_snapshot_format_aliases{$_} ?
- $known_snapshot_format_aliases{$_} : $_ } @fmts;
- @fmts = grep(exists $known_snapshot_formats{$_}, @fmts);
}
return @fmts;
@@ -356,6 +352,18 @@ sub check_export_ok {
(!$export_ok || -e "$dir/$export_ok"));
}
+# process alternate names for backward compatibility
+# filter out unsupported (unknown) snapshot formats
+sub filter_snapshot_fmts {
+ my @fmts = @_;
+
+ @fmts = map {
+ exists $known_snapshot_format_aliases{$_} ?
+ $known_snapshot_format_aliases{$_} : $_} @fmts;
+ @fmts = grep(exists $known_snapshot_formats{$_}, @fmts);
+
+}
+
our $GITWEB_CONFIG = $ENV{'GITWEB_CONFIG'} || "++GITWEB_CONFIG++";
do $GITWEB_CONFIG if -e $GITWEB_CONFIG;
@@ -1299,9 +1307,11 @@ sub format_diff_line {
sub format_snapshot_links {
my ($hash) = @_;
my @snapshot_fmts = gitweb_check_feature('snapshot');
+ @snapshot_fmts = filter_snapshot_fmts(@snapshot_fmts);
my $num_fmts = @snapshot_fmts;
if ($num_fmts > 1) {
# A parenthesized list of links bearing format names.
+ # e.g. "snapshot (_tar.gz_ _zip_)"
return "snapshot (" . join(' ', map
$cgi->a({
-href => href(
@@ -1313,8 +1323,10 @@ sub format_snapshot_links {
, @snapshot_fmts) . ")";
} elsif ($num_fmts == 1) {
# A single "snapshot" link whose tooltip bears the format name.
+ # i.e. "_snapshot_"
my ($fmt) = @snapshot_fmts;
- return $cgi->a({
+ return
+ $cgi->a({
-href => href(
action=>"snapshot",
hash=>$hash,
@@ -4302,11 +4314,12 @@ sub git_tree {
sub git_snapshot {
my @supported_fmts = gitweb_check_feature('snapshot');
+ @supported_fmts = filter_snapshot_fmts(@supported_fmts);
my $format = $cgi->param('sf');
unless ($format =~ m/[a-z0-9]+/
- && exists($known_snapshot_formats{$format})
- && grep($_ eq $format, @supported_fmts)) {
+ && exists($known_snapshot_formats{$format})
+ && grep($_ eq $format, @supported_fmts)) {
die_error(undef, "Unsupported snapshot format");
}
--
1.5.2.4
next prev parent reply other threads:[~2007-07-22 22:13 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 ` Jakub Narebski [this message]
2007-07-22 23:10 ` [PATCH] gitweb: Fix support for legacy gitweb config for snapshots 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
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=200707222341.21538.jnareb@gmail.com \
--to=jnareb@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=hashproduct@gmail.com \
--cc=ltuikov@yahoo.com \
--cc=pasky@suse.cz \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.