# [PATCHv5 1/3] gitweb: support to globally disable a snapshot format

2 messages from 2009-08-06 to 2009-08-06. Participants: Mark A Rada, Junio C Hamano.
Thread: https://gitlist.dev/t/20424

## Mark A Rada, 2009-08-06 04:24

Subject: [PATCHv5 1/3] gitweb: support to globally disable a snapshot format
Message-ID: <35210404-7E4C-4CB9-881C-45C9E61ACECE@uwaterloo.ca>
URL: https://gitlist.dev/e/35210404-7E4C-4CB9-881C-45C9E61ACECE%40uwaterloo.ca

```
Re-ordered, as suggested by Junio.

--
Mark A Rada (ferrous26)
marada@uwaterloo.ca


--->8---
From: Mark Rada <marada@uwaterloo.ca>
Date: Wed, 5 Aug 2009 21:02:54 -0400
Subject: [PATCH 1/3] gitweb: support to globally disable a snapshot  
format

I added an optional variable, 'disabled', to to the
$known_snapshot_formats keys so that a Gitweb administrator can
globally enable or disable a specific format for snapshots.

All formats are enabled by default because project specific overriding
is disabled by default.

Signed-off-by: Mark Rada <marada@uwaterloo.ca>
---
  gitweb/gitweb.perl |    8 ++++++--
  1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 37120a3..a0cdf31 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -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',
@@ -494,7 +495,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++";
@@ -5166,6 +5168,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) {
-- 
1.6.4

```

## Junio C Hamano, 2009-08-06 06:20

Subject: Re: [PATCHv5 1/3] gitweb: support to globally disable a snapshot format
Message-ID: <7vtz0lpinr.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vtz0lpinr.fsf%40alter.siamese.dyndns.org
In-Reply-To: <35210404-7E4C-4CB9-881C-45C9E61ACECE@uwaterloo.ca>

```
Mark A Rada <marada@uwaterloo.ca> writes:

> Re-ordered, as suggested by Junio.
>
> --
> Mark A Rada (ferrous26)
> marada@uwaterloo.ca
>
>
> --->8---

Please have all of the above after the "---" line.

> From: Mark Rada <marada@uwaterloo.ca>
> Date: Wed, 5 Aug 2009 21:02:54 -0400
> Subject: [PATCH 1/3] gitweb: support to globally disable a snapshot
> format

And you do not need these four lines, as they match what you have in the
e-mail header.

> I added an optional variable, 'disabled', to to the
> $known_snapshot_formats keys so that a Gitweb administrator can
> globally enable or disable a specific format for snapshots.

"to to"?

We tend not to say "I did this and that" in our log messsages; order the
codebase to do certain new things, or order the maintainer to change the
code to make it do new things. e.g.

	Allow gitweb administrators to set in %known_snapshot_formats hash
	an optional key, 'disabled' for specific format.  This can be used
	to configure out individual formats.

> All formats are enabled by default because project specific overriding
> is disabled by default.

That is not quite a good justification; but "all the formats have been
enabled so far, and installing an updated gitweb should not change the
existing behaviour" is.

```
