Skip to content

Commit

Permalink
gitweb: unify boolean feature subroutines
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Matt Kraai authored and Junio C Hamano committed Dec 16, 2008
1 parent 8befc50 commit cdad817
Showing 1 changed file with 9 additions and 32 deletions.
41 changes: 9 additions & 32 deletions gitweb/gitweb.perl
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ BEGIN
# $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]},

Expand Down Expand Up @@ -241,7 +241,7 @@ BEGIN
# $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]},

Expand All @@ -255,7 +255,7 @@ BEGIN
# $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]},

Expand Down Expand Up @@ -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 {
Expand All @@ -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.
Expand Down

0 comments on commit cdad817

Please sign in to comment.