git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHv2 0/2] fixes to gitweb feature check code
@ 2008-11-28 20:39 Giuseppe Bilotta
  2008-11-28 20:39 ` [PATCHv2 1/2] gitweb: " Giuseppe Bilotta
  2008-11-29 10:48 ` [PATCHv2 0/2] " Jakub Narebski
  0 siblings, 2 replies; 26+ messages in thread
From: Giuseppe Bilotta @ 2008-11-28 20:39 UTC (permalink / raw)
  To: git; +Cc: Jakub Narebski, Petr Baudis, Junio C Hamano, Giuseppe Bilotta

This is v2 of the gitweb feature check fix patch, which has now been
split into into a code patch and cleanup patch.

The first patch introduces git_get_feature() to clearly distinguish the
feature retrieval from the boolean feature check (which is kept at
git_check_feature()). The new function is used where appropriate.

The second patch cleans up use of git_check_feature(): since the
function now returns a boolean instead of an array, the often-used
construct
  my ($somevar) = git_check_feature('somefeat');
although still valid, becomes a rather clumsy stylistic choice, as it
introduces an unnecessary ambiguity. Make it clear that we're now
dealing with scalars by using scalar assignment.

Giuseppe Bilotta (2):
  gitweb: fixes to gitweb feature check code
  gitweb: clean up git_check_feature() calls

 gitweb/gitweb.perl |   52 +++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 35 insertions(+), 17 deletions(-)

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCHv2 1/2] gitweb: fixes to gitweb feature check code
  2008-11-28 20:39 [PATCHv2 0/2] " Giuseppe Bilotta
@ 2008-11-28 20:39 ` Giuseppe Bilotta
  2008-11-28 20:39   ` [PATCHv2 2/2] gitweb: clean up git_check_feature() calls Giuseppe Bilotta
  2008-11-30  0:31   ` [PATCHv2 1/2] gitweb: fixes to gitweb feature check code Jakub Narebski
  2008-11-29 10:48 ` [PATCHv2 0/2] " Jakub Narebski
  1 sibling, 2 replies; 26+ messages in thread
From: Giuseppe Bilotta @ 2008-11-28 20:39 UTC (permalink / raw)
  To: git; +Cc: Jakub Narebski, Petr Baudis, Junio C Hamano, Giuseppe Bilotta

The gitweb_check_feature routine was being used for two different
purposes: retrieving the actual feature value (such as the list of
snapshot formats or the list of additional actions), and to check if a
feature was enabled.

For the latter use, since all features return an array, it led to either
clumsy code or subtle bugs, with disabled features appearing enabled
because (0) evaluates to 1.

We fix these bugs, and simplify the code, by separating feature (list)
value retrieval (gitweb_get_feature) from boolean feature check (i.e.
retrieving the first/only item in the feature value list). Usage of
gitweb_check_feature is replaced by gitweb_get_feature where
appropriate.

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 gitweb/gitweb.perl |   26 ++++++++++++++++++++++----
 1 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 933e137..128d7ad 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -190,7 +190,9 @@ our %feature = (
 	# if there is no 'sub' key (no feature-sub), then feature cannot be
 	# overriden
 	#
-	# use gitweb_check_feature(<feature>) to check if <feature> is enabled
+	# use gitweb_get_feature(<feature>) to retrieve the <feature> value
+	# (an array) or gitweb_check_feature(<feature>) to check if <feature>
+	# is enabled
 
 	# Enable the 'blame' blob view, showing the last commit that modified
 	# each line in the file. This can be very CPU-intensive.
@@ -329,7 +331,8 @@ our %feature = (
 		'default' => [0]},
 );
 
-sub gitweb_check_feature {
+# retrieve the value of a given feature, as an array
+sub gitweb_get_feature {
 	my ($name) = @_;
 	return unless exists $feature{$name};
 	my ($sub, $override, @defaults) = (
@@ -344,6 +347,21 @@ sub gitweb_check_feature {
 	return $sub->(@defaults);
 }
 
+# check if a given feature is enabled or not, returning the first (and only)
+# value of the feature. Comfort code, allowing the use of
+#   my $bool_feat = gitweb_check_feature('bool_feat');
+# or
+#   gitweb_check_feature('bool_feat') or somecode;
+# instead of
+#   my ($bool_feat) = gitweb_git_feature('bool_feat');
+# or
+#   (gitweb_check_feature('bool_feat'))[0] or somecode;
+# respectively
+sub gitweb_check_feature {
+	return (gitweb_get_feature(@_))[0];
+}
+
+
 sub feature_blame {
 	my ($val) = git_get_project_config('blame', '--bool');
 
@@ -767,7 +785,7 @@ our $git_dir;
 $git_dir = "$projectroot/$project" if $project;
 
 # list of supported snapshot formats
-our @snapshot_fmts = gitweb_check_feature('snapshot');
+our @snapshot_fmts = gitweb_get_feature('snapshot');
 @snapshot_fmts = filter_snapshot_fmts(@snapshot_fmts);
 
 # dispatch
@@ -3084,7 +3102,7 @@ sub git_print_page_nav {
 	$arg{'tree'}{'hash'} = $treehead if defined $treehead;
 	$arg{'tree'}{'hash_base'} = $treebase if defined $treebase;
 
-	my @actions = gitweb_check_feature('actions');
+	my @actions = gitweb_get_feature('actions');
 	my %repl = (
 		'%' => '%',
 		'n' => $project,         # project name
-- 
1.5.6.5

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCHv2 2/2] gitweb: clean up git_check_feature() calls
  2008-11-28 20:39 ` [PATCHv2 1/2] gitweb: " Giuseppe Bilotta
@ 2008-11-28 20:39   ` Giuseppe Bilotta
  2008-11-29 11:15     ` [PATCHv2 2/2] gitweb: clean up gitweb_check_feature() calls Giuseppe Bilotta
  2008-11-29 11:53     ` [PATCHv2ter " Giuseppe Bilotta
  2008-11-30  0:31   ` [PATCHv2 1/2] gitweb: fixes to gitweb feature check code Jakub Narebski
  1 sibling, 2 replies; 26+ messages in thread
From: Giuseppe Bilotta @ 2008-11-28 20:39 UTC (permalink / raw)
  To: git; +Cc: Jakub Narebski, Petr Baudis, Junio C Hamano, Giuseppe Bilotta

Since git_check_feature now returns a scalar, the parentheses around the
variables initialized from git_check_feature() are not needed.

We remove them for stylistic consistency and to prevent unnecessary
ambiguity in the code.

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 gitweb/gitweb.perl |   26 +++++++++++++-------------
 1 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 128d7ad..b0d00ea 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -828,7 +828,7 @@ sub href (%) {
 		}
 	}
 
-	my ($use_pathinfo) = gitweb_check_feature('pathinfo');
+	my $use_pathinfo = gitweb_check_feature('pathinfo');
 	if ($use_pathinfo) {
 		# try to put as many parameters as possible in PATH_INFO:
 		#   - project name
@@ -2119,7 +2119,7 @@ sub git_get_projects_list {
 	$filter ||= '';
 	$filter =~ s/\.git$//;
 
-	my ($check_forks) = gitweb_check_feature('forks');
+	my $check_forks = gitweb_check_feature('forks');
 
 	if (-d $projects_list) {
 		# search in directory
@@ -2965,7 +2965,7 @@ EOF
 	}
 	print "</div>\n";
 
-	my ($have_search) = gitweb_check_feature('search');
+	my $have_search = gitweb_check_feature('search');
 	if (defined $project && $have_search) {
 		if (!defined $searchtext) {
 			$searchtext = "";
@@ -2979,7 +2979,7 @@ EOF
 			$search_hash = "HEAD";
 		}
 		my $action = $my_uri;
-		my ($use_pathinfo) = gitweb_check_feature('pathinfo');
+		my $use_pathinfo = gitweb_check_feature('pathinfo');
 		if ($use_pathinfo) {
 			$action .= "/".esc_url($project);
 		}
@@ -3472,7 +3472,7 @@ sub is_patch_split {
 sub git_difftree_body {
 	my ($difftree, $hash, @parents) = @_;
 	my ($parent) = $parents[0];
-	my ($have_blame) = gitweb_check_feature('blame');
+	my $have_blame = gitweb_check_feature('blame');
 	print "<div class=\"list_head\">\n";
 	if ($#{$difftree} > 10) {
 		print(($#{$difftree} + 1) . " files changed:\n");
@@ -3986,7 +3986,7 @@ sub git_project_list_body {
 	# actually uses global variable $project
 	my ($projlist, $order, $from, $to, $extra, $no_header) = @_;
 
-	my ($check_forks) = gitweb_check_feature('forks');
+	my $check_forks = gitweb_check_feature('forks');
 	my @projects = fill_project_list_info($projlist, $check_forks);
 
 	$order ||= $default_projects_order;
@@ -4446,7 +4446,7 @@ sub git_summary {
 	my @taglist  = git_get_tags_list(16);
 	my @headlist = git_get_heads_list(16);
 	my @forklist;
-	my ($check_forks) = gitweb_check_feature('forks');
+	my $check_forks = gitweb_check_feature('forks');
 
 	if ($check_forks) {
 		@forklist = git_get_projects_list($project);
@@ -4475,7 +4475,7 @@ sub git_summary {
 	}
 
 	# Tag cloud
-	my $show_ctags = (gitweb_check_feature('ctags'))[0];
+	my $show_ctags = gitweb_check_feature('ctags');
 	if ($show_ctags) {
 		my $ctags = git_get_project_ctags($project);
 		my $cloud = git_populate_project_tagcloud($ctags);
@@ -4765,7 +4765,7 @@ sub git_blob {
 		$expires = "+1d";
 	}
 
-	my ($have_blame) = gitweb_check_feature('blame');
+	my $have_blame = gitweb_check_feature('blame');
 	open my $fd, "-|", git_cmd(), "cat-file", "blob", $hash
 		or die_error(500, "Couldn't cat $file_name, $hash");
 	my $mimetype = blob_mimetype($fd, $file_name);
@@ -4858,7 +4858,7 @@ sub git_tree {
 	my $ref = format_ref_marker($refs, $hash_base);
 	git_header_html();
 	my $basedir = '';
-	my ($have_blame) = gitweb_check_feature('blame');
+	my $have_blame = gitweb_check_feature('blame');
 	if (defined $hash_base && (my %co = parse_commit($hash_base))) {
 		my @views_nav = ();
 		if (defined $file_name) {
@@ -5856,7 +5856,7 @@ insensitive).</p>
 <dt><b>commit</b></dt>
 <dd>The commit messages and authorship information will be scanned for the given pattern.</dd>
 EOT
-	my ($have_grep) = gitweb_check_feature('grep');
+	my $have_grep = gitweb_check_feature('grep');
 	if ($have_grep) {
 		print <<EOT;
 <dt><b>grep</b></dt>
@@ -5873,7 +5873,7 @@ EOT
 <dt><b>committer</b></dt>
 <dd>Name and e-mail of the committer and date of commit will be scanned for the given pattern.</dd>
 EOT
-	my ($have_pickaxe) = gitweb_check_feature('pickaxe');
+	my $have_pickaxe = gitweb_check_feature('pickaxe');
 	if ($have_pickaxe) {
 		print <<EOT;
 <dt><b>pickaxe</b></dt>
@@ -5925,7 +5925,7 @@ sub git_shortlog {
 
 sub git_feed {
 	my $format = shift || 'atom';
-	my ($have_blame) = gitweb_check_feature('blame');
+	my $have_blame = gitweb_check_feature('blame');
 
 	# Atom: http://www.atomenabled.org/developers/syndication/
 	# RSS:  http://www.notestips.com/80256B3A007F2692/1/NAMO5P9UPQ
-- 
1.5.6.5

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* Re: [PATCHv2 0/2] fixes to gitweb feature check code
  2008-11-28 20:39 [PATCHv2 0/2] " Giuseppe Bilotta
  2008-11-28 20:39 ` [PATCHv2 1/2] gitweb: " Giuseppe Bilotta
@ 2008-11-29 10:48 ` Jakub Narebski
  2008-11-29 11:13   ` Giuseppe Bilotta
  1 sibling, 1 reply; 26+ messages in thread
From: Jakub Narebski @ 2008-11-29 10:48 UTC (permalink / raw)
  To: Giuseppe Bilotta; +Cc: git, Petr Baudis, Junio C Hamano

Dnia piątek 28. listopada 2008 21:39, Giuseppe Bilotta napisał:
> This is v2 of the gitweb feature check fix patch, which has now been
> split into into a code patch and cleanup patch.
> 
> The first patch introduces git_get_feature() to clearly distinguish the
> feature retrieval from the boolean feature check (which is kept at
> git_check_feature()). The new function is used where appropriate.
> 
> The second patch cleans up use of git_check_feature(): since the
> function now returns a boolean instead of an array, the often-used
> construct
>   my ($somevar) = git_check_feature('somefeat');
> although still valid, becomes a rather clumsy stylistic choice, as it
> introduces an unnecessary ambiguity. Make it clear that we're now
> dealing with scalars by using scalar assignment.

It is gitweb_get_feature() (for retrieval) and gitweb_check_feature()
(for checking), not git_get_feature() and git_check_feature().

I really like this series; making coding easier by removing need to
use special construct, and making it easier to avoid mistakes is always
a good thing.

> Giuseppe Bilotta (2):
>   gitweb: fixes to gitweb feature check code
>   gitweb: clean up git_check_feature() calls
> 
>  gitweb/gitweb.perl |   52 +++++++++++++++++++++++++++++++++++-----------------
>  1 files changed, 35 insertions(+), 17 deletions(-)

I also like the split, as it separates improvement (much easier to use
and less error prone gitweb_check_feature()) from style cleanup.

-- 
Jakub Narebski
Poland

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCHv2 0/2] fixes to gitweb feature check code
  2008-11-29 10:48 ` [PATCHv2 0/2] " Jakub Narebski
@ 2008-11-29 11:13   ` Giuseppe Bilotta
  0 siblings, 0 replies; 26+ messages in thread
From: Giuseppe Bilotta @ 2008-11-29 11:13 UTC (permalink / raw)
  To: Jakub Narebski; +Cc: git, Petr Baudis, Junio C Hamano

2008/11/29 Jakub Narebski <jnareb@gmail.com>:
> Dnia piątek 28. listopada 2008 21:39, Giuseppe Bilotta napisał:

>> The first patch introduces git_get_feature() to clearly distinguish the
>> feature retrieval from the boolean feature check (which is kept at
>> git_check_feature()). The new function is used where appropriate.

> It is gitweb_get_feature() (for retrieval) and gitweb_check_feature()
> (for checking), not git_get_feature() and git_check_feature().

Ahem. Right. I'll resend the second patch with a fixed subject and
commit message 8-P

-- 
Giuseppe "Oblomov" Bilotta

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCHv2 2/2] gitweb: clean up gitweb_check_feature() calls
  2008-11-28 20:39   ` [PATCHv2 2/2] gitweb: clean up git_check_feature() calls Giuseppe Bilotta
@ 2008-11-29 11:15     ` Giuseppe Bilotta
  2008-11-29 11:18       ` Jakub Narebski
  2008-11-29 11:53     ` [PATCHv2ter " Giuseppe Bilotta
  1 sibling, 1 reply; 26+ messages in thread
From: Giuseppe Bilotta @ 2008-11-29 11:15 UTC (permalink / raw)
  To: git; +Cc: Jakub Narebski, Petr Baudis, Junio C Hamano, Giuseppe Bilotta

Since git_check_feature now returns a scalar, the parentheses around the
variables initialized from gitweb_check_feature() are not needed.

We remove them for stylistic consistency and to prevent unnecessary
ambiguity in the code.

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---

Fixed the commit message, use this instead of the previous one.

 gitweb/gitweb.perl |   26 +++++++++++++-------------
 1 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 128d7ad..b0d00ea 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -828,7 +828,7 @@ sub href (%) {
 		}
 	}
 
-	my ($use_pathinfo) = gitweb_check_feature('pathinfo');
+	my $use_pathinfo = gitweb_check_feature('pathinfo');
 	if ($use_pathinfo) {
 		# try to put as many parameters as possible in PATH_INFO:
 		#   - project name
@@ -2119,7 +2119,7 @@ sub git_get_projects_list {
 	$filter ||= '';
 	$filter =~ s/\.git$//;
 
-	my ($check_forks) = gitweb_check_feature('forks');
+	my $check_forks = gitweb_check_feature('forks');
 
 	if (-d $projects_list) {
 		# search in directory
@@ -2965,7 +2965,7 @@ EOF
 	}
 	print "</div>\n";
 
-	my ($have_search) = gitweb_check_feature('search');
+	my $have_search = gitweb_check_feature('search');
 	if (defined $project && $have_search) {
 		if (!defined $searchtext) {
 			$searchtext = "";
@@ -2979,7 +2979,7 @@ EOF
 			$search_hash = "HEAD";
 		}
 		my $action = $my_uri;
-		my ($use_pathinfo) = gitweb_check_feature('pathinfo');
+		my $use_pathinfo = gitweb_check_feature('pathinfo');
 		if ($use_pathinfo) {
 			$action .= "/".esc_url($project);
 		}
@@ -3472,7 +3472,7 @@ sub is_patch_split {
 sub git_difftree_body {
 	my ($difftree, $hash, @parents) = @_;
 	my ($parent) = $parents[0];
-	my ($have_blame) = gitweb_check_feature('blame');
+	my $have_blame = gitweb_check_feature('blame');
 	print "<div class=\"list_head\">\n";
 	if ($#{$difftree} > 10) {
 		print(($#{$difftree} + 1) . " files changed:\n");
@@ -3986,7 +3986,7 @@ sub git_project_list_body {
 	# actually uses global variable $project
 	my ($projlist, $order, $from, $to, $extra, $no_header) = @_;
 
-	my ($check_forks) = gitweb_check_feature('forks');
+	my $check_forks = gitweb_check_feature('forks');
 	my @projects = fill_project_list_info($projlist, $check_forks);
 
 	$order ||= $default_projects_order;
@@ -4446,7 +4446,7 @@ sub git_summary {
 	my @taglist  = git_get_tags_list(16);
 	my @headlist = git_get_heads_list(16);
 	my @forklist;
-	my ($check_forks) = gitweb_check_feature('forks');
+	my $check_forks = gitweb_check_feature('forks');
 
 	if ($check_forks) {
 		@forklist = git_get_projects_list($project);
@@ -4475,7 +4475,7 @@ sub git_summary {
 	}
 
 	# Tag cloud
-	my $show_ctags = (gitweb_check_feature('ctags'))[0];
+	my $show_ctags = gitweb_check_feature('ctags');
 	if ($show_ctags) {
 		my $ctags = git_get_project_ctags($project);
 		my $cloud = git_populate_project_tagcloud($ctags);
@@ -4765,7 +4765,7 @@ sub git_blob {
 		$expires = "+1d";
 	}
 
-	my ($have_blame) = gitweb_check_feature('blame');
+	my $have_blame = gitweb_check_feature('blame');
 	open my $fd, "-|", git_cmd(), "cat-file", "blob", $hash
 		or die_error(500, "Couldn't cat $file_name, $hash");
 	my $mimetype = blob_mimetype($fd, $file_name);
@@ -4858,7 +4858,7 @@ sub git_tree {
 	my $ref = format_ref_marker($refs, $hash_base);
 	git_header_html();
 	my $basedir = '';
-	my ($have_blame) = gitweb_check_feature('blame');
+	my $have_blame = gitweb_check_feature('blame');
 	if (defined $hash_base && (my %co = parse_commit($hash_base))) {
 		my @views_nav = ();
 		if (defined $file_name) {
@@ -5856,7 +5856,7 @@ insensitive).</p>
 <dt><b>commit</b></dt>
 <dd>The commit messages and authorship information will be scanned for the given pattern.</dd>
 EOT
-	my ($have_grep) = gitweb_check_feature('grep');
+	my $have_grep = gitweb_check_feature('grep');
 	if ($have_grep) {
 		print <<EOT;
 <dt><b>grep</b></dt>
@@ -5873,7 +5873,7 @@ EOT
 <dt><b>committer</b></dt>
 <dd>Name and e-mail of the committer and date of commit will be scanned for the given pattern.</dd>
 EOT
-	my ($have_pickaxe) = gitweb_check_feature('pickaxe');
+	my $have_pickaxe = gitweb_check_feature('pickaxe');
 	if ($have_pickaxe) {
 		print <<EOT;
 <dt><b>pickaxe</b></dt>
@@ -5925,7 +5925,7 @@ sub git_shortlog {
 
 sub git_feed {
 	my $format = shift || 'atom';
-	my ($have_blame) = gitweb_check_feature('blame');
+	my $have_blame = gitweb_check_feature('blame');
 
 	# Atom: http://www.atomenabled.org/developers/syndication/
 	# RSS:  http://www.notestips.com/80256B3A007F2692/1/NAMO5P9UPQ
-- 
1.5.6.5

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* Re: [PATCHv2 2/2] gitweb: clean up gitweb_check_feature() calls
  2008-11-29 11:15     ` [PATCHv2 2/2] gitweb: clean up gitweb_check_feature() calls Giuseppe Bilotta
@ 2008-11-29 11:18       ` Jakub Narebski
  0 siblings, 0 replies; 26+ messages in thread
From: Jakub Narebski @ 2008-11-29 11:18 UTC (permalink / raw)
  To: Giuseppe Bilotta; +Cc: git, Petr Baudis, Junio C Hamano

Giuseppe Bilotta wrote:

> Since git_check_feature now returns a scalar, the parentheses around the
        ^^^
         \---- missed one.

> variables initialized from gitweb_check_feature() are not needed.
> 
> We remove them for stylistic consistency and to prevent unnecessary
> ambiguity in the code.
> 
> Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
> ---
> 
> Fixed the commit message, use this instead of the previous one.

-- 
Jakub Narebski
Poland

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCHv2ter 2/2] gitweb: clean up gitweb_check_feature() calls
  2008-11-28 20:39   ` [PATCHv2 2/2] gitweb: clean up git_check_feature() calls Giuseppe Bilotta
  2008-11-29 11:15     ` [PATCHv2 2/2] gitweb: clean up gitweb_check_feature() calls Giuseppe Bilotta
@ 2008-11-29 11:53     ` Giuseppe Bilotta
  2008-11-29 20:39       ` Junio C Hamano
  1 sibling, 1 reply; 26+ messages in thread
From: Giuseppe Bilotta @ 2008-11-29 11:53 UTC (permalink / raw)
  To: git; +Cc: Jakub Narebski, Petr Baudis, Junio C Hamano, Giuseppe Bilotta

Since gitweb_check_feature now returns a scalar, the parentheses around
the variables initialized from gitweb_check_feature() are not needed.

We remove them for stylistic consistency and to prevent unnecessary
ambiguity in the code.

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---

Third attempt, hopefully I got the commit message right, finally 8-P

 gitweb/gitweb.perl |   26 +++++++++++++-------------
 1 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 128d7ad..b0d00ea 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -828,7 +828,7 @@ sub href (%) {
 		}
 	}
 
-	my ($use_pathinfo) = gitweb_check_feature('pathinfo');
+	my $use_pathinfo = gitweb_check_feature('pathinfo');
 	if ($use_pathinfo) {
 		# try to put as many parameters as possible in PATH_INFO:
 		#   - project name
@@ -2119,7 +2119,7 @@ sub git_get_projects_list {
 	$filter ||= '';
 	$filter =~ s/\.git$//;
 
-	my ($check_forks) = gitweb_check_feature('forks');
+	my $check_forks = gitweb_check_feature('forks');
 
 	if (-d $projects_list) {
 		# search in directory
@@ -2965,7 +2965,7 @@ EOF
 	}
 	print "</div>\n";
 
-	my ($have_search) = gitweb_check_feature('search');
+	my $have_search = gitweb_check_feature('search');
 	if (defined $project && $have_search) {
 		if (!defined $searchtext) {
 			$searchtext = "";
@@ -2979,7 +2979,7 @@ EOF
 			$search_hash = "HEAD";
 		}
 		my $action = $my_uri;
-		my ($use_pathinfo) = gitweb_check_feature('pathinfo');
+		my $use_pathinfo = gitweb_check_feature('pathinfo');
 		if ($use_pathinfo) {
 			$action .= "/".esc_url($project);
 		}
@@ -3472,7 +3472,7 @@ sub is_patch_split {
 sub git_difftree_body {
 	my ($difftree, $hash, @parents) = @_;
 	my ($parent) = $parents[0];
-	my ($have_blame) = gitweb_check_feature('blame');
+	my $have_blame = gitweb_check_feature('blame');
 	print "<div class=\"list_head\">\n";
 	if ($#{$difftree} > 10) {
 		print(($#{$difftree} + 1) . " files changed:\n");
@@ -3986,7 +3986,7 @@ sub git_project_list_body {
 	# actually uses global variable $project
 	my ($projlist, $order, $from, $to, $extra, $no_header) = @_;
 
-	my ($check_forks) = gitweb_check_feature('forks');
+	my $check_forks = gitweb_check_feature('forks');
 	my @projects = fill_project_list_info($projlist, $check_forks);
 
 	$order ||= $default_projects_order;
@@ -4446,7 +4446,7 @@ sub git_summary {
 	my @taglist  = git_get_tags_list(16);
 	my @headlist = git_get_heads_list(16);
 	my @forklist;
-	my ($check_forks) = gitweb_check_feature('forks');
+	my $check_forks = gitweb_check_feature('forks');
 
 	if ($check_forks) {
 		@forklist = git_get_projects_list($project);
@@ -4475,7 +4475,7 @@ sub git_summary {
 	}
 
 	# Tag cloud
-	my $show_ctags = (gitweb_check_feature('ctags'))[0];
+	my $show_ctags = gitweb_check_feature('ctags');
 	if ($show_ctags) {
 		my $ctags = git_get_project_ctags($project);
 		my $cloud = git_populate_project_tagcloud($ctags);
@@ -4765,7 +4765,7 @@ sub git_blob {
 		$expires = "+1d";
 	}
 
-	my ($have_blame) = gitweb_check_feature('blame');
+	my $have_blame = gitweb_check_feature('blame');
 	open my $fd, "-|", git_cmd(), "cat-file", "blob", $hash
 		or die_error(500, "Couldn't cat $file_name, $hash");
 	my $mimetype = blob_mimetype($fd, $file_name);
@@ -4858,7 +4858,7 @@ sub git_tree {
 	my $ref = format_ref_marker($refs, $hash_base);
 	git_header_html();
 	my $basedir = '';
-	my ($have_blame) = gitweb_check_feature('blame');
+	my $have_blame = gitweb_check_feature('blame');
 	if (defined $hash_base && (my %co = parse_commit($hash_base))) {
 		my @views_nav = ();
 		if (defined $file_name) {
@@ -5856,7 +5856,7 @@ insensitive).</p>
 <dt><b>commit</b></dt>
 <dd>The commit messages and authorship information will be scanned for the given pattern.</dd>
 EOT
-	my ($have_grep) = gitweb_check_feature('grep');
+	my $have_grep = gitweb_check_feature('grep');
 	if ($have_grep) {
 		print <<EOT;
 <dt><b>grep</b></dt>
@@ -5873,7 +5873,7 @@ EOT
 <dt><b>committer</b></dt>
 <dd>Name and e-mail of the committer and date of commit will be scanned for the given pattern.</dd>
 EOT
-	my ($have_pickaxe) = gitweb_check_feature('pickaxe');
+	my $have_pickaxe = gitweb_check_feature('pickaxe');
 	if ($have_pickaxe) {
 		print <<EOT;
 <dt><b>pickaxe</b></dt>
@@ -5925,7 +5925,7 @@ sub git_shortlog {
 
 sub git_feed {
 	my $format = shift || 'atom';
-	my ($have_blame) = gitweb_check_feature('blame');
+	my $have_blame = gitweb_check_feature('blame');
 
 	# Atom: http://www.atomenabled.org/developers/syndication/
 	# RSS:  http://www.notestips.com/80256B3A007F2692/1/NAMO5P9UPQ
-- 
1.5.6.5

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* Re: [PATCHv2ter 2/2] gitweb: clean up gitweb_check_feature() calls
  2008-11-29 11:53     ` [PATCHv2ter " Giuseppe Bilotta
@ 2008-11-29 20:39       ` Junio C Hamano
  2008-11-29 21:00         ` Junio C Hamano
  0 siblings, 1 reply; 26+ messages in thread
From: Junio C Hamano @ 2008-11-29 20:39 UTC (permalink / raw)
  To: Giuseppe Bilotta; +Cc: git, Jakub Narebski, Petr Baudis

Giuseppe Bilotta <giuseppe.bilotta@gmail.com> writes:

> Since gitweb_check_feature now returns a scalar, the parentheses around
> the variables initialized from gitweb_check_feature() are not needed.

Here is what I think the commit message of your [1/2] should have read:

    Subject: [PATCH] gitweb: make gitweb_check_feature a boolean wrapper

    The gitweb_check_feature() function retrieves the configuration
    parameters for the feature (such as the list of snapshot formats or
    the list of additional actions), but it is very often used to see if
    feature is enabled (which is returned as the first element in the
    list).

    Because accepting the returned list in a scalar context by mistake
    yields the number of elements in the array, which is non-zero in all
    cases, such a mistake would result in a bug for the latter use, with
    disabled features appearing enabled.  All existing callers that call
    the function for this purpose assign the return value in the list
    context to retrieve the first element, but this is a bug waiting to
    happen for future callers that are not careful.

    This changes gitweb_check_feature() to a wrapper that can be called
    safely in the scalar context to see if a feature is enabled to reduce
    the risk of future bugs.  A new function gitweb_get_feature() is
    introduced for the callers that want the list of configuration
    parameters.  All existing callers of gitweb_check_feature() that want
    the configuration parameters are adjusted to call gitweb_get_feature().

Notice the difference in the tone from your [1/2].  The change is not
about fixing (your proposed commit log message read "gitweb:fixes to
gitweb feature check code") as nothing is broken.  It is purely about
futureproofing and I think we should mark it as such.

The splitting of two patches is not strictly necessary, but if you wanted
to, I would do so slightly differently:

 * Make [1/2] purely the rename of s/check/get/, saying "the function is
   not just checking if it is enabled, but it is getting the configuration
   parameter list.  I'll introduce a new API to ask if it is enabled,
   which will be called 'check', hence this rename".

   Obviously, after applying this patch, there should be no caller of
   "check".

 * Make [2/2] introduce the "check" wrapper, and change the existing
   callers of "get" that want boolean to call "check" (and in the scalar
   context, as it does not matter anymore).  You can steal most of the
   above rewrite as your commit message for this (except for the last two
   sentences).

Also I would rewrite the mysterious "Comfort code" comment like this:

        # A wrapper to check if a given feature is enabled.
        # With this, you can say
        #
        #   my $bool_feat = gitweb_check_feature('bool_feat');
        #   gitweb_check_feature('bool_feat') or somecode;
        #
        # instead of
        #
        #   my ($bool_feat) = gitweb_get_feature('bool_feat');
        #   (gitweb_get_feature('bool_feat'))[0] or somecode;

(you also had a few typos in these four example calls).

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCHv2ter 2/2] gitweb: clean up gitweb_check_feature() calls
  2008-11-29 20:39       ` Junio C Hamano
@ 2008-11-29 21:00         ` Junio C Hamano
  2008-11-29 21:12           ` [PATCH 2/3] gitweb: rename gitweb_check_feature to gitweb_get_feature Junio C Hamano
                             ` (2 more replies)
  0 siblings, 3 replies; 26+ messages in thread
From: Junio C Hamano @ 2008-11-29 21:00 UTC (permalink / raw)
  To: Giuseppe Bilotta; +Cc: git, Jakub Narebski, Petr Baudis

Junio C Hamano <gitster@pobox.com> writes:

> ...  The change is not
> about fixing (your proposed commit log message read "gitweb:fixes to
> gitweb feature check code") as nothing is broken.  It is purely about
> futureproofing and I think we should mark it as such.

Actually, there is a handful clueless/careless callers.  Before applying
any of the check => get patch, let's do this as a fix.

-- >8 --
Subject: [PATCH] gitweb: fix 'ctags' feature check and others

gitweb_check_feature() function is to retrieve the configuration parameter
list and calling it in a scalar context does not give its first element
that tells if the feature is enabled.  This fixes all the existing callers
to call the function correctly in list context.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 gitweb/gitweb.perl |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 933e137..400f5c8 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -3914,7 +3914,7 @@ sub fill_project_list_info {
 	my ($projlist, $check_forks) = @_;
 	my @projects;
 
-	my $show_ctags = gitweb_check_feature('ctags');
+	my ($show_ctags) = gitweb_check_feature('ctags');
  PROJECT:
 	foreach my $pr (@$projlist) {
 		my (@activity) = git_get_last_activity($pr->{'path'});
@@ -3988,7 +3988,7 @@ sub git_project_list_body {
 		@projects = sort {$a->{$oi->{'key'}} <=> $b->{$oi->{'key'}}} @projects;
 	}
 
-	my $show_ctags = gitweb_check_feature('ctags');
+	my ($show_ctags) = gitweb_check_feature('ctags');
 	if ($show_ctags) {
 		my %ctags;
 		foreach my $p (@projects) {
@@ -4457,7 +4457,7 @@ sub git_summary {
 	}
 
 	# Tag cloud
-	my $show_ctags = (gitweb_check_feature('ctags'))[0];
+	my ($show_ctags) = gitweb_check_feature('ctags');
 	if ($show_ctags) {
 		my $ctags = git_get_project_ctags($project);
 		my $cloud = git_populate_project_tagcloud($ctags);
@@ -4559,7 +4559,7 @@ sub git_blame {
 	my $fd;
 	my $ftype;
 
-	gitweb_check_feature('blame')
+	gitweb_check_feature('blame')[0]
 	    or die_error(403, "Blame view not allowed");
 
 	die_error(400, "No file name given") unless $file_name;
@@ -5610,7 +5610,7 @@ sub git_history {
 }
 
 sub git_search {
-	gitweb_check_feature('search') or die_error(403, "Search is disabled");
+	gitweb_check_feature('search')[0] or die_error(403, "Search is disabled");
 	if (!defined $searchtext) {
 		die_error(400, "Text field is empty");
 	}
@@ -5629,11 +5629,11 @@ sub git_search {
 	if ($searchtype eq 'pickaxe') {
 		# pickaxe may take all resources of your box and run for several minutes
 		# with every query - so decide by yourself how public you make this feature
-		gitweb_check_feature('pickaxe')
+		gitweb_check_feature('pickaxe')[0]
 		    or die_error(403, "Pickaxe is disabled");
 	}
 	if ($searchtype eq 'grep') {
-		gitweb_check_feature('grep')
+		gitweb_check_feature('grep')[0]
 		    or die_error(403, "Grep is disabled");
 	}
 
-- 
1.6.0.4.850.g6bd829

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH 2/3] gitweb: rename gitweb_check_feature to gitweb_get_feature
  2008-11-29 21:00         ` Junio C Hamano
@ 2008-11-29 21:12           ` Junio C Hamano
  2008-11-29 21:16           ` [PATCH 3/3] gitweb: make gitweb_check_feature a boolean wrapper Junio C Hamano
  2008-11-29 22:16           ` [PATCHv2ter 2/2] gitweb: clean up gitweb_check_feature() calls Giuseppe Bilotta
  2 siblings, 0 replies; 26+ messages in thread
From: Junio C Hamano @ 2008-11-29 21:12 UTC (permalink / raw)
  To: Giuseppe Bilotta; +Cc: git, Jakub Narebski, Petr Baudis

The function is about retrieving the configuration parameter list for the
feature.  A more robust way to check if a feature is enabled is introduced
in the next patch, and the function will be called gitweb_check_feature.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 * The earlier "fix ctags and friends" is the 1/3; this shows how I would
   have liked to see your patches as a reviewable series.  The end result
   is almost identical.

 gitweb/gitweb.perl |   46 +++++++++++++++++++++++-----------------------
 1 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 400f5c8..7ab16cd 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -190,7 +190,7 @@ our %feature = (
 	# if there is no 'sub' key (no feature-sub), then feature cannot be
 	# overriden
 	#
-	# use gitweb_check_feature(<feature>) to check if <feature> is enabled
+	# use gitweb_get_feature(<feature>) to check if <feature> is enabled
 
 	# Enable the 'blame' blob view, showing the last commit that modified
 	# each line in the file. This can be very CPU-intensive.
@@ -329,7 +329,7 @@ our %feature = (
 		'default' => [0]},
 );
 
-sub gitweb_check_feature {
+sub gitweb_get_feature {
 	my ($name) = @_;
 	return unless exists $feature{$name};
 	my ($sub, $override, @defaults) = (
@@ -767,7 +767,7 @@ our $git_dir;
 $git_dir = "$projectroot/$project" if $project;
 
 # list of supported snapshot formats
-our @snapshot_fmts = gitweb_check_feature('snapshot');
+our @snapshot_fmts = gitweb_get_feature('snapshot');
 @snapshot_fmts = filter_snapshot_fmts(@snapshot_fmts);
 
 # dispatch
@@ -810,7 +810,7 @@ sub href (%) {
 		}
 	}
 
-	my ($use_pathinfo) = gitweb_check_feature('pathinfo');
+	my ($use_pathinfo) = gitweb_get_feature('pathinfo');
 	if ($use_pathinfo) {
 		# try to put as many parameters as possible in PATH_INFO:
 		#   - project name
@@ -2101,7 +2101,7 @@ sub git_get_projects_list {
 	$filter ||= '';
 	$filter =~ s/\.git$//;
 
-	my ($check_forks) = gitweb_check_feature('forks');
+	my ($check_forks) = gitweb_get_feature('forks');
 
 	if (-d $projects_list) {
 		# search in directory
@@ -2947,7 +2947,7 @@ EOF
 	}
 	print "</div>\n";
 
-	my ($have_search) = gitweb_check_feature('search');
+	my ($have_search) = gitweb_get_feature('search');
 	if (defined $project && $have_search) {
 		if (!defined $searchtext) {
 			$searchtext = "";
@@ -2961,7 +2961,7 @@ EOF
 			$search_hash = "HEAD";
 		}
 		my $action = $my_uri;
-		my ($use_pathinfo) = gitweb_check_feature('pathinfo');
+		my ($use_pathinfo) = gitweb_get_feature('pathinfo');
 		if ($use_pathinfo) {
 			$action .= "/".esc_url($project);
 		}
@@ -3084,7 +3084,7 @@ sub git_print_page_nav {
 	$arg{'tree'}{'hash'} = $treehead if defined $treehead;
 	$arg{'tree'}{'hash_base'} = $treebase if defined $treebase;
 
-	my @actions = gitweb_check_feature('actions');
+	my @actions = gitweb_get_feature('actions');
 	my %repl = (
 		'%' => '%',
 		'n' => $project,         # project name
@@ -3454,7 +3454,7 @@ sub is_patch_split {
 sub git_difftree_body {
 	my ($difftree, $hash, @parents) = @_;
 	my ($parent) = $parents[0];
-	my ($have_blame) = gitweb_check_feature('blame');
+	my ($have_blame) = gitweb_get_feature('blame');
 	print "<div class=\"list_head\">\n";
 	if ($#{$difftree} > 10) {
 		print(($#{$difftree} + 1) . " files changed:\n");
@@ -3914,7 +3914,7 @@ sub fill_project_list_info {
 	my ($projlist, $check_forks) = @_;
 	my @projects;
 
-	my ($show_ctags) = gitweb_check_feature('ctags');
+	my ($show_ctags) = gitweb_get_feature('ctags');
  PROJECT:
 	foreach my $pr (@$projlist) {
 		my (@activity) = git_get_last_activity($pr->{'path'});
@@ -3968,7 +3968,7 @@ sub git_project_list_body {
 	# actually uses global variable $project
 	my ($projlist, $order, $from, $to, $extra, $no_header) = @_;
 
-	my ($check_forks) = gitweb_check_feature('forks');
+	my ($check_forks) = gitweb_get_feature('forks');
 	my @projects = fill_project_list_info($projlist, $check_forks);
 
 	$order ||= $default_projects_order;
@@ -3988,7 +3988,7 @@ sub git_project_list_body {
 		@projects = sort {$a->{$oi->{'key'}} <=> $b->{$oi->{'key'}}} @projects;
 	}
 
-	my ($show_ctags) = gitweb_check_feature('ctags');
+	my ($show_ctags) = gitweb_get_feature('ctags');
 	if ($show_ctags) {
 		my %ctags;
 		foreach my $p (@projects) {
@@ -4428,7 +4428,7 @@ sub git_summary {
 	my @taglist  = git_get_tags_list(16);
 	my @headlist = git_get_heads_list(16);
 	my @forklist;
-	my ($check_forks) = gitweb_check_feature('forks');
+	my ($check_forks) = gitweb_get_feature('forks');
 
 	if ($check_forks) {
 		@forklist = git_get_projects_list($project);
@@ -4457,7 +4457,7 @@ sub git_summary {
 	}
 
 	# Tag cloud
-	my ($show_ctags) = gitweb_check_feature('ctags');
+	my ($show_ctags) = gitweb_get_feature('ctags');
 	if ($show_ctags) {
 		my $ctags = git_get_project_ctags($project);
 		my $cloud = git_populate_project_tagcloud($ctags);
@@ -4559,7 +4559,7 @@ sub git_blame {
 	my $fd;
 	my $ftype;
 
-	gitweb_check_feature('blame')[0]
+	gitweb_get_feature('blame')[0]
 	    or die_error(403, "Blame view not allowed");
 
 	die_error(400, "No file name given") unless $file_name;
@@ -4747,7 +4747,7 @@ sub git_blob {
 		$expires = "+1d";
 	}
 
-	my ($have_blame) = gitweb_check_feature('blame');
+	my ($have_blame) = gitweb_get_feature('blame');
 	open my $fd, "-|", git_cmd(), "cat-file", "blob", $hash
 		or die_error(500, "Couldn't cat $file_name, $hash");
 	my $mimetype = blob_mimetype($fd, $file_name);
@@ -4840,7 +4840,7 @@ sub git_tree {
 	my $ref = format_ref_marker($refs, $hash_base);
 	git_header_html();
 	my $basedir = '';
-	my ($have_blame) = gitweb_check_feature('blame');
+	my ($have_blame) = gitweb_get_feature('blame');
 	if (defined $hash_base && (my %co = parse_commit($hash_base))) {
 		my @views_nav = ();
 		if (defined $file_name) {
@@ -5610,7 +5610,7 @@ sub git_history {
 }
 
 sub git_search {
-	gitweb_check_feature('search')[0] or die_error(403, "Search is disabled");
+	gitweb_get_feature('search')[0] or die_error(403, "Search is disabled");
 	if (!defined $searchtext) {
 		die_error(400, "Text field is empty");
 	}
@@ -5629,11 +5629,11 @@ sub git_search {
 	if ($searchtype eq 'pickaxe') {
 		# pickaxe may take all resources of your box and run for several minutes
 		# with every query - so decide by yourself how public you make this feature
-		gitweb_check_feature('pickaxe')[0]
+		gitweb_get_feature('pickaxe')[0]
 		    or die_error(403, "Pickaxe is disabled");
 	}
 	if ($searchtype eq 'grep') {
-		gitweb_check_feature('grep')[0]
+		gitweb_get_feature('grep')[0]
 		    or die_error(403, "Grep is disabled");
 	}
 
@@ -5838,7 +5838,7 @@ insensitive).</p>
 <dt><b>commit</b></dt>
 <dd>The commit messages and authorship information will be scanned for the given pattern.</dd>
 EOT
-	my ($have_grep) = gitweb_check_feature('grep');
+	my ($have_grep) = gitweb_get_feature('grep');
 	if ($have_grep) {
 		print <<EOT;
 <dt><b>grep</b></dt>
@@ -5855,7 +5855,7 @@ EOT
 <dt><b>committer</b></dt>
 <dd>Name and e-mail of the committer and date of commit will be scanned for the given pattern.</dd>
 EOT
-	my ($have_pickaxe) = gitweb_check_feature('pickaxe');
+	my ($have_pickaxe) = gitweb_get_feature('pickaxe');
 	if ($have_pickaxe) {
 		print <<EOT;
 <dt><b>pickaxe</b></dt>
@@ -5907,7 +5907,7 @@ sub git_shortlog {
 
 sub git_feed {
 	my $format = shift || 'atom';
-	my ($have_blame) = gitweb_check_feature('blame');
+	my ($have_blame) = gitweb_get_feature('blame');
 
 	# Atom: http://www.atomenabled.org/developers/syndication/
 	# RSS:  http://www.notestips.com/80256B3A007F2692/1/NAMO5P9UPQ
-- 
1.6.0.4.850.g6bd829

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH 3/3] gitweb: make gitweb_check_feature a boolean wrapper
  2008-11-29 21:00         ` Junio C Hamano
  2008-11-29 21:12           ` [PATCH 2/3] gitweb: rename gitweb_check_feature to gitweb_get_feature Junio C Hamano
@ 2008-11-29 21:16           ` Junio C Hamano
  2008-11-29 22:27             ` Giuseppe Bilotta
  2008-11-29 22:16           ` [PATCHv2ter 2/2] gitweb: clean up gitweb_check_feature() calls Giuseppe Bilotta
  2 siblings, 1 reply; 26+ messages in thread
From: Junio C Hamano @ 2008-11-29 21:16 UTC (permalink / raw)
  To: Giuseppe Bilotta; +Cc: git, Jakub Narebski, Petr Baudis

The gitweb_get_feature() function retrieves the configuration parameters
for the feature (such as the list of snapshot formats or the list of
additional actions), but it is very often used to see if feature is
enabled (which is returned as the first element in the list).

Because accepting the returned list in a scalar context by mistake yields
the number of elements in the array, which is non-zero in all cases, such
a mistake would result in a bug for the latter use, with disabled features
appearing enabled.  All existing callers that call the function for this
purpose assign the return value in the list context to retrieve the first
element, but that is only because we fixed careless callers recently.

This add gitweb_check_feature() as a wrapper to gitweb_get_feature() that
can be called safely in the scalar context to see if a feature is enabled
to reduce the risk of future bugs.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 * Again, this is to demonstrate how I would have liked to see your
   patches as a reviewable series.  Notice how this naturally justifies
   the dropping of parentheses in many lines that begin with "my", and
   makes it easier to review?  You can review the patch easily by knowing
   that callers that have s/get/check/ are now safe to use scalar context.

 gitweb/gitweb.perl |   56 +++++++++++++++++++++++++++++++++------------------
 1 files changed, 36 insertions(+), 20 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 7ab16cd..acc4cfd 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -190,7 +190,7 @@ our %feature = (
 	# if there is no 'sub' key (no feature-sub), then feature cannot be
 	# overriden
 	#
-	# use gitweb_get_feature(<feature>) to check if <feature> is enabled
+	# use gitweb_check_feature(<feature>) to check if <feature> is enabled
 
 	# Enable the 'blame' blob view, showing the last commit that modified
 	# each line in the file. This can be very CPU-intensive.
@@ -344,6 +344,22 @@ sub gitweb_get_feature {
 	return $sub->(@defaults);
 }
 
+# A wrapper to check if a given feature is enabled.
+# With this, you can say
+#
+#   my $bool_feat = gitweb_check_feature('bool_feat');
+#   gitweb_check_feature('bool_feat') or somecode;
+#
+# instead of
+#
+#   my ($bool_feat) = gitweb_get_feature('bool_feat');
+#   (gitweb_get_feature('bool_feat'))[0] or somecode;
+#
+sub gitweb_check_feature {
+	return (gitweb_get_feature(@_))[0];
+}
+
+
 sub feature_blame {
 	my ($val) = git_get_project_config('blame', '--bool');
 
@@ -810,7 +826,7 @@ sub href (%) {
 		}
 	}
 
-	my ($use_pathinfo) = gitweb_get_feature('pathinfo');
+	my $use_pathinfo = gitweb_check_feature('pathinfo');
 	if ($use_pathinfo) {
 		# try to put as many parameters as possible in PATH_INFO:
 		#   - project name
@@ -2101,7 +2117,7 @@ sub git_get_projects_list {
 	$filter ||= '';
 	$filter =~ s/\.git$//;
 
-	my ($check_forks) = gitweb_get_feature('forks');
+	my $check_forks = gitweb_check_feature('forks');
 
 	if (-d $projects_list) {
 		# search in directory
@@ -2947,7 +2963,7 @@ EOF
 	}
 	print "</div>\n";
 
-	my ($have_search) = gitweb_get_feature('search');
+	my $have_search = gitweb_check_feature('search');
 	if (defined $project && $have_search) {
 		if (!defined $searchtext) {
 			$searchtext = "";
@@ -2961,7 +2977,7 @@ EOF
 			$search_hash = "HEAD";
 		}
 		my $action = $my_uri;
-		my ($use_pathinfo) = gitweb_get_feature('pathinfo');
+		my $use_pathinfo = gitweb_check_feature('pathinfo');
 		if ($use_pathinfo) {
 			$action .= "/".esc_url($project);
 		}
@@ -3454,7 +3470,7 @@ sub is_patch_split {
 sub git_difftree_body {
 	my ($difftree, $hash, @parents) = @_;
 	my ($parent) = $parents[0];
-	my ($have_blame) = gitweb_get_feature('blame');
+	my $have_blame = gitweb_check_feature('blame');
 	print "<div class=\"list_head\">\n";
 	if ($#{$difftree} > 10) {
 		print(($#{$difftree} + 1) . " files changed:\n");
@@ -3914,7 +3930,7 @@ sub fill_project_list_info {
 	my ($projlist, $check_forks) = @_;
 	my @projects;
 
-	my ($show_ctags) = gitweb_get_feature('ctags');
+	my $show_ctags = gitweb_check_feature('ctags');
  PROJECT:
 	foreach my $pr (@$projlist) {
 		my (@activity) = git_get_last_activity($pr->{'path'});
@@ -3968,7 +3984,7 @@ sub git_project_list_body {
 	# actually uses global variable $project
 	my ($projlist, $order, $from, $to, $extra, $no_header) = @_;
 
-	my ($check_forks) = gitweb_get_feature('forks');
+	my $check_forks = gitweb_check_feature('forks');
 	my @projects = fill_project_list_info($projlist, $check_forks);
 
 	$order ||= $default_projects_order;
@@ -3988,7 +4004,7 @@ sub git_project_list_body {
 		@projects = sort {$a->{$oi->{'key'}} <=> $b->{$oi->{'key'}}} @projects;
 	}
 
-	my ($show_ctags) = gitweb_get_feature('ctags');
+	my $show_ctags = gitweb_check_feature('ctags');
 	if ($show_ctags) {
 		my %ctags;
 		foreach my $p (@projects) {
@@ -4428,7 +4444,7 @@ sub git_summary {
 	my @taglist  = git_get_tags_list(16);
 	my @headlist = git_get_heads_list(16);
 	my @forklist;
-	my ($check_forks) = gitweb_get_feature('forks');
+	my $check_forks = gitweb_check_feature('forks');
 
 	if ($check_forks) {
 		@forklist = git_get_projects_list($project);
@@ -4457,7 +4473,7 @@ sub git_summary {
 	}
 
 	# Tag cloud
-	my ($show_ctags) = gitweb_get_feature('ctags');
+	my $show_ctags = gitweb_check_feature('ctags');
 	if ($show_ctags) {
 		my $ctags = git_get_project_ctags($project);
 		my $cloud = git_populate_project_tagcloud($ctags);
@@ -4559,7 +4575,7 @@ sub git_blame {
 	my $fd;
 	my $ftype;
 
-	gitweb_get_feature('blame')[0]
+	gitweb_check_feature('blame')
 	    or die_error(403, "Blame view not allowed");
 
 	die_error(400, "No file name given") unless $file_name;
@@ -4747,7 +4763,7 @@ sub git_blob {
 		$expires = "+1d";
 	}
 
-	my ($have_blame) = gitweb_get_feature('blame');
+	my $have_blame = gitweb_check_feature('blame');
 	open my $fd, "-|", git_cmd(), "cat-file", "blob", $hash
 		or die_error(500, "Couldn't cat $file_name, $hash");
 	my $mimetype = blob_mimetype($fd, $file_name);
@@ -4840,7 +4856,7 @@ sub git_tree {
 	my $ref = format_ref_marker($refs, $hash_base);
 	git_header_html();
 	my $basedir = '';
-	my ($have_blame) = gitweb_get_feature('blame');
+	my $have_blame = gitweb_check_feature('blame');
 	if (defined $hash_base && (my %co = parse_commit($hash_base))) {
 		my @views_nav = ();
 		if (defined $file_name) {
@@ -5610,7 +5626,7 @@ sub git_history {
 }
 
 sub git_search {
-	gitweb_get_feature('search')[0] or die_error(403, "Search is disabled");
+	gitweb_check_feature('search') or die_error(403, "Search is disabled");
 	if (!defined $searchtext) {
 		die_error(400, "Text field is empty");
 	}
@@ -5629,11 +5645,11 @@ sub git_search {
 	if ($searchtype eq 'pickaxe') {
 		# pickaxe may take all resources of your box and run for several minutes
 		# with every query - so decide by yourself how public you make this feature
-		gitweb_get_feature('pickaxe')[0]
+		gitweb_check_feature('pickaxe')
 		    or die_error(403, "Pickaxe is disabled");
 	}
 	if ($searchtype eq 'grep') {
-		gitweb_get_feature('grep')[0]
+		gitweb_check_feature('grep')
 		    or die_error(403, "Grep is disabled");
 	}
 
@@ -5838,7 +5854,7 @@ insensitive).</p>
 <dt><b>commit</b></dt>
 <dd>The commit messages and authorship information will be scanned for the given pattern.</dd>
 EOT
-	my ($have_grep) = gitweb_get_feature('grep');
+	my $have_grep = gitweb_check_feature('grep');
 	if ($have_grep) {
 		print <<EOT;
 <dt><b>grep</b></dt>
@@ -5855,7 +5871,7 @@ EOT
 <dt><b>committer</b></dt>
 <dd>Name and e-mail of the committer and date of commit will be scanned for the given pattern.</dd>
 EOT
-	my ($have_pickaxe) = gitweb_get_feature('pickaxe');
+	my $have_pickaxe = gitweb_check_feature('pickaxe');
 	if ($have_pickaxe) {
 		print <<EOT;
 <dt><b>pickaxe</b></dt>
@@ -5907,7 +5923,7 @@ sub git_shortlog {
 
 sub git_feed {
 	my $format = shift || 'atom';
-	my ($have_blame) = gitweb_get_feature('blame');
+	my $have_blame = gitweb_check_feature('blame');
 
 	# Atom: http://www.atomenabled.org/developers/syndication/
 	# RSS:  http://www.notestips.com/80256B3A007F2692/1/NAMO5P9UPQ
-- 
1.6.0.4.850.g6bd829

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* Re: [PATCHv2ter 2/2] gitweb: clean up gitweb_check_feature() calls
  2008-11-29 21:00         ` Junio C Hamano
  2008-11-29 21:12           ` [PATCH 2/3] gitweb: rename gitweb_check_feature to gitweb_get_feature Junio C Hamano
  2008-11-29 21:16           ` [PATCH 3/3] gitweb: make gitweb_check_feature a boolean wrapper Junio C Hamano
@ 2008-11-29 22:16           ` Giuseppe Bilotta
  2008-11-29 22:26             ` Junio C Hamano
  2 siblings, 1 reply; 26+ messages in thread
From: Giuseppe Bilotta @ 2008-11-29 22:16 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Jakub Narebski, Petr Baudis

On Sat, Nov 29, 2008 at 10:00 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Junio C Hamano <gitster@pobox.com> writes:
>
>> ...  The change is not
>> about fixing (your proposed commit log message read "gitweb:fixes to
>> gitweb feature check code") as nothing is broken.  It is purely about
>> futureproofing and I think we should mark it as such.
>
> Actually, there is a handful clueless/careless callers.  Before applying
> any of the check => get patch, let's do this as a fix.

And this is precisely the reason why the first time I sent the patch I
did the restyling in the same go: by not touching the
clueless/careless callers and instead bringing gitweb_check_feature to
act in scalar context, it would automatically fix those broken usages,
and it made sense to convert all array-to-get-a-scalar assignmets as
well.

-- 
Giuseppe "Oblomov" Bilotta

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCHv2ter 2/2] gitweb: clean up gitweb_check_feature() calls
  2008-11-29 22:16           ` [PATCHv2ter 2/2] gitweb: clean up gitweb_check_feature() calls Giuseppe Bilotta
@ 2008-11-29 22:26             ` Junio C Hamano
  2008-11-29 22:36               ` Jakub Narebski
  0 siblings, 1 reply; 26+ messages in thread
From: Junio C Hamano @ 2008-11-29 22:26 UTC (permalink / raw)
  To: Giuseppe Bilotta; +Cc: git, Jakub Narebski, Petr Baudis

"Giuseppe Bilotta" <giuseppe.bilotta@gmail.com> writes:

> And this is precisely the reason why the first time I sent the patch I
> did the restyling in the same go: by not touching the
> clueless/careless callers and instead bringing gitweb_check_feature to
> act in scalar context, it would automatically fix those broken usages,

... which is very bad for reviewability purposes.

By explicitly fixing them before doing the "this will sweep all the
potential bugs under the rug", you can demonstrate a lot more clearly why
these changes are necessary.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 3/3] gitweb: make gitweb_check_feature a boolean wrapper
  2008-11-29 21:16           ` [PATCH 3/3] gitweb: make gitweb_check_feature a boolean wrapper Junio C Hamano
@ 2008-11-29 22:27             ` Giuseppe Bilotta
  2008-11-30  0:23               ` Junio C Hamano
  0 siblings, 1 reply; 26+ messages in thread
From: Giuseppe Bilotta @ 2008-11-29 22:27 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Jakub Narebski, Petr Baudis

On Sat, Nov 29, 2008 at 10:16 PM, Junio C Hamano <gitster@pobox.com> wrote:
>  * Again, this is to demonstrate how I would have liked to see your
>   patches as a reviewable series.  Notice how this naturally justifies
>   the dropping of parentheses in many lines that begin with "my", and
>   makes it easier to review?  You can review the patch easily by knowing
>   that callers that have s/get/check/ are now safe to use scalar context.

Yes, I get the point: do less things under the hood. I also still
think that three patches with code going ping-pong are way too much,
though 8-P

For what it's worth, you get my Ack: to your patchset 8-)

-- 
Giuseppe "Oblomov" Bilotta

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCHv2ter 2/2] gitweb: clean up gitweb_check_feature() calls
  2008-11-29 22:26             ` Junio C Hamano
@ 2008-11-29 22:36               ` Jakub Narebski
  2008-11-29 22:38                 ` Jakub Narebski
  0 siblings, 1 reply; 26+ messages in thread
From: Jakub Narebski @ 2008-11-29 22:36 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Giuseppe Bilotta, git, Petr Baudis

Junio C Hamano wrote:
> "Giuseppe Bilotta" <giuseppe.bilotta@gmail.com> writes:
> 
> > And this is precisely the reason why the first time I sent the patch I
> > did the restyling in the same go: by not touching the
> > clueless/careless callers and instead bringing gitweb_check_feature to
> > act in scalar context, it would automatically fix those broken usages,
> 
> ... which is very bad for reviewability purposes.
> 
> By explicitly fixing them before doing the "this will sweep all the
> potential bugs under the rug", you can demonstrate a lot more clearly why
> these changes are necessary.

Well, I think now that it would be best to split this series into
_two_ patches: first Junio's patch fixing (!) gitweb_check_feature()
calls, second original v1 Guiseppe's renaming gitweb_check_feature()
to gitweb_get_feature(), and adding gitweb_check_feature(), and using
gitweb_get_feature() only where needed; optionally fixing "style".

Pure rename IMVHO doesn't look that nice...
-- 
Jakub Narebski
Poland

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCHv2ter 2/2] gitweb: clean up gitweb_check_feature() calls
  2008-11-29 22:36               ` Jakub Narebski
@ 2008-11-29 22:38                 ` Jakub Narebski
  0 siblings, 0 replies; 26+ messages in thread
From: Jakub Narebski @ 2008-11-29 22:38 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Giuseppe Bilotta, git, Petr Baudis

Jakub Narebski wrote:

> 
> Well, I think now that it would be best to split this series into
> _two_ patches: first Junio's patch fixing (!) gitweb_check_feature()
> calls, second original v1 Guiseppe's renaming gitweb_check_feature()
> to gitweb_get_feature(), and adding gitweb_check_feature(), and using
> gitweb_get_feature() only where needed; optionally fixing "style".

It means: first fixup patch, then futureproof patch.

-- 
Jakub Narebski
Poland

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 3/3] gitweb: make gitweb_check_feature a boolean wrapper
  2008-11-29 22:27             ` Giuseppe Bilotta
@ 2008-11-30  0:23               ` Junio C Hamano
  2008-11-30  1:31                 ` Giuseppe Bilotta
  0 siblings, 1 reply; 26+ messages in thread
From: Junio C Hamano @ 2008-11-30  0:23 UTC (permalink / raw)
  To: Giuseppe Bilotta; +Cc: Junio C Hamano, git, Jakub Narebski, Petr Baudis

"Giuseppe Bilotta" <giuseppe.bilotta@gmail.com> writes:

> On Sat, Nov 29, 2008 at 10:16 PM, Junio C Hamano <gitster@pobox.com> wrote:
>>  * Again, this is to demonstrate how I would have liked to see your
>>   patches as a reviewable series.  Notice how this naturally justifies
>>   the dropping of parentheses in many lines that begin with "my", and
>>   makes it easier to review?  You can review the patch easily by knowing
>>   that callers that have s/get/check/ are now safe to use scalar context.
>
> Yes, I get the point: do less things under the hood. I also still
> think that three patches with code going ping-pong are way too much,
> though 8-P
>
> For what it's worth, you get my Ack: to your patchset 8-)

Well, I am not interested in taking credits for this series.  I am very
much interested in reducing my future workload by showing people how an
easily reviewable series should look like.

So if you still think it is "way too much", I did not succeed what I tried
to do X-<.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCHv2 1/2] gitweb: fixes to gitweb feature check code
  2008-11-28 20:39 ` [PATCHv2 1/2] gitweb: " Giuseppe Bilotta
  2008-11-28 20:39   ` [PATCHv2 2/2] gitweb: clean up git_check_feature() calls Giuseppe Bilotta
@ 2008-11-30  0:31   ` Jakub Narebski
  1 sibling, 0 replies; 26+ messages in thread
From: Jakub Narebski @ 2008-11-30  0:31 UTC (permalink / raw)
  To: Giuseppe Bilotta; +Cc: git, Petr Baudis, Junio C Hamano

On Fri, 28 Nov 2008, Giuseppe Bilotta wrote:

> The gitweb_check_feature routine was being used for two different
> purposes: retrieving the actual feature value (such as the list of
> snapshot formats or the list of additional actions), and to check if a
> feature was enabled.
> 
> For the latter use, since all features return an array, it led to either
> clumsy code or subtle bugs, with disabled features appearing enabled
> because (0) evaluates to 1.
> 
> We fix these bugs, and simplify the code, by separating feature (list)
> value retrieval (gitweb_get_feature) from boolean feature check (i.e.
> retrieving the first/only item in the feature value list). Usage of
> gitweb_check_feature is replaced by gitweb_get_feature where
> appropriate.
> 
> Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>

I like the idea of futureproofing gitweb code to avoid further bugs
with checking if feature is enabled. So from me this patch gets Ack.

I have thought at first that perhaps this patch could also remove
requirement that 'default' field is array (reference), replacing a bit
cumbersome
  $feature{'blame'}{'default'} = [1];
with simpler
  $feature{'blame'}{'default'} = 1;

But now I think that is separate issue, and if we think it is worth
having (in spite of its disadvantages in form of more complicated code
dealing among others with legacy configuration), it should be put in
separate patch.

-- 
Jakub Narebski
Poland

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 3/3] gitweb: make gitweb_check_feature a boolean wrapper
  2008-11-30  0:23               ` Junio C Hamano
@ 2008-11-30  1:31                 ` Giuseppe Bilotta
  0 siblings, 0 replies; 26+ messages in thread
From: Giuseppe Bilotta @ 2008-11-30  1:31 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Jakub Narebski, Petr Baudis

On Sun, Nov 30, 2008 at 1:23 AM, Junio C Hamano <gitster@pobox.com> wrote:
> "Giuseppe Bilotta" <giuseppe.bilotta@gmail.com> writes:
>
>> On Sat, Nov 29, 2008 at 10:16 PM, Junio C Hamano <gitster@pobox.com> wrote:
>>>  * Again, this is to demonstrate how I would have liked to see your
>>>   patches as a reviewable series.  Notice how this naturally justifies
>>>   the dropping of parentheses in many lines that begin with "my", and
>>>   makes it easier to review?  You can review the patch easily by knowing
>>>   that callers that have s/get/check/ are now safe to use scalar context.
>>
>> Yes, I get the point: do less things under the hood. I also still
>> think that three patches with code going ping-pong are way too much,
>> though 8-P
>>
>> For what it's worth, you get my Ack: to your patchset 8-)
>
> Well, I am not interested in taking credits for this series.  I am very
> much interested in reducing my future workload by showing people how an
> easily reviewable series should look like.
>
> So if you still think it is "way too much", I did not succeed what I tried
> to do X-<.

At least as far as this patch goes, from my point of view, the
'clueless/careless' usages of gitweb_check_feature are the
conceptually (although not code-wise) correct ones, so they shouldn't
be the ones touched by the patch, considering that in addition to the
futureproofing, (implicit) fixing those usages is one of the main
points of the patch itself.

OTOH, I _do_ get the point about ease of review. But for example (and
for future reference for myself): would you say that it would have
been enough to have a cleaner commit message explicitly mentioning the
fact that formerly incorrect usages of the gitweb_check_feature() were
left intact because they were now correct?

Something like this http://git.oblomov.eu/git/patch/gitweb/check-feature-v3

-- 
Giuseppe "Oblomov" Bilotta

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH] gitweb: fixes to gitweb feature check code
       [not found] <Message-ID: <cb7bb73a0811291731g7f8770f7p89e924c00d2ab004@mail.gmail.com>
@ 2008-11-30  1:34 ` Giuseppe Bilotta
  2008-12-02  1:53   ` Jakub Narebski
  0 siblings, 1 reply; 26+ messages in thread
From: Giuseppe Bilotta @ 2008-11-30  1:34 UTC (permalink / raw)
  To: git; +Cc: Jakub Narebski, Petr Baudis, Junio C Hamano, Giuseppe Bilotta

The gitweb_check_feature routine was being used for two different
purposes: retrieving the actual feature value (such as the list of
snapshot formats or the list of additional actions), and checking if a
feature was enabled.

This led to subtle bugs in feature checking code: gitweb_check_feature
would return (0) for disabled features, so its use in scalar context
would return true instead of false.

To fix this issue and future-proof the code, we split feature value
retrieval into its own gitweb_get_feature()function , and ensure that
the boolean feature check function gitweb_check_feature() always returns
a scalar (precisely, the first/only item in the feature value list).

Usage of gitweb_check_feature() across gitweb is replaced with
gitweb_get_feature() where appropriate, and list evaluation of
gitweb_check_feature() is demoted to scalar evaluation to prevent
ambiguity. The few previously incorrect uses of gitweb_check_feature()
in scalar context are left untouched because they are now correct.

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 gitweb/gitweb.perl |   52 +++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 35 insertions(+), 17 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 933e137..4246819 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -190,7 +190,9 @@ our %feature = (
 	# if there is no 'sub' key (no feature-sub), then feature cannot be
 	# overriden
 	#
-	# use gitweb_check_feature(<feature>) to check if <feature> is enabled
+	# use gitweb_get_feature(<feature>) to retrieve the <feature> value
+	# (an array) or gitweb_check_feature(<feature>) to check if <feature>
+	# is enabled
 
 	# Enable the 'blame' blob view, showing the last commit that modified
 	# each line in the file. This can be very CPU-intensive.
@@ -329,7 +331,8 @@ our %feature = (
 		'default' => [0]},
 );
 
-sub gitweb_check_feature {
+# retrieve the value of a given feature, as an array
+sub gitweb_get_feature {
 	my ($name) = @_;
 	return unless exists $feature{$name};
 	my ($sub, $override, @defaults) = (
@@ -344,6 +347,21 @@ sub gitweb_check_feature {
 	return $sub->(@defaults);
 }
 
+# check if a given feature is enabled or not, returning the first (and only)
+# value of the feature. This allows us to write
+#   my $bool_feat = gitweb_check_feature('bool_feat');
+# or
+#   gitweb_check_feature('bool_feat') or somecode;
+# instead of
+#   my ($bool_feat) = gitweb_get_feature('bool_feat');
+# or
+#   (gitweb_get_feature('bool_feat'))[0] or somecode;
+# respectively
+sub gitweb_check_feature {
+	return (gitweb_get_feature(@_))[0];
+}
+
+
 sub feature_blame {
 	my ($val) = git_get_project_config('blame', '--bool');
 
@@ -767,7 +785,7 @@ our $git_dir;
 $git_dir = "$projectroot/$project" if $project;
 
 # list of supported snapshot formats
-our @snapshot_fmts = gitweb_check_feature('snapshot');
+our @snapshot_fmts = gitweb_get_feature('snapshot');
 @snapshot_fmts = filter_snapshot_fmts(@snapshot_fmts);
 
 # dispatch
@@ -810,7 +828,7 @@ sub href (%) {
 		}
 	}
 
-	my ($use_pathinfo) = gitweb_check_feature('pathinfo');
+	my $use_pathinfo = gitweb_check_feature('pathinfo');
 	if ($use_pathinfo) {
 		# try to put as many parameters as possible in PATH_INFO:
 		#   - project name
@@ -2101,7 +2119,7 @@ sub git_get_projects_list {
 	$filter ||= '';
 	$filter =~ s/\.git$//;
 
-	my ($check_forks) = gitweb_check_feature('forks');
+	my $check_forks = gitweb_check_feature('forks');
 
 	if (-d $projects_list) {
 		# search in directory
@@ -2947,7 +2965,7 @@ EOF
 	}
 	print "</div>\n";
 
-	my ($have_search) = gitweb_check_feature('search');
+	my $have_search = gitweb_check_feature('search');
 	if (defined $project && $have_search) {
 		if (!defined $searchtext) {
 			$searchtext = "";
@@ -2961,7 +2979,7 @@ EOF
 			$search_hash = "HEAD";
 		}
 		my $action = $my_uri;
-		my ($use_pathinfo) = gitweb_check_feature('pathinfo');
+		my $use_pathinfo = gitweb_check_feature('pathinfo');
 		if ($use_pathinfo) {
 			$action .= "/".esc_url($project);
 		}
@@ -3084,7 +3102,7 @@ sub git_print_page_nav {
 	$arg{'tree'}{'hash'} = $treehead if defined $treehead;
 	$arg{'tree'}{'hash_base'} = $treebase if defined $treebase;
 
-	my @actions = gitweb_check_feature('actions');
+	my @actions = gitweb_get_feature('actions');
 	my %repl = (
 		'%' => '%',
 		'n' => $project,         # project name
@@ -3454,7 +3472,7 @@ sub is_patch_split {
 sub git_difftree_body {
 	my ($difftree, $hash, @parents) = @_;
 	my ($parent) = $parents[0];
-	my ($have_blame) = gitweb_check_feature('blame');
+	my $have_blame = gitweb_check_feature('blame');
 	print "<div class=\"list_head\">\n";
 	if ($#{$difftree} > 10) {
 		print(($#{$difftree} + 1) . " files changed:\n");
@@ -3968,7 +3986,7 @@ sub git_project_list_body {
 	# actually uses global variable $project
 	my ($projlist, $order, $from, $to, $extra, $no_header) = @_;
 
-	my ($check_forks) = gitweb_check_feature('forks');
+	my $check_forks = gitweb_check_feature('forks');
 	my @projects = fill_project_list_info($projlist, $check_forks);
 
 	$order ||= $default_projects_order;
@@ -4428,7 +4446,7 @@ sub git_summary {
 	my @taglist  = git_get_tags_list(16);
 	my @headlist = git_get_heads_list(16);
 	my @forklist;
-	my ($check_forks) = gitweb_check_feature('forks');
+	my $check_forks = gitweb_check_feature('forks');
 
 	if ($check_forks) {
 		@forklist = git_get_projects_list($project);
@@ -4457,7 +4475,7 @@ sub git_summary {
 	}
 
 	# Tag cloud
-	my $show_ctags = (gitweb_check_feature('ctags'))[0];
+	my $show_ctags = gitweb_check_feature('ctags');
 	if ($show_ctags) {
 		my $ctags = git_get_project_ctags($project);
 		my $cloud = git_populate_project_tagcloud($ctags);
@@ -4747,7 +4765,7 @@ sub git_blob {
 		$expires = "+1d";
 	}
 
-	my ($have_blame) = gitweb_check_feature('blame');
+	my $have_blame = gitweb_check_feature('blame');
 	open my $fd, "-|", git_cmd(), "cat-file", "blob", $hash
 		or die_error(500, "Couldn't cat $file_name, $hash");
 	my $mimetype = blob_mimetype($fd, $file_name);
@@ -4840,7 +4858,7 @@ sub git_tree {
 	my $ref = format_ref_marker($refs, $hash_base);
 	git_header_html();
 	my $basedir = '';
-	my ($have_blame) = gitweb_check_feature('blame');
+	my $have_blame = gitweb_check_feature('blame');
 	if (defined $hash_base && (my %co = parse_commit($hash_base))) {
 		my @views_nav = ();
 		if (defined $file_name) {
@@ -5838,7 +5856,7 @@ insensitive).</p>
 <dt><b>commit</b></dt>
 <dd>The commit messages and authorship information will be scanned for the given pattern.</dd>
 EOT
-	my ($have_grep) = gitweb_check_feature('grep');
+	my $have_grep = gitweb_check_feature('grep');
 	if ($have_grep) {
 		print <<EOT;
 <dt><b>grep</b></dt>
@@ -5855,7 +5873,7 @@ EOT
 <dt><b>committer</b></dt>
 <dd>Name and e-mail of the committer and date of commit will be scanned for the given pattern.</dd>
 EOT
-	my ($have_pickaxe) = gitweb_check_feature('pickaxe');
+	my $have_pickaxe = gitweb_check_feature('pickaxe');
 	if ($have_pickaxe) {
 		print <<EOT;
 <dt><b>pickaxe</b></dt>
@@ -5907,7 +5925,7 @@ sub git_shortlog {
 
 sub git_feed {
 	my $format = shift || 'atom';
-	my ($have_blame) = gitweb_check_feature('blame');
+	my $have_blame = gitweb_check_feature('blame');
 
 	# Atom: http://www.atomenabled.org/developers/syndication/
 	# RSS:  http://www.notestips.com/80256B3A007F2692/1/NAMO5P9UPQ
-- 
1.5.6.5

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* Re: [PATCH] gitweb: fixes to gitweb feature check code
  2008-11-30  1:34 ` [PATCH] gitweb: fixes to gitweb feature check code Giuseppe Bilotta
@ 2008-12-02  1:53   ` Jakub Narebski
  2008-12-02 10:43     ` [PATCHv3bis] " Giuseppe Bilotta
  2008-12-02 21:55     ` [PATCH] " Junio C Hamano
  0 siblings, 2 replies; 26+ messages in thread
From: Jakub Narebski @ 2008-12-02  1:53 UTC (permalink / raw)
  To: Giuseppe Bilotta; +Cc: git, Petr Baudis, Junio C Hamano

On Sun, 30 Nov 2008, Giuseppe Bilotta wrote:

> The gitweb_check_feature routine was being used for two different
> purposes: retrieving the actual feature value (such as the list of
> snapshot formats or the list of additional actions), and checking if a
> feature was enabled.
> 
> This led to subtle bugs in feature checking code: gitweb_check_feature
> would return (0) for disabled features, so its use in scalar context
> would return true instead of false.
> 
> To fix this issue and future-proof the code, we split feature value
> retrieval into its own gitweb_get_feature()function , and ensure that

  retrieval into its own gitweb_get_feature() function, and ensure that

> the boolean feature check function gitweb_check_feature() always returns
> a scalar (precisely, the first/only item in the feature value list).
> 
> Usage of gitweb_check_feature() across gitweb is replaced with
> gitweb_get_feature() where appropriate, and list evaluation of
> gitweb_check_feature() is demoted to scalar evaluation to prevent
> ambiguity. The few previously incorrect uses of gitweb_check_feature()
> in scalar context are left untouched because they are now correct.
> 
> Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>

Acked-by: Jakub Narebski <jnareb@gmail.com>


What I like about having all this, i.e. fix, futureproof and style
correction in one single patch is the fact that fix doesn't introduce
strange looking (gitweb_check_feature('bool_feat'))[0]... well, except
encapsulated in a subroutine.

>From all possible splits of this feature into series of up to three
patches I think I like the one with pure subroutine rename from *check*
to *get* least...
-- 
Jakub Narebski
Poland

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCHv3bis] gitweb: fixes to gitweb feature check code
  2008-12-02  1:53   ` Jakub Narebski
@ 2008-12-02 10:43     ` Giuseppe Bilotta
  2008-12-03  2:18       ` Junio C Hamano
  2008-12-02 21:55     ` [PATCH] " Junio C Hamano
  1 sibling, 1 reply; 26+ messages in thread
From: Giuseppe Bilotta @ 2008-12-02 10:43 UTC (permalink / raw)
  To: git; +Cc: Jakub Narebski, Petr Baudis, Junio C Hamano, Giuseppe Bilotta

The gitweb_check_feature routine was being used for two different
purposes: retrieving the actual feature value (such as the list of
snapshot formats or the list of additional actions), and checking if a
feature was enabled.

This led to subtle bugs in feature checking code: gitweb_check_feature
would return (0) for disabled features, so its use in scalar context
would return true instead of false.

To fix this issue and future-proof the code, we split feature value
retrieval into its own gitweb_get_feature()function, and ensure that
the boolean feature check function gitweb_check_feature() always returns
a scalar (precisely, the first/only item in the feature value list).

Usage of gitweb_check_feature() across gitweb is replaced with
gitweb_get_feature() where appropriate, and list evaluation of
gitweb_check_feature() is demoted to scalar evaluation to prevent
ambiguity. The few previously incorrect uses of gitweb_check_feature()
in scalar context are left untouched because they are now correct.

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---

Fixed typo in commit message.

 gitweb/gitweb.perl |   52 +++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 35 insertions(+), 17 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 933e137..4246819 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -190,7 +190,9 @@ our %feature = (
 	# if there is no 'sub' key (no feature-sub), then feature cannot be
 	# overriden
 	#
-	# use gitweb_check_feature(<feature>) to check if <feature> is enabled
+	# use gitweb_get_feature(<feature>) to retrieve the <feature> value
+	# (an array) or gitweb_check_feature(<feature>) to check if <feature>
+	# is enabled
 
 	# Enable the 'blame' blob view, showing the last commit that modified
 	# each line in the file. This can be very CPU-intensive.
@@ -329,7 +331,8 @@ our %feature = (
 		'default' => [0]},
 );
 
-sub gitweb_check_feature {
+# retrieve the value of a given feature, as an array
+sub gitweb_get_feature {
 	my ($name) = @_;
 	return unless exists $feature{$name};
 	my ($sub, $override, @defaults) = (
@@ -344,6 +347,21 @@ sub gitweb_check_feature {
 	return $sub->(@defaults);
 }
 
+# check if a given feature is enabled or not, returning the first (and only)
+# value of the feature. This allows us to write
+#   my $bool_feat = gitweb_check_feature('bool_feat');
+# or
+#   gitweb_check_feature('bool_feat') or somecode;
+# instead of
+#   my ($bool_feat) = gitweb_get_feature('bool_feat');
+# or
+#   (gitweb_get_feature('bool_feat'))[0] or somecode;
+# respectively
+sub gitweb_check_feature {
+	return (gitweb_get_feature(@_))[0];
+}
+
+
 sub feature_blame {
 	my ($val) = git_get_project_config('blame', '--bool');
 
@@ -767,7 +785,7 @@ our $git_dir;
 $git_dir = "$projectroot/$project" if $project;
 
 # list of supported snapshot formats
-our @snapshot_fmts = gitweb_check_feature('snapshot');
+our @snapshot_fmts = gitweb_get_feature('snapshot');
 @snapshot_fmts = filter_snapshot_fmts(@snapshot_fmts);
 
 # dispatch
@@ -810,7 +828,7 @@ sub href (%) {
 		}
 	}
 
-	my ($use_pathinfo) = gitweb_check_feature('pathinfo');
+	my $use_pathinfo = gitweb_check_feature('pathinfo');
 	if ($use_pathinfo) {
 		# try to put as many parameters as possible in PATH_INFO:
 		#   - project name
@@ -2101,7 +2119,7 @@ sub git_get_projects_list {
 	$filter ||= '';
 	$filter =~ s/\.git$//;
 
-	my ($check_forks) = gitweb_check_feature('forks');
+	my $check_forks = gitweb_check_feature('forks');
 
 	if (-d $projects_list) {
 		# search in directory
@@ -2947,7 +2965,7 @@ EOF
 	}
 	print "</div>\n";
 
-	my ($have_search) = gitweb_check_feature('search');
+	my $have_search = gitweb_check_feature('search');
 	if (defined $project && $have_search) {
 		if (!defined $searchtext) {
 			$searchtext = "";
@@ -2961,7 +2979,7 @@ EOF
 			$search_hash = "HEAD";
 		}
 		my $action = $my_uri;
-		my ($use_pathinfo) = gitweb_check_feature('pathinfo');
+		my $use_pathinfo = gitweb_check_feature('pathinfo');
 		if ($use_pathinfo) {
 			$action .= "/".esc_url($project);
 		}
@@ -3084,7 +3102,7 @@ sub git_print_page_nav {
 	$arg{'tree'}{'hash'} = $treehead if defined $treehead;
 	$arg{'tree'}{'hash_base'} = $treebase if defined $treebase;
 
-	my @actions = gitweb_check_feature('actions');
+	my @actions = gitweb_get_feature('actions');
 	my %repl = (
 		'%' => '%',
 		'n' => $project,         # project name
@@ -3454,7 +3472,7 @@ sub is_patch_split {
 sub git_difftree_body {
 	my ($difftree, $hash, @parents) = @_;
 	my ($parent) = $parents[0];
-	my ($have_blame) = gitweb_check_feature('blame');
+	my $have_blame = gitweb_check_feature('blame');
 	print "<div class=\"list_head\">\n";
 	if ($#{$difftree} > 10) {
 		print(($#{$difftree} + 1) . " files changed:\n");
@@ -3968,7 +3986,7 @@ sub git_project_list_body {
 	# actually uses global variable $project
 	my ($projlist, $order, $from, $to, $extra, $no_header) = @_;
 
-	my ($check_forks) = gitweb_check_feature('forks');
+	my $check_forks = gitweb_check_feature('forks');
 	my @projects = fill_project_list_info($projlist, $check_forks);
 
 	$order ||= $default_projects_order;
@@ -4428,7 +4446,7 @@ sub git_summary {
 	my @taglist  = git_get_tags_list(16);
 	my @headlist = git_get_heads_list(16);
 	my @forklist;
-	my ($check_forks) = gitweb_check_feature('forks');
+	my $check_forks = gitweb_check_feature('forks');
 
 	if ($check_forks) {
 		@forklist = git_get_projects_list($project);
@@ -4457,7 +4475,7 @@ sub git_summary {
 	}
 
 	# Tag cloud
-	my $show_ctags = (gitweb_check_feature('ctags'))[0];
+	my $show_ctags = gitweb_check_feature('ctags');
 	if ($show_ctags) {
 		my $ctags = git_get_project_ctags($project);
 		my $cloud = git_populate_project_tagcloud($ctags);
@@ -4747,7 +4765,7 @@ sub git_blob {
 		$expires = "+1d";
 	}
 
-	my ($have_blame) = gitweb_check_feature('blame');
+	my $have_blame = gitweb_check_feature('blame');
 	open my $fd, "-|", git_cmd(), "cat-file", "blob", $hash
 		or die_error(500, "Couldn't cat $file_name, $hash");
 	my $mimetype = blob_mimetype($fd, $file_name);
@@ -4840,7 +4858,7 @@ sub git_tree {
 	my $ref = format_ref_marker($refs, $hash_base);
 	git_header_html();
 	my $basedir = '';
-	my ($have_blame) = gitweb_check_feature('blame');
+	my $have_blame = gitweb_check_feature('blame');
 	if (defined $hash_base && (my %co = parse_commit($hash_base))) {
 		my @views_nav = ();
 		if (defined $file_name) {
@@ -5838,7 +5856,7 @@ insensitive).</p>
 <dt><b>commit</b></dt>
 <dd>The commit messages and authorship information will be scanned for the given pattern.</dd>
 EOT
-	my ($have_grep) = gitweb_check_feature('grep');
+	my $have_grep = gitweb_check_feature('grep');
 	if ($have_grep) {
 		print <<EOT;
 <dt><b>grep</b></dt>
@@ -5855,7 +5873,7 @@ EOT
 <dt><b>committer</b></dt>
 <dd>Name and e-mail of the committer and date of commit will be scanned for the given pattern.</dd>
 EOT
-	my ($have_pickaxe) = gitweb_check_feature('pickaxe');
+	my $have_pickaxe = gitweb_check_feature('pickaxe');
 	if ($have_pickaxe) {
 		print <<EOT;
 <dt><b>pickaxe</b></dt>
@@ -5907,7 +5925,7 @@ sub git_shortlog {
 
 sub git_feed {
 	my $format = shift || 'atom';
-	my ($have_blame) = gitweb_check_feature('blame');
+	my $have_blame = gitweb_check_feature('blame');
 
 	# Atom: http://www.atomenabled.org/developers/syndication/
 	# RSS:  http://www.notestips.com/80256B3A007F2692/1/NAMO5P9UPQ
-- 
1.5.6.5

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* Re: [PATCH] gitweb: fixes to gitweb feature check code
  2008-12-02  1:53   ` Jakub Narebski
  2008-12-02 10:43     ` [PATCHv3bis] " Giuseppe Bilotta
@ 2008-12-02 21:55     ` Junio C Hamano
  2008-12-03  1:21       ` Jakub Narebski
  1 sibling, 1 reply; 26+ messages in thread
From: Junio C Hamano @ 2008-12-02 21:55 UTC (permalink / raw)
  To: Jakub Narebski; +Cc: Giuseppe Bilotta, git, Petr Baudis

Jakub Narebski <jnareb@gmail.com> writes:

> What I like about having all this, i.e. fix, futureproof and style
> correction in one single patch is the fact that fix doesn't introduce
> strange looking (gitweb_check_feature('bool_feat'))[0]... well, except
> encapsulated in a subroutine.
>
> From all possible splits of this feature into series of up to three
> patches I think I like the one with pure subroutine rename from *check*
> to *get* least...

Well, I have to say that you have a strange taste, sense of priorities,
and perhaps aversion to logical progression.  Let's explain one more
time.

The case we had at hand was that a callee has a less-than-ideal calling
convention that has caused a few bugs by callers because they did not
understand the calling convention.  You can argue it is not entirely
caller's fault that they failed to follow the calling convention, but the
fact remains that there are bugs taken as a whole.

First we fix the callers, because existing bugs get highest priority.
This is a pure bugfix patch that could even go to maintenance "bugfix
only" branch.

Then we fix the calling convention because we all know that the calling
convention was less-than-ideal.  A large part of the reason the calling
convention was confusing was because the wording "check" implied it was a
boolean function.  Logically, s/check/get/ would be a major part of fixing
that.

After calling convention is enhanced by a new function that lets callers
"check" via a boolean function, we can have them use that, which makes
them easier to read.

But remember that it is the order I wanted the patches to be presented for
review.  After people involved in review agree that the result is good, I
do not have any problem in squashing the three steps into a single patch
for things like this after the end result is verified to be good (which we
did).

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH] gitweb: fixes to gitweb feature check code
  2008-12-02 21:55     ` [PATCH] " Junio C Hamano
@ 2008-12-03  1:21       ` Jakub Narebski
  0 siblings, 0 replies; 26+ messages in thread
From: Jakub Narebski @ 2008-12-03  1:21 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Giuseppe Bilotta, git, Petr Baudis

Dnia wtorek 2. grudnia 2008 22:55, Junio C Hamano napisał:
> Jakub Narebski <jnareb@gmail.com> writes:
> 
> > What I like about having all this, i.e. fix, futureproof and style
> > correction in one single patch is the fact that fix doesn't introduce
> > strange looking (gitweb_check_feature('bool_feat'))[0]... well, except
> > encapsulated in a subroutine.
> >
> > From all possible splits of this feature into series of up to three
> > patches I think I like the one with pure subroutine rename from *check*
> > to *get* least...
> 
> Well, I have to say that you have a strange taste, sense of priorities,
> and perhaps aversion to logical progression.  Let's explain one more
> time.
> 
> The case we had at hand was that a callee has a less-than-ideal calling
> convention that has caused a few bugs by callers because they did not
> understand the calling convention.  You can argue it is not entirely
> caller's fault that they failed to follow the calling convention, but the
> fact remains that there are bugs taken as a whole.
> 
> First we fix the callers, because existing bugs get highest priority.
> This is a pure bugfix patch that could even go to maintenance "bugfix
> only" branch.

I agree here.

> Then we fix the calling convention because we all know that the calling
> convention was less-than-ideal.  A large part of the reason the calling
> convention was confusing was because the wording "check" implied it was a
> boolean function.  Logically, s/check/get/ would be a major part of fixing
> that.

And here I slightly disagree. The lone change s/check/get/ doesn't
actually do anything. Splitting wrongly named 'check' into checking
if feature is enabled and actual getting config does. And it is IMVHO
quote obvious which calls are to be to new semantic of 'check':
  my ($var) = gitweb_check_feature('feature');
and
  (gitweb_check_feature('feature'))[0]

and which are to be renamed to 'get':
  my ($a, $b) = gitweb_check_feature('feature');
and
  my @a  = gitweb_check_feature('feature');

Perhaps it is more clear from the point of view of reviewing individual
pieces...

-- 
Jakub Narebski
Poland

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCHv3bis] gitweb: fixes to gitweb feature check code
  2008-12-02 10:43     ` [PATCHv3bis] " Giuseppe Bilotta
@ 2008-12-03  2:18       ` Junio C Hamano
  0 siblings, 0 replies; 26+ messages in thread
From: Junio C Hamano @ 2008-12-03  2:18 UTC (permalink / raw)
  To: Giuseppe Bilotta; +Cc: git, Jakub Narebski, Petr Baudis

Thanks, but the ones based on the previous round were already queued in
'next', so I took the change to the check/get comment (the first hunk in
this squashed patch) not to lose the remaining improvements from this
patch.

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2008-12-03  2:19 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <Message-ID: <cb7bb73a0811291731g7f8770f7p89e924c00d2ab004@mail.gmail.com>
2008-11-30  1:34 ` [PATCH] gitweb: fixes to gitweb feature check code Giuseppe Bilotta
2008-12-02  1:53   ` Jakub Narebski
2008-12-02 10:43     ` [PATCHv3bis] " Giuseppe Bilotta
2008-12-03  2:18       ` Junio C Hamano
2008-12-02 21:55     ` [PATCH] " Junio C Hamano
2008-12-03  1:21       ` Jakub Narebski
2008-11-28 20:39 [PATCHv2 0/2] " Giuseppe Bilotta
2008-11-28 20:39 ` [PATCHv2 1/2] gitweb: " Giuseppe Bilotta
2008-11-28 20:39   ` [PATCHv2 2/2] gitweb: clean up git_check_feature() calls Giuseppe Bilotta
2008-11-29 11:15     ` [PATCHv2 2/2] gitweb: clean up gitweb_check_feature() calls Giuseppe Bilotta
2008-11-29 11:18       ` Jakub Narebski
2008-11-29 11:53     ` [PATCHv2ter " Giuseppe Bilotta
2008-11-29 20:39       ` Junio C Hamano
2008-11-29 21:00         ` Junio C Hamano
2008-11-29 21:12           ` [PATCH 2/3] gitweb: rename gitweb_check_feature to gitweb_get_feature Junio C Hamano
2008-11-29 21:16           ` [PATCH 3/3] gitweb: make gitweb_check_feature a boolean wrapper Junio C Hamano
2008-11-29 22:27             ` Giuseppe Bilotta
2008-11-30  0:23               ` Junio C Hamano
2008-11-30  1:31                 ` Giuseppe Bilotta
2008-11-29 22:16           ` [PATCHv2ter 2/2] gitweb: clean up gitweb_check_feature() calls Giuseppe Bilotta
2008-11-29 22:26             ` Junio C Hamano
2008-11-29 22:36               ` Jakub Narebski
2008-11-29 22:38                 ` Jakub Narebski
2008-11-30  0:31   ` [PATCHv2 1/2] gitweb: fixes to gitweb feature check code Jakub Narebski
2008-11-29 10:48 ` [PATCHv2 0/2] " Jakub Narebski
2008-11-29 11:13   ` Giuseppe Bilotta

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).