git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] gitweb: unify boolean feature subroutines

From
MKMatt Kraai <kraai@ftbfs.org>
Date
Dec 15, 2008, 14:51 UTC
Message-ID
<1229352709-4663-2-git-send-email-kraai@ftbfs.org>
In-Reply-To
<1229352709-4663-1-git-send-email-kraai@ftbfs.org>

The boolean feature subroutines were identical 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 |   35 ++++++-----------------------------
 1 files changed, 6 insertions(+), 29 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 145e712..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,8 +363,9 @@ 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);
@@ -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
Previous: Matt KraaiNext: Junio C Hamano
Message 2 of 13 in “gitweb: make feature_blame return a list”
  1. gitweb: make feature_blame return a listMatt Kraai, Dec 15, 2008
  2. gitweb: unify boolean feature subroutinesMatt Kraai, Dec 15, 2008
  3. Junio C HamanoDec 15, 2008
  4. Junio C HamanoDec 15, 2008
  5. Giuseppe BilottaDec 15, 2008
  6. Matt KraaiDec 16, 2008
  7. Junio C HamanoDec 16, 2008
  8. gitweb: unify boolean feature subroutinesMatt Kraai, Dec 16, 2008
  9. gitweb: pass the option name to the feature callbackMatt Kraai, Dec 16, 2008
  10. Junio C HamanoDec 16, 2008
  11. Matt KraaiDec 16, 2008
  12. Petr BaudisDec 17, 2008
  13. Junio C HamanoDec 17, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.