{"thread":{"id":"20485","subject":"[PATCH] gitweb: squelch harmless variable scoping errors","startedAt":"2009-08-08T16:50:35Z","lastAt":"2009-08-10T15:05:29Z","messageCount":3,"participants":["Mark A Rada","Junio C Hamano","Jakub Narebski"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"119997","messageId":"F203660D-5123-475D-8288-F398EA670002@mailservices.uwaterloo.ca","threadId":"20485","inReplyTo":null,"subject":"[PATCH] gitweb: squelch harmless variable scoping errors","fromName":"Mark A Rada","fromEmail":"marada@uwaterloo.ca","sentAt":"2009-08-08T16:50:35Z","receivedAt":"2009-08-08T16:50:35Z","isPatch":true,"sender":{"key":"marada@uwaterloo.ca","avatar":"https://avatars.githubusercontent.com/u/38430?v=4"},"body":"I fiddled around a bit and this solution seems to work, but is a bit  \nodd, as\nthe method is declared obsolete in the Perl documentation (v5.8.8).\n\nWhat do you think?\n\n--\nMark A Rada (ferrous26)\nmarada@uwaterloo.ca\n\n\n--->8---\nThis will use the 'vars' method of declaring global variables instead\nof the 'our' method.\n\nThough 'vars' has been obsoleted, it has the advantage of pre-declaring\nglobal symbols; this ensures that those symbols will be available to\nroutines loaded later, whereas 'our' does not seem to do this.\n\nThe result is that when using mod_perl you will no longer get any\nwarnings printed to your error_log.\n\nSigned-off-by: Mark Rada <marada@uwaterloo.ca>\n---\ngitweb/gitweb.perl |    8 +++++---\n1 files changed, 5 insertions(+), 3 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 37120a3..0544aa2 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -57,12 +57,14 @@ if ($path_info) {\nour $GIT = \"++GIT_BINDIR++/git\";\n\n# absolute fs-path which will be prepended to the project path\n-#our $projectroot = \"/pub/scm\";\n-our $projectroot = \"++GITWEB_PROJECTROOT++\";\n+use vars qw($projectroot);\n+#$projectroot = \"/pub/scm\";\n+$projectroot = \"++GITWEB_PROJECTROOT++\";\n\n# fs traversing limit for getting project list\n# the number is relative to the projectroot\n-our $project_maxdepth = \"++GITWEB_PROJECT_MAXDEPTH++\";\n+use vars qw($project_maxdepth);\n+$project_maxdepth = \"++GITWEB_PROJECT_MAXDEPTH++\";\n\n# target of the home link on top of all pages\nour $home_link = $my_uri || \"/\";\n-- \n1.6.4\n"},{"id":"120004","messageId":"7vvdkygne3.fsf@alter.siamese.dyndns.org","threadId":"20485","inReplyTo":"F203660D-5123-475D-8288-F398EA670002@mailservices.uwaterloo.ca","subject":"Re: [PATCH] gitweb: squelch harmless variable scoping errors","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-08-08T18:40:20Z","receivedAt":"2009-08-08T18:40:20Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Mark A Rada <marada@uwaterloo.ca> writes:\n\n> I fiddled around a bit and this solution seems to work, but is a bit\n> odd, as the method is declared obsolete in the Perl documentation\n> (v5.8.8).\n>\n> What do you think?\n\nI'd prefer to summon our resident Perl expert ;-)\n\n> --\n> Mark A Rada (ferrous26)\n> marada@uwaterloo.ca\n>\n>\n> --->8---\n> This will use the 'vars' method of declaring global variables instead\n> of the 'our' method.\n>\n> Though 'vars' has been obsoleted, it has the advantage of pre-declaring\n> global symbols; this ensures that those symbols will be available to\n> routines loaded later, whereas 'our' does not seem to do this.\n>\n> The result is that when using mod_perl you will no longer get any\n> warnings printed to your error_log.\n>\n> Signed-off-by: Mark Rada <marada@uwaterloo.ca>\n> ---\n> gitweb/gitweb.perl |    8 +++++---\n> 1 files changed, 5 insertions(+), 3 deletions(-)\n>\n> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\n> index 37120a3..0544aa2 100755\n> --- a/gitweb/gitweb.perl\n> +++ b/gitweb/gitweb.perl\n> @@ -57,12 +57,14 @@ if ($path_info) {\n> our $GIT = \"++GIT_BINDIR++/git\";\n>\n> # absolute fs-path which will be prepended to the project path\n> -#our $projectroot = \"/pub/scm\";\n> -our $projectroot = \"++GITWEB_PROJECTROOT++\";\n> +use vars qw($projectroot);\n> +#$projectroot = \"/pub/scm\";\n> +$projectroot = \"++GITWEB_PROJECTROOT++\";\n>\n> # fs traversing limit for getting project list\n> # the number is relative to the projectroot\n> -our $project_maxdepth = \"++GITWEB_PROJECT_MAXDEPTH++\";\n> +use vars qw($project_maxdepth);\n> +$project_maxdepth = \"++GITWEB_PROJECT_MAXDEPTH++\";\n>\n> # target of the home link on top of all pages\n> our $home_link = $my_uri || \"/\";\n> -- \n> 1.6.4\n"},{"id":"120162","messageId":"200908101705.30521.jnareb@gmail.com","threadId":"20485","inReplyTo":"F203660D-5123-475D-8288-F398EA670002@mailservices.uwaterloo.ca","subject":"Re: [PATCH] gitweb: squelch harmless variable scoping errors","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2009-08-10T15:05:29Z","receivedAt":"2009-08-10T15:05:29Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Sat, 8 Aug 2009, Mark A Rada wrote:\n\n> I fiddled around a bit and this solution seems to work, but is a bit  \n> odd, as the method is declared obsolete in the Perl documentation\n> (v5.8.8). \n> \n> What do you think?\n\nBelow there is alternate solution (from asking on #perl channel on\nFreeNode).\n\n> --->8---\n> This will use the 'vars' method of declaring global variables instead\n> of the 'our' method.\n> \n> Though 'vars' has been obsoleted, it has the advantage of pre-declaring\n> global symbols; this ensures that those symbols will be available to\n> routines loaded later, whereas 'our' does not seem to do this.\n> \n> The result is that when using mod_perl you will no longer get any\n> warnings printed to your error_log.\n> \n> Signed-off-by: Mark Rada <marada@uwaterloo.ca>\n> ---\n> gitweb/gitweb.perl |    8 +++++---\n> 1 files changed, 5 insertions(+), 3 deletions(-)\n> \n> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\n> index 37120a3..0544aa2 100755\n> --- a/gitweb/gitweb.perl\n> +++ b/gitweb/gitweb.perl\n> @@ -57,12 +57,14 @@ if ($path_info) {\n> our $GIT = \"++GIT_BINDIR++/git\";\n> \n> # absolute fs-path which will be prepended to the project path\n> -#our $projectroot = \"/pub/scm\";\n> -our $projectroot = \"++GITWEB_PROJECTROOT++\";\n> +use vars qw($projectroot);\n> +#$projectroot = \"/pub/scm\";\n> +$projectroot = \"++GITWEB_PROJECTROOT++\";\n> \n> # fs traversing limit for getting project list\n> # the number is relative to the projectroot\n> -our $project_maxdepth = \"++GITWEB_PROJECT_MAXDEPTH++\";\n> +use vars qw($project_maxdepth);\n> +$project_maxdepth = \"++GITWEB_PROJECT_MAXDEPTH++\";\n> \n> # target of the home link on top of all pages\n> our $home_link = $my_uri || \"/\";\n> -- \n> 1.6.4\n\nAlternate solution could be (please test that it works as intended),\nwhich is a bit simpler, and do not use obsolete 'use vars' pragma,\nwhich is not BLOCK-scoped like other pragmas like 'use strict'.\n\ndiff --git i/gitweb/gitweb.perl w/gitweb/gitweb.perl\nindex ab0cad2..c0fa53c 100755\n--- i/gitweb/gitweb.perl\n+++ w/gitweb/gitweb.perl\n@@ -2308,6 +2305,7 @@ sub git_get_projects_list {\n \t\t\tfollow_skip => 2, # ignore duplicates\n \t\t\tdangling_symlinks => 0, # ignore dangling symlinks, silently\n \t\t\twanted => sub {\n+\t\t\t\tour ($project_maxdepth, $projectroot);\n \t\t\t\t# skip project-list toplevel, if we get it.\n \t\t\t\treturn if (m!^[/.]$!);\n \t\t\t\t# only directories can be git repositories\n\n\n\n-- \nJakub Narebski\n\nGit User's Survey 2009:\nhttp://tinyurl.com/GitSurvey2009\n"}]}