{"thread":{"id":"15868","subject":"[PATCH/RFC] gitweb: Separate features with no project specific override","startedAt":"2008-10-12T13:05:41Z","lastAt":"2008-10-12T21:00:25Z","messageCount":2,"participants":["Jakub Narebski"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"92837","messageId":"20081012130157.26825.67398.stgit@localhost.localdomain","threadId":"15868","inReplyTo":null,"subject":"[PATCH/RFC] gitweb: Separate features with no project specific override","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2008-10-12T13:05:41Z","receivedAt":"2008-10-12T13:05:41Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Put features for which project specific override is not supported into\nseparate %global_feature hash, updating gitweb_check_feature()\nsubroutine to use it.\n\nWhile at it remove stale comment for 'pathinfo' feature; requiring to\nuse workaround specified was fixed in b65910f (gitweb: remove\nPATH_INFO from $my_url and $my_uri).\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\nThis patch has the advantage of clear separation of non-overridable\nand overridable features; currently the only difference is lack of\nsubroutine and comment on feature.  For non-overridable features the\ncomplexisty of {'sub'=>..., 'override'=>..., 'default'=>...} is not\nneeded.\n\nIt has the disadvantage of invalidating old gitweb configuration, and\nthat now there are two sources of gitweb config.\n\nFIX IT: some spurious \"HASH..\" is printed to STDERR (by my 'run gitweb\nfrom command line' script), which I didn't found yet.\n\n gitweb/gitweb.perl |   59 ++++++++++++++++++++++++----------------------------\n 1 files changed, 27 insertions(+), 32 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex cc6edbe..82068f9 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -215,13 +215,6 @@ our %feature = (\n \t\t'override' => 0,\n \t\t'default' => ['tgz']},\n \n-\t# Enable text search, which will list the commits which match author,\n-\t# committer or commit text to a given string.  Enabled by default.\n-\t# Project specific override is not supported.\n-\t'search' => {\n-\t\t'override' => 0,\n-\t\t'default' => [1]},\n-\n \t# Enable grep search, which will list the files in currently selected\n \t# tree containing the given string. Enabled by default. This can be\n \t# potentially CPU-intensive, of course.\n@@ -248,6 +241,18 @@ our %feature = (\n \t\t'sub' => \\&feature_pickaxe,\n \t\t'override' => 0,\n \t\t'default' => [1]},\n+);\n+\n+our %global_feature = (\n+\t# feature => [ default options...] (array reference)\n+\t#\n+\t# For those features project specific override is not supported.\n+\t#\n+\t# use gitweb_check_feature(<feature>) to check if <feature> is enabled\n+\n+\t# Enable text search, which will list the commits which match author,\n+\t# committer or commit text to a given string.  Enabled by default.\n+\t'search' => [1],\n \n \t# Make gitweb use an alternative format of the URLs which can be\n \t# more readable and natural-looking: project name is embedded\n@@ -257,16 +262,8 @@ our %feature = (\n \t# generates links.\n \n \t# To enable system wide have in $GITWEB_CONFIG\n-\t# $feature{'pathinfo'}{'default'} = [1];\n-\t# Project specific override is not supported.\n-\n-\t# Note that you will need to change the default location of CSS,\n-\t# favicon, logo and possibly other files to an absolute URL. Also,\n-\t# if gitweb.cgi serves as your indexfile, you will need to force\n-\t# $my_uri to contain the script name in your $GITWEB_CONFIG.\n-\t'pathinfo' => {\n-\t\t'override' => 0,\n-\t\t'default' => [0]},\n+\t# $global_feature{'pathinfo'} = [1];\n+\t'pathinfo' => [0],\n \n \t# Make gitweb consider projects in project root subdirectories\n \t# to be forks of existing projects. Given project $projname.git,\n@@ -277,11 +274,8 @@ our %feature = (\n \t# to be listed after the main project.\n \n \t# To enable system wide have in $GITWEB_CONFIG\n-\t# $feature{'forks'}{'default'} = [1];\n-\t# Project specific override is not supported.\n-\t'forks' => {\n-\t\t'override' => 0,\n-\t\t'default' => [0]},\n+\t# $global_feature{'forks'} = [1];\n+\t'forks' => [0],\n \n \t# Insert custom links to the action bar of all project pages.\n \t# This enables you mainly to link to third-party scripts integrating\n@@ -296,12 +290,9 @@ our %feature = (\n \t# hash base (hb gitweb parameter); %% expands to %.\n \n \t# To enable system wide have in $GITWEB_CONFIG e.g.\n-\t# $feature{'actions'}{'default'} = [('graphiclog',\n+\t# $global_feature{'actions'} = [('graphiclog',\n \t# \t'/git-browser/by-commit.html?r=%n', 'summary')];\n-\t# Project specific override is not supported.\n-\t'actions' => {\n-\t\t'override' => 0,\n-\t\t'default' => []},\n+\t'actions' => [],\n \n \t# Allow gitweb scan project content tags described in ctags/\n \t# of project repository, and display the popular Web 2.0-ish\n@@ -315,16 +306,20 @@ our %feature = (\n \t# a pretty tag cloud instead of just a list of tags.\n \n \t# To enable system wide have in $GITWEB_CONFIG\n-\t# $feature{'ctags'}{'default'} = ['path_to_tag_script'];\n+\t# $global_feature{'ctags'} = ['path_to_tag_script'];\n \t# Project specific override is not supported.\n-\t'ctags' => {\n-\t\t'override' => 0,\n-\t\t'default' => [0]},\n+\t'ctags' => [0],\n );\n \n sub gitweb_check_feature {\n-\tmy ($name) = @_;\n+\tmy $name = shift;\n+\n+\tif (exists $global_feature{$name}) {\n+\t\treturn @{$global_feature{$name}};\n+\t}\n+\n \treturn unless exists $feature{$name};\n+\n \tmy ($sub, $override, @defaults) = (\n \t\t$feature{$name}{'sub'},\n \t\t$feature{$name}{'override'},\n\n-- \nStacked GIT 0.14.3\ngit version 1.6.0.2\n"},{"id":"92873","messageId":"20081012205925.29606.36935.stgit@localhost.localdomain","threadId":"15868","inReplyTo":"20081012130157.26825.67398.stgit@localhost.localdomain","subject":"[PATCH/RFC v2] gitweb: Separate %global_features","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2008-10-12T21:00:25Z","receivedAt":"2008-10-12T21:00:25Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Put features for which project specific override is not supported into\nseparate %global_feature hash, updating gitweb_check_feature()\nsubroutine to use it.  For backward compatibility with existing gitweb\nconfiguration setups $feature{<feature>}{'default'} has preference\nover $global_feature{<feature>}.\n\nWhile at it remove stale comment for 'pathinfo' feature; requiring to\nuse workaround specified was fixed in b65910f (gitweb: remove\nPATH_INFO from $my_url and $my_uri).\n\nFIX IT: some spurious \"HASH..\" is printed to STDERR.\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\nThis should be backward compatibile...\n\n gitweb/gitweb.perl |   66 ++++++++++++++++++++++++++--------------------------\n 1 files changed, 33 insertions(+), 33 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex cc6edbe..88bedec 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -215,13 +215,6 @@ our %feature = (\n \t\t'override' => 0,\n \t\t'default' => ['tgz']},\n \n-\t# Enable text search, which will list the commits which match author,\n-\t# committer or commit text to a given string.  Enabled by default.\n-\t# Project specific override is not supported.\n-\t'search' => {\n-\t\t'override' => 0,\n-\t\t'default' => [1]},\n-\n \t# Enable grep search, which will list the files in currently selected\n \t# tree containing the given string. Enabled by default. This can be\n \t# potentially CPU-intensive, of course.\n@@ -248,6 +241,20 @@ our %feature = (\n \t\t'sub' => \\&feature_pickaxe,\n \t\t'override' => 0,\n \t\t'default' => [1]},\n+);\n+\n+our %global_feature = (\n+\t# feature => [ default options...] (array reference)\n+\t#\n+\t# For those features project specific override is not supported.\n+\t# Note that for backwards compatibility of existing gitweb\n+\t# configurations $feature{<feature>}{'default'} has preference.\n+\n+\t# use gitweb_check_feature(<feature>) to check if <feature> is enabled\n+\n+\t# Enable text search, which will list the commits which match author,\n+\t# committer or commit text to a given string.  Enabled by default.\n+\t'search' => [1],\n \n \t# Make gitweb use an alternative format of the URLs which can be\n \t# more readable and natural-looking: project name is embedded\n@@ -257,16 +264,8 @@ our %feature = (\n \t# generates links.\n \n \t# To enable system wide have in $GITWEB_CONFIG\n-\t# $feature{'pathinfo'}{'default'} = [1];\n-\t# Project specific override is not supported.\n-\n-\t# Note that you will need to change the default location of CSS,\n-\t# favicon, logo and possibly other files to an absolute URL. Also,\n-\t# if gitweb.cgi serves as your indexfile, you will need to force\n-\t# $my_uri to contain the script name in your $GITWEB_CONFIG.\n-\t'pathinfo' => {\n-\t\t'override' => 0,\n-\t\t'default' => [0]},\n+\t# $global_feature{'pathinfo'} = [1];\n+\t'pathinfo' => [0],\n \n \t# Make gitweb consider projects in project root subdirectories\n \t# to be forks of existing projects. Given project $projname.git,\n@@ -277,11 +276,8 @@ our %feature = (\n \t# to be listed after the main project.\n \n \t# To enable system wide have in $GITWEB_CONFIG\n-\t# $feature{'forks'}{'default'} = [1];\n-\t# Project specific override is not supported.\n-\t'forks' => {\n-\t\t'override' => 0,\n-\t\t'default' => [0]},\n+\t# $global_feature{'forks'} = [1];\n+\t'forks' => [0],\n \n \t# Insert custom links to the action bar of all project pages.\n \t# This enables you mainly to link to third-party scripts integrating\n@@ -296,12 +292,9 @@ our %feature = (\n \t# hash base (hb gitweb parameter); %% expands to %.\n \n \t# To enable system wide have in $GITWEB_CONFIG e.g.\n-\t# $feature{'actions'}{'default'} = [('graphiclog',\n+\t# $global_feature{'actions'} = [('graphiclog',\n \t# \t'/git-browser/by-commit.html?r=%n', 'summary')];\n-\t# Project specific override is not supported.\n-\t'actions' => {\n-\t\t'override' => 0,\n-\t\t'default' => []},\n+\t'actions' => [],\n \n \t# Allow gitweb scan project content tags described in ctags/\n \t# of project repository, and display the popular Web 2.0-ish\n@@ -315,16 +308,23 @@ our %feature = (\n \t# a pretty tag cloud instead of just a list of tags.\n \n \t# To enable system wide have in $GITWEB_CONFIG\n-\t# $feature{'ctags'}{'default'} = ['path_to_tag_script'];\n+\t# $global_feature{'ctags'} = ['path_to_tag_script'];\n \t# Project specific override is not supported.\n-\t'ctags' => {\n-\t\t'override' => 0,\n-\t\t'default' => [0]},\n+\t'ctags' => [0],\n );\n \n sub gitweb_check_feature {\n-\tmy ($name) = @_;\n-\treturn unless exists $feature{$name};\n+\tmy $name = shift;\n+\n+\t# %feature has precedence over %global_feature for backward\n+\t# compatibility with pre-existing gitweb configuration setups\n+\tunless (exists $feature{$name}) {\n+\t\tif (exists $global_feature{$name}) {\n+\t\t\treturn @{$global_feature{$name}};\n+\t\t}\n+\t\treturn;\n+\t}\n+\n \tmy ($sub, $override, @defaults) = (\n \t\t$feature{$name}{'sub'},\n \t\t$feature{$name}{'override'},\n"}]}