* [PATCH] gitweb: squelch harmless variable scoping errors
@ 2009-08-08 16:50 Mark A Rada
2009-08-08 18:40 ` Junio C Hamano
2009-08-10 15:05 ` Jakub Narebski
0 siblings, 2 replies; 3+ messages in thread
From: Mark A Rada @ 2009-08-08 16:50 UTC (permalink / raw)
To: git; +Cc: Jakub Narebski
I fiddled around a bit and this solution seems to work, but is a bit
odd, as
the method is declared obsolete in the Perl documentation (v5.8.8).
What do you think?
--
Mark A Rada (ferrous26)
marada@uwaterloo.ca
--->8---
This will use the 'vars' method of declaring global variables instead
of the 'our' method.
Though 'vars' has been obsoleted, it has the advantage of pre-declaring
global symbols; this ensures that those symbols will be available to
routines loaded later, whereas 'our' does not seem to do this.
The result is that when using mod_perl you will no longer get any
warnings printed to your error_log.
Signed-off-by: Mark Rada <marada@uwaterloo.ca>
---
gitweb/gitweb.perl | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 37120a3..0544aa2 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -57,12 +57,14 @@ if ($path_info) {
our $GIT = "++GIT_BINDIR++/git";
# absolute fs-path which will be prepended to the project path
-#our $projectroot = "/pub/scm";
-our $projectroot = "++GITWEB_PROJECTROOT++";
+use vars qw($projectroot);
+#$projectroot = "/pub/scm";
+$projectroot = "++GITWEB_PROJECTROOT++";
# fs traversing limit for getting project list
# the number is relative to the projectroot
-our $project_maxdepth = "++GITWEB_PROJECT_MAXDEPTH++";
+use vars qw($project_maxdepth);
+$project_maxdepth = "++GITWEB_PROJECT_MAXDEPTH++";
# target of the home link on top of all pages
our $home_link = $my_uri || "/";
--
1.6.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] gitweb: squelch harmless variable scoping errors
2009-08-08 16:50 [PATCH] gitweb: squelch harmless variable scoping errors Mark A Rada
@ 2009-08-08 18:40 ` Junio C Hamano
2009-08-10 15:05 ` Jakub Narebski
1 sibling, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2009-08-08 18:40 UTC (permalink / raw)
To: Randal L. Schwartz; +Cc: git, Jakub Narebski, Mark A Rada
Mark A Rada <marada@uwaterloo.ca> writes:
> I fiddled around a bit and this solution seems to work, but is a bit
> odd, as the method is declared obsolete in the Perl documentation
> (v5.8.8).
>
> What do you think?
I'd prefer to summon our resident Perl expert ;-)
> --
> Mark A Rada (ferrous26)
> marada@uwaterloo.ca
>
>
> --->8---
> This will use the 'vars' method of declaring global variables instead
> of the 'our' method.
>
> Though 'vars' has been obsoleted, it has the advantage of pre-declaring
> global symbols; this ensures that those symbols will be available to
> routines loaded later, whereas 'our' does not seem to do this.
>
> The result is that when using mod_perl you will no longer get any
> warnings printed to your error_log.
>
> Signed-off-by: Mark Rada <marada@uwaterloo.ca>
> ---
> gitweb/gitweb.perl | 8 +++++---
> 1 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> index 37120a3..0544aa2 100755
> --- a/gitweb/gitweb.perl
> +++ b/gitweb/gitweb.perl
> @@ -57,12 +57,14 @@ if ($path_info) {
> our $GIT = "++GIT_BINDIR++/git";
>
> # absolute fs-path which will be prepended to the project path
> -#our $projectroot = "/pub/scm";
> -our $projectroot = "++GITWEB_PROJECTROOT++";
> +use vars qw($projectroot);
> +#$projectroot = "/pub/scm";
> +$projectroot = "++GITWEB_PROJECTROOT++";
>
> # fs traversing limit for getting project list
> # the number is relative to the projectroot
> -our $project_maxdepth = "++GITWEB_PROJECT_MAXDEPTH++";
> +use vars qw($project_maxdepth);
> +$project_maxdepth = "++GITWEB_PROJECT_MAXDEPTH++";
>
> # target of the home link on top of all pages
> our $home_link = $my_uri || "/";
> --
> 1.6.4
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] gitweb: squelch harmless variable scoping errors
2009-08-08 16:50 [PATCH] gitweb: squelch harmless variable scoping errors Mark A Rada
2009-08-08 18:40 ` Junio C Hamano
@ 2009-08-10 15:05 ` Jakub Narebski
1 sibling, 0 replies; 3+ messages in thread
From: Jakub Narebski @ 2009-08-10 15:05 UTC (permalink / raw)
To: Mark A Rada; +Cc: git, Randal L. Schwartz, Junio C Hamano
On Sat, 8 Aug 2009, Mark A Rada wrote:
> I fiddled around a bit and this solution seems to work, but is a bit
> odd, as the method is declared obsolete in the Perl documentation
> (v5.8.8).
>
> What do you think?
Below there is alternate solution (from asking on #perl channel on
FreeNode).
> --->8---
> This will use the 'vars' method of declaring global variables instead
> of the 'our' method.
>
> Though 'vars' has been obsoleted, it has the advantage of pre-declaring
> global symbols; this ensures that those symbols will be available to
> routines loaded later, whereas 'our' does not seem to do this.
>
> The result is that when using mod_perl you will no longer get any
> warnings printed to your error_log.
>
> Signed-off-by: Mark Rada <marada@uwaterloo.ca>
> ---
> gitweb/gitweb.perl | 8 +++++---
> 1 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> index 37120a3..0544aa2 100755
> --- a/gitweb/gitweb.perl
> +++ b/gitweb/gitweb.perl
> @@ -57,12 +57,14 @@ if ($path_info) {
> our $GIT = "++GIT_BINDIR++/git";
>
> # absolute fs-path which will be prepended to the project path
> -#our $projectroot = "/pub/scm";
> -our $projectroot = "++GITWEB_PROJECTROOT++";
> +use vars qw($projectroot);
> +#$projectroot = "/pub/scm";
> +$projectroot = "++GITWEB_PROJECTROOT++";
>
> # fs traversing limit for getting project list
> # the number is relative to the projectroot
> -our $project_maxdepth = "++GITWEB_PROJECT_MAXDEPTH++";
> +use vars qw($project_maxdepth);
> +$project_maxdepth = "++GITWEB_PROJECT_MAXDEPTH++";
>
> # target of the home link on top of all pages
> our $home_link = $my_uri || "/";
> --
> 1.6.4
Alternate solution could be (please test that it works as intended),
which is a bit simpler, and do not use obsolete 'use vars' pragma,
which is not BLOCK-scoped like other pragmas like 'use strict'.
diff --git i/gitweb/gitweb.perl w/gitweb/gitweb.perl
index ab0cad2..c0fa53c 100755
--- i/gitweb/gitweb.perl
+++ w/gitweb/gitweb.perl
@@ -2308,6 +2305,7 @@ sub git_get_projects_list {
follow_skip => 2, # ignore duplicates
dangling_symlinks => 0, # ignore dangling symlinks, silently
wanted => sub {
+ our ($project_maxdepth, $projectroot);
# skip project-list toplevel, if we get it.
return if (m!^[/.]$!);
# only directories can be git repositories
--
Jakub Narebski
Git User's Survey 2009:
http://tinyurl.com/GitSurvey2009
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-08-10 15:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-08 16:50 [PATCH] gitweb: squelch harmless variable scoping errors Mark A Rada
2009-08-08 18:40 ` Junio C Hamano
2009-08-10 15:05 ` Jakub Narebski
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.