All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matt Kraai <kraai@ftbfs.org>
To: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Cc: Matt Kraai <kraai@ftbfs.org>
Subject: [PATCH] gitweb: unify boolean feature subroutines
Date: Mon, 15 Dec 2008 22:16:19 -0800	[thread overview]
Message-ID: <1229408179-7655-1-git-send-email-kraai@ftbfs.org> (raw)
In-Reply-To: <7vabawu1ao.fsf@gitster.siamese.dyndns.org>

The boolean feature subroutines behaved identically except for the
name of the configuration option, so make that a parameter and unify
them.

Signed-off-by: Matt Kraai <kraai@ftbfs.org>
---
 gitweb/gitweb.perl |   41 +++++++++--------------------------------
 1 files changed, 9 insertions(+), 32 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 6eb370d..827e5c5 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -203,7 +203,7 @@ our %feature = (
 	# $feature{'blame'}{'override'} = 1;
 	# and in project config gitweb.blame = 0|1;
 	'blame' => {
-		'sub' => \&feature_blame,
+		'sub' => sub { feature_bool('blame', @_) },
 		'override' => 0,
 		'default' => [0]},
 
@@ -241,7 +241,7 @@ our %feature = (
 	# $feature{'grep'}{'override'} = 1;
 	# and in project config gitweb.grep = 0|1;
 	'grep' => {
-		'sub' => \&feature_grep,
+		'sub' => sub { feature_bool('grep', @_) },
 		'override' => 0,
 		'default' => [1]},
 
@@ -255,7 +255,7 @@ our %feature = (
 	# $feature{'pickaxe'}{'override'} = 1;
 	# and in project config gitweb.pickaxe = 0|1;
 	'pickaxe' => {
-		'sub' => \&feature_pickaxe,
+		'sub' => sub { feature_bool('pickaxe', @_) },
 		'override' => 0,
 		'default' => [1]},
 
@@ -363,16 +363,17 @@ sub gitweb_check_feature {
 }
 
 
-sub feature_blame {
-	my ($val) = git_get_project_config('blame', '--bool');
+sub feature_bool {
+	my $key = shift;
+	my ($val) = git_get_project_config($key, '--bool');
 
 	if ($val eq 'true') {
-		return 1;
+		return (1);
 	} elsif ($val eq 'false') {
-		return 0;
+		return (0);
 	}
 
-	return $_[0];
+	return ($_[0]);
 }
 
 sub feature_snapshot {
@@ -387,30 +388,6 @@ sub feature_snapshot {
 	return @fmts;
 }
 
-sub feature_grep {
-	my ($val) = git_get_project_config('grep', '--bool');
-
-	if ($val eq 'true') {
-		return (1);
-	} elsif ($val eq 'false') {
-		return (0);
-	}
-
-	return ($_[0]);
-}
-
-sub feature_pickaxe {
-	my ($val) = git_get_project_config('pickaxe', '--bool');
-
-	if ($val eq 'true') {
-		return (1);
-	} elsif ($val eq 'false') {
-		return (0);
-	}
-
-	return ($_[0]);
-}
-
 # checking HEAD file with -e is fragile if the repository was
 # initialized long time ago (i.e. symlink HEAD) and was pack-ref'ed
 # and then pruned.
-- 
1.5.6.5

  reply	other threads:[~2008-12-16  6:18 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-15 14:51 [PATCH] gitweb: make feature_blame return a list Matt Kraai
2008-12-15 14:51 ` [PATCH] gitweb: unify boolean feature subroutines Matt Kraai
2008-12-15 22:21   ` Junio C Hamano
2008-12-15 22:20 ` [PATCH] gitweb: make feature_blame return a list Junio C Hamano
2008-12-15 22:52   ` Giuseppe Bilotta
2008-12-16  2:46   ` Matt Kraai
2008-12-16  5:38     ` Junio C Hamano
2008-12-16  6:16       ` Matt Kraai [this message]
2008-12-16  7:36         ` [PATCH] gitweb: pass the option name to the feature callback Matt Kraai
2008-12-16  9:03         ` [PATCH] gitweb: unify boolean feature subroutines Junio C Hamano
2008-12-16 14:23           ` Matt Kraai
2008-12-17  8:10             ` Petr Baudis
2008-12-17  8:20               ` Junio C Hamano

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=1229408179-7655-1-git-send-email-kraai@ftbfs.org \
    --to=kraai@ftbfs.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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.