{"thread":{"id":"5533","subject":"[PATCH] gitweb: Make pickaxe search a feature","startedAt":"2006-09-10T22:29:27Z","lastAt":"2006-09-10T22:29:27Z","messageCount":1,"participants":["Jakub Narebski"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"26702","messageId":"200609110029.28021.jnareb@gmail.com","threadId":"5533","inReplyTo":null,"subject":"[PATCH] gitweb: Make pickaxe search a feature","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-09-10T22:29:27Z","receivedAt":"2006-09-10T22:29:27Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"As pickaxe search (selected using undocumented 'pickaxe:' operator in\nsearch query) is resource consuming, allow to turn it on/off using\nfeature meachanism.  Turned on by default, for historical reasons.\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\nThe difference compared to the previous version is that it is turned\non by default.\n\n gitweb/gitweb.perl |   33 +++++++++++++++++++++++++++++++--\n 1 files changed, 31 insertions(+), 2 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex d89f709..53e3478 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -90,6 +90,11 @@ our %feature = (\n \t\t'override' => 0,\n \t\t#         => [content-encoding, suffix, program]\n \t\t'default' => ['x-gzip', 'gz', 'gzip']},\n+\n+\t'pickaxe' => {\n+\t\t'sub' => \\&feature_pickaxe,\n+\t\t'override' => 0,\n+\t\t'default' => [1]},\n );\n \n sub gitweb_check_feature {\n@@ -143,6 +148,24 @@ sub feature_snapshot {\n \treturn ($ctype, $suffix, $command);\n }\n \n+# To enable system wide have in $GITWEB_CONFIG\n+# $feature{'pickaxe'}{'default'} = [1];\n+# To have project specific config enable override in $GITWEB_CONFIG\n+# $feature{'pickaxe'}{'override'} = 1;\n+# and in project config gitweb.pickaxe = 0|1;\n+\n+sub feature_pickaxe {\n+\tmy ($val) = git_get_project_config('pickaxe', '--bool');\n+\n+\tif ($val eq 'true') {\n+\t\treturn (1);\n+\t} elsif ($val eq 'false') {\n+\t\treturn (0);\n+\t}\n+\n+\treturn ($_[0]);\n+}\n+\n # rename detection options for git-diff and git-diff-tree\n # - default is '-M', with the cost proportional to\n #   (number of removed files) * (number of new files).\n@@ -3128,8 +3151,7 @@ sub git_search {\n \tif (!%co) {\n \t\tdie_error(undef, \"Unknown commit object\");\n \t}\n-\t# pickaxe may take all resources of your box and run for several minutes\n-\t# with every query - so decide by yourself how public you make this feature :)\n+\n \tmy $commit_search = 1;\n \tmy $author_search = 0;\n \tmy $committer_search = 0;\n@@ -3141,6 +3163,13 @@ sub git_search {\n \t} elsif ($searchtext =~ s/^pickaxe\\\\://i) {\n \t\t$commit_search = 0;\n \t\t$pickaxe_search = 1;\n+\n+\t\t# pickaxe may take all resources of your box and run for several minutes\n+\t\t# with every query - so decide by yourself how public you make this feature\n+\t\tmy ($have_pickaxe) = gitweb_check_feature('pickaxe');\n+\t\tif (!$have_pickaxe) {\n+\t\t\tdie_error('403 Permission denied', \"Permission denied\");\n+\t\t}\n \t}\n \tgit_header_html();\n \tgit_print_page_nav('','', $hash,$co{'tree'},$hash);\n-- \n1.4.2\n"}]}