@matheusbsbs / matheus-bagliano / commits / a7c5a28350
Fork 0

gitweb: rename gitweb_check_feature to gitweb_get_feature

The function is about retrieving the configuration parameter list for the feature. A more robust way to check if a feature is enabled will be introduced in the next patch, and the function will be called gitweb_check_feature. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Nov 29, 2008 at 13:02 UTC a7c5a283509f6a70753c90393dfad016312b8822
1 file changed +23 -23
gitweb/gitweb.perl
+23 -23
@@ -190,7 +190,7 @@ our %feature = (
190 # if there is no 'sub' key (no feature-sub), then feature cannot be
191 # overriden
192 #
193 - # use gitweb_check_feature(<feature>) to check if <feature> is enabled
193 + #
194
195 # Enable the 'blame' blob view, showing the last commit that modified
196 # each line in the file. This can be very CPU-intensive.
@@ -329,7 +329,7 @@ our %feature = (
329 'default' => [0]},
330 );
331
332 -sub gitweb_check_feature {
332 +sub gitweb_get_feature {
333 my ($name) = @_;
334 return unless exists $feature{$name};
335 my ($sub, $override, @defaults) = (
@@ -767,7 +767,7 @@ our $git_dir;
767 $git_dir = "$projectroot/$project" if $project;
768
769 # list of supported snapshot formats
770 -our @snapshot_fmts = gitweb_check_feature('snapshot');
770 +our @snapshot_fmts = gitweb_get_feature('snapshot');
771 @snapshot_fmts = filter_snapshot_fmts(@snapshot_fmts);
772
773 # dispatch
@@ -810,7 +810,7 @@ sub href (%) {
810 }
811 }
812
813 - my ($use_pathinfo) = gitweb_check_feature('pathinfo');
813 + my ($use_pathinfo) = gitweb_get_feature('pathinfo');
814 if ($use_pathinfo) {
815 # try to put as many parameters as possible in PATH_INFO:
816 # - project name
@@ -2101,7 +2101,7 @@ sub git_get_projects_list {
2101 $filter ||= '';
2102 $filter =~ s/\.git$//;
2103
2104 - my ($check_forks) = gitweb_check_feature('forks');
2104 + my ($check_forks) = gitweb_get_feature('forks');
2105
2106 if (-d $projects_list) {
2107 # search in directory
@@ -2947,7 +2947,7 @@ EOF
2947 }
2948 print "</div>\n";
2949
2950 - my ($have_search) = gitweb_check_feature('search');
2950 + my ($have_search) = gitweb_get_feature('search');
2951 if (defined $project && $have_search) {
2952 if (!defined $searchtext) {
2953 $searchtext = "";
@@ -2961,7 +2961,7 @@ EOF
2961 $search_hash = "HEAD";
2962 }
2963 my $action = $my_uri;
2964 - my ($use_pathinfo) = gitweb_check_feature('pathinfo');
2964 + my ($use_pathinfo) = gitweb_get_feature('pathinfo');
2965 if ($use_pathinfo) {
2966 $action .= "/".esc_url($project);
2967 }
@@ -3084,7 +3084,7 @@ sub git_print_page_nav {
3084 $arg{'tree'}{'hash'} = $treehead if defined $treehead;
3085 $arg{'tree'}{'hash_base'} = $treebase if defined $treebase;
3086
3087 - my @actions = gitweb_check_feature('actions');
3087 + my @actions = gitweb_get_feature('actions');
3088 my %repl = (
3089 '%' => '%',
3090 'n' => $project, # project name
@@ -3454,7 +3454,7 @@ sub is_patch_split {
3454 sub git_difftree_body {
3455 my ($difftree, $hash, @parents) = @_;
3456 my ($parent) = $parents[0];
3457 - my ($have_blame) = gitweb_check_feature('blame');
3457 + my ($have_blame) = gitweb_get_feature('blame');
3458 print "<div class=\"list_head\">\n";
3459 if ($#{$difftree} > 10) {
3460 print(($#{$difftree} + 1) . " files changed:\n");
@@ -3914,7 +3914,7 @@ sub fill_project_list_info {
3914 my ($projlist, $check_forks) = @_;
3915 my @projects;
3916
3917 - my ($show_ctags) = gitweb_check_feature('ctags');
3917 + my ($show_ctags) = gitweb_get_feature('ctags');
3918 PROJECT:
3919 foreach my $pr (@$projlist) {
3920 my (@activity) = git_get_last_activity($pr->{'path'});
@@ -3968,7 +3968,7 @@ sub git_project_list_body {
3968 # actually uses global variable $project
3969 my ($projlist, $order, $from, $to, $extra, $no_header) = @_;
3970
3971 - my ($check_forks) = gitweb_check_feature('forks');
3971 + my ($check_forks) = gitweb_get_feature('forks');
3972 my @projects = fill_project_list_info($projlist, $check_forks);
3973
3974 $order ||= $default_projects_order;
@@ -3988,7 +3988,7 @@ sub git_project_list_body {
3988 @projects = sort {$a->{$oi->{'key'}} <=> $b->{$oi->{'key'}}} @projects;
3989 }
3990
3991 - my ($show_ctags) = gitweb_check_feature('ctags');
3991 + my ($show_ctags) = gitweb_get_feature('ctags');
3992 if ($show_ctags) {
3993 my %ctags;
3994 foreach my $p (@projects) {
@@ -4428,7 +4428,7 @@ sub git_summary {
4428 my @taglist = git_get_tags_list(16);
4429 my @headlist = git_get_heads_list(16);
4430 my @forklist;
4431 - my ($check_forks) = gitweb_check_feature('forks');
4431 + my ($check_forks) = gitweb_get_feature('forks');
4432
4433 if ($check_forks) {
4434 @forklist = git_get_projects_list($project);
@@ -4457,7 +4457,7 @@ sub git_summary {
4457 }
4458
4459 # Tag cloud
4460 - my ($show_ctags) = gitweb_check_feature('ctags');
4460 + my ($show_ctags) = gitweb_get_feature('ctags');
4461 if ($show_ctags) {
4462 my $ctags = git_get_project_ctags($project);
4463 my $cloud = git_populate_project_tagcloud($ctags);
@@ -4559,7 +4559,7 @@ sub git_blame {
4559 my $fd;
4560 my $ftype;
4561
4562 - gitweb_check_feature('blame')[0]
4562 + gitweb_get_feature('blame')[0]
4563 or die_error(403, "Blame view not allowed");
4564
4565 die_error(400, "No file name given") unless $file_name;
@@ -4747,7 +4747,7 @@ sub git_blob {
4747 $expires = "+1d";
4748 }
4749
4750 - my ($have_blame) = gitweb_check_feature('blame');
4750 + my ($have_blame) = gitweb_get_feature('blame');
4751 open my $fd, "-|", git_cmd(), "cat-file", "blob", $hash
4752 or die_error(500, "Couldn't cat $file_name, $hash");
4753 my $mimetype = blob_mimetype($fd, $file_name);
@@ -4840,7 +4840,7 @@ sub git_tree {
4840 my $ref = format_ref_marker($refs, $hash_base);
4841 git_header_html();
4842 my $basedir = '';
4843 - my ($have_blame) = gitweb_check_feature('blame');
4843 + my ($have_blame) = gitweb_get_feature('blame');
4844 if (defined $hash_base && (my %co = parse_commit($hash_base))) {
4845 my @views_nav = ();
4846 if (defined $file_name) {
@@ -5610,7 +5610,7 @@ sub git_history {
5610 }
5611
5612 sub git_search {
5613 - gitweb_check_feature('search')[0] or die_error(403, "Search is disabled");
5613 + gitweb_get_feature('search')[0] or die_error(403, "Search is disabled");
5614 if (!defined $searchtext) {
5615 die_error(400, "Text field is empty");
5616 }
@@ -5629,11 +5629,11 @@ sub git_search {
5629 if ($searchtype eq 'pickaxe') {
5630 # pickaxe may take all resources of your box and run for several minutes
5631 # with every query - so decide by yourself how public you make this feature
5632 - gitweb_check_feature('pickaxe')[0]
5632 + gitweb_get_feature('pickaxe')[0]
5633 or die_error(403, "Pickaxe is disabled");
5634 }
5635 if ($searchtype eq 'grep') {
5636 - gitweb_check_feature('grep')[0]
5636 + gitweb_get_feature('grep')[0]
5637 or die_error(403, "Grep is disabled");
5638 }
5639
@@ -5838,7 +5838,7 @@ insensitive).</p>
5838 <dt><b>commit</b></dt>
5839 <dd>The commit messages and authorship information will be scanned for the given pattern.</dd>
5840 EOT
5841 - my ($have_grep) = gitweb_check_feature('grep');
5841 + my ($have_grep) = gitweb_get_feature('grep');
5842 if ($have_grep) {
5843 print <<EOT;
5844 <dt><b>grep</b></dt>
@@ -5855,7 +5855,7 @@ EOT
5855 <dt><b>committer</b></dt>
5856 <dd>Name and e-mail of the committer and date of commit will be scanned for the given pattern.</dd>
5857 EOT
5858 - my ($have_pickaxe) = gitweb_check_feature('pickaxe');
5858 + my ($have_pickaxe) = gitweb_get_feature('pickaxe');
5859 if ($have_pickaxe) {
5860 print <<EOT;
5861 <dt><b>pickaxe</b></dt>
@@ -5907,7 +5907,7 @@ sub git_shortlog {
5907
5908 sub git_feed {
5909 my $format = shift || 'atom';
5910 - my ($have_blame) = gitweb_check_feature('blame');
5910 + my ($have_blame) = gitweb_get_feature('blame');
5911
5912 # Atom: http://www.atomenabled.org/developers/syndication/
5913 # RSS: http://www.notestips.com/80256B3A007F2692/1/NAMO5P9UPQ