{"thread":{"id":"23639","subject":"[PATCH] gitweb: Silence 'Variable VAR may be unavailable' warnings","startedAt":"2010-04-30T16:30:31Z","lastAt":"2010-04-30T16:30:31Z","messageCount":1,"participants":["Jakub Narebski"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"140641","messageId":"20100430162934.11548.7015.stgit@localhost.localdomain","threadId":"23639","inReplyTo":null,"subject":"[PATCH] gitweb: Silence 'Variable VAR may be unavailable' warnings","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2010-04-30T16:30:31Z","receivedAt":"2010-04-30T16:30:31Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"When $projects_list points to a directory, and git_get_projects_list\nscans this directory for repositories, there can be generated the\nfollowing warnings (for persistent services like mod_perl or plackup):\n\n  Variable \"$project_maxdepth\" may be unavailable at gitweb.cgi line 2443.\n  Variable \"$projectroot\" may be unavailable at gitweb.cgi line 2451.\n\nThose are false positives; silence those warnings by explicitely\ndeclaring $project_maxdepth and $projectroot with 'our', as global\nvariables, in anonymous subrotine passed to File::Find::find.\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\nThose warnings do not appear when run as simple CGI script, so test\nsuite could not catch them.\n\n gitweb/gitweb.perl |    3 +++\n 1 files changed, 3 insertions(+), 0 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 7d9b660..d6cbfa9 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -2433,6 +2433,9 @@ 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\t# global variables\n+\t\t\t\tour $project_maxdepth;\n+\t\t\t\tour $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"}]}