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

[PATCH 1/7] gitweb: Make pickaxe search a feature

From
Jakub Narebski <jnareb@gmail.com>
Date
Sep 6, 2006, 13:08 UTC
Message-ID
<1157548091229-git-send-email-jnareb@gmail.com>
In-Reply-To
<200609061504.40725.jnareb@gmail.com>

As pickaxe search (selected using undocumented 'pickaxe:' operator in search query) is resource consuming, allow to turn it on/off using feature meachanism.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
 gitweb/gitweb.perl |   33 +++++++++++++++++++++++++++++++--
 1 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index d6f546d..e95d16f 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -93,6 +93,11 @@ our %feature = (
 		'override' => 0,
 		#         => [content-encoding, suffix, program]
 		'default' => ['x-gzip', 'gz', 'gzip']},
+
+	'pickaxe' => {
+		'sub' => \&feature_pickaxe,
+		'override' => 0,
+		'default' => [0]},
 );
 
 sub gitweb_check_feature {
@@ -146,6 +151,24 @@ sub feature_snapshot {
 	return ($ctype, $suffix, $command);
 }
 
+# To enable system wide have in $GITWEB_CONFIG
+# $feature{'pickaxe'}{'default'} = [1];
+# To have project specific config enable override in $GITWEB_CONFIG
+# $feature{'pickaxe'}{'override'} = 1;
+# and in project config gitweb.pickaxe = 0|1;
+
+sub feature_pickaxe {
+	my ($val) = git_get_project_config('pickaxe', '--bool');
+
+	if ($val eq 'true') {
+		return (1);
+	} elsif ($val eq 'false') {
+		return (0);
+	}
+
+	return ($_[0]);
+}
+
 # rename detection options for git-diff and git-diff-tree
 # - default is '-M', with the cost proportional to
 #   (number of removed files) * (number of new files).
@@ -3131,8 +3154,7 @@ sub git_search {
 	if (!%co) {
 		die_error(undef, "Unknown commit object");
 	}
-	# 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 :)
+
 	my $commit_search = 1;
 	my $author_search = 0;
 	my $committer_search = 0;
@@ -3144,6 +3166,13 @@ sub git_search {
 	} elsif ($searchtext =~ s/^pickaxe\\://i) {
 		$commit_search = 0;
 		$pickaxe_search = 1;
+
+		# 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
+		my ($have_pickaxe) = gitweb_check_feature('pickaxe');
+		if (!$have_pickaxe) {
+			die_error('403 Permission denied', "Permission denied");
+		}
 	}
 	git_header_html();
 	git_print_page_nav('','', $hash,$co{'tree'},$hash);
-- 
1.4.2
Previous: Jakub NarebskiNext: Jakub Narebski
Message 2 of 28 in “gitweb: Trying to improve history view speed”
  1. 0/7 gitweb: Trying to improve history view speedJakub Narebski, Sep 6, 2006
  2. 1/7 gitweb: Make pickaxe search a featureJakub Narebski, Sep 6, 2006
  3. 2/7 gitweb: Paginate history outputJakub Narebski, Sep 6, 2006
  4. 3/7 gitweb: Use @hist_opts as git-rev-list parameters in git_historyJakub Narebski, Sep 6, 2006
  5. 4/7 gitweb: Add parse_rev_list for later useJakub Narebski, Sep 6, 2006
  6. 5/7 gitweb: Use parse_rev_list in git_shortlog and git_historyJakub Narebski, Sep 6, 2006
  7. 6/7 gitweb: Assume parsed revision list in git_shortlog_body and git_history_bodyJakub Narebski, Sep 6, 2006
  8. 7/7 gitweb: Set page to 0 if it is not defined, in git_historyJakub Narebski, Sep 6, 2006
  9. 8/8 gitweb: Remove --parents from call to git-rev-list in parse_rev_listJakub Narebski, Sep 6, 2006
  10. Linus TorvaldsSep 6, 2006
  11. Jakub NarebskiSep 6, 2006
  12. Junio C HamanoSep 6, 2006
  13. Jakub NarebskiSep 6, 2006
  14. Jakub NarebskiSep 7, 2006
  15. Junio C HamanoSep 7, 2006
  16. Jakub NarebskiSep 7, 2006
  17. Junio C HamanoSep 7, 2006
  18. Jakub NarebskiSep 7, 2006
  19. Linus TorvaldsSep 6, 2006
  20. Jakub NarebskiSep 6, 2006
  21. Linus TorvaldsSep 6, 2006
  22. Jakub NarebskiSep 6, 2006
  23. Linus TorvaldsSep 6, 2006
  24. Junio C HamanoSep 6, 2006
  25. Jakub NarebskiSep 9, 2006
  26. Junio C HamanoSep 9, 2006
  27. Jakub NarebskiSep 9, 2006
  28. Junio C HamanoSep 9, 2006

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

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