All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
Cc: git@vger.kernel.org, Jakub Narebski <jnareb@gmail.com>,
	Petr Baudis <pasky@suse.cz>
Subject: [PATCH 2/3] gitweb: rename gitweb_check_feature to gitweb_get_feature
Date: Sat, 29 Nov 2008 13:12:22 -0800	[thread overview]
Message-ID: <7vskpaz16x.fsf_-_@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <7vzljiz1qn.fsf@gitster.siamese.dyndns.org> (Junio C. Hamano's message of "Sat, 29 Nov 2008 13:00:32 -0800")

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

  reply	other threads:[~2008-11-29 21:14 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-28 20:39 [PATCHv2 0/2] fixes to gitweb feature check code 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           ` Junio C Hamano [this message]
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
     [not found] <Message-ID: <cb7bb73a0811291731g7f8770f7p89e924c00d2ab004@mail.gmail.com>
2008-11-30  1:34 ` [PATCH] gitweb: " 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vskpaz16x.fsf_-_@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=giuseppe.bilotta@gmail.com \
    --cc=jnareb@gmail.com \
    --cc=pasky@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.