Skip to contentSkip to conversation

gitweb: Create Gitweb::Config module

PATCH In review Pavan Kumar Sunkara 4 participants 13 messages Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 gitweb: Create Gitweb::Config module

Create Gitweb::Config module in 'gitweb/lib/Gitweb/Config.pm' to store all the configuration variables of the gitweb.perl script.

Subroutines moved:
evaluate_gitweb_config
evaluate_git_version

Subroutines yet to move: (Contains calls to not yet packaged subs)
gitweb_get_feature
gitweb_check_feature

Update gitweb/Makefile to install gitweb modules alongside gitweb

---

This patch is based on branch 'pu' of alt-git.git

 gitweb/Makefile             |    6 +
 gitweb/gitweb.perl          |  421 +++----------------------------------------
 gitweb/lib/Gitweb/Config.pm |  413 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 447 insertions(+), 393 deletions(-)
 create mode 100644 gitweb/lib/Gitweb/Config.pm
gitweb/Makefile +6 -0
index d2584fe..45e176e 100644
@@ -55,6 +55,7 @@ PERL_PATH  ?= /usr/bin/perl
 bindir_SQ = $(subst ','\'',$(bindir))#'
 gitwebdir_SQ = $(subst ','\'',$(gitwebdir))#'
 gitwebstaticdir_SQ = $(subst ','\'',$(gitwebdir)/static)#'
+gitweblibdir_SQ = $(subst ','\'',$(gitwebdir)/lib)#'
 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))#'
 PERL_PATH_SQ  = $(subst ','\'',$(PERL_PATH))#'
 DESTDIR_SQ    = $(subst ','\'',$(DESTDIR))#'
@@ -110,6 +111,9 @@ endif
 
 GITWEB_FILES += static/git-logo.png static/git-favicon.png
 
+# Files: gitweb/lib/Gitweb
+GITWEB_LIB_GITWEB += lib/Gitweb/Config.pm
+
 GITWEB_REPLACE = \
 	-e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \
 	-e 's|++GIT_BINDIR++|$(bindir)|g' \
@@ -150,6 +154,8 @@ install: all
 	$(INSTALL) -m 755 $(GITWEB_PROGRAMS) '$(DESTDIR_SQ)$(gitwebdir_SQ)'
 	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)'
 	$(INSTALL) -m 644 $(GITWEB_FILES) '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)'
+	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitweblibdir_SQ)/Gitweb'
+	$(INSTALL) -m 644 $(GITWEB_LIB_GITWEB) '$(DESTDIR_SQ)$(gitweblibdir_SQ)/Gitweb'
 
 ### Cleaning rules
 
gitweb/gitweb.perl +28 -393

498 lines not on this page · raw message

gitweb/lib/Gitweb/Config.pm new file +413 -0

413 lines not on this page · raw message

Signature · 1 line
1.7.1.447.gfddfb
#1 lore raw

PATCH 2/3 gitweb: Create Gitweb::Request module

Create a Gitweb::Request module in 'gitweb/lib/Gitweb/Request.pm' to store and handle all the cgi params and related variables regarding the gitweb.perl script.

Subroutines moved:
evaluate_uri
evaluate_query_params
evaluate_git_dir
validate_pathname
validate_refname

Subroutines yet to move: (Contains calls to not yet packages subs)
evaluate_path_info
evaluate_and _validate_params
validate_action
validate_project

Update gitweb/Makefile to install gitweb modules alongside gitweb

---

This patch is based on branch 'pu' and previous patch.

 gitweb/Makefile              |    1 +
 gitweb/gitweb.perl           |  165 ++++--------------------------------------
 gitweb/lib/Gitweb/Request.pm |  156 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 171 insertions(+), 151 deletions(-)
 create mode 100644 gitweb/lib/Gitweb/Request.pm
gitweb/Makefile +1 -0
index 45e176e..15646b2 100644
@@ -113,6 +113,7 @@ GITWEB_FILES += static/git-logo.png static/git-favicon.png
 
 # Files: gitweb/lib/Gitweb
 GITWEB_LIB_GITWEB += lib/Gitweb/Config.pm
+GITWEB_LIB_GITWEB += lib/Gitweb/Request.pm
 
 GITWEB_REPLACE = \
 	-e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \
gitweb/gitweb.perl +14 -151

287 lines not on this page · raw message

gitweb/lib/Gitweb/Request.pm new file +156 -0

156 lines not on this page · raw message

Signature · 1 line
1.7.1.447.gfddfb
#2 lore raw

PATCH 3/3 git-instaweb: Add support for --reuse-config using gitconfig

In reply to Pavan Kumar Sunkara

Support instaweb's --reuse-config using instaweb.overwrite variable in gitconfig.

To use --reuse-config always
[instaweb]
overwrite = false

---

This patch is based on branch 'pu' and my previous patch
http://thread.gmane.org/gmane.comp.version-control.git/148161

 Documentation/git-instaweb.txt |    2 ++
 git-instaweb.sh                |    5 ++++-
 2 files changed, 6 insertions(+), 1 deletions(-)
Documentation/git-instaweb.txt +2 -0
index 0e7e20b..12cbe1d 100644
@@ -77,6 +77,8 @@ You may specify configuration in your .git/config
 	port = 4321
 	browser = konqueror
 	modulepath = /usr/lib/apache2/modules
+	gitwebdir = /usr/share/gitweb
+	overwrite = false
 
 -----------------------------------------------------------------------
 
git-instaweb.sh +4 -1
index 1c704a3..3635974 100755
@@ -28,7 +28,7 @@ httpd="$(git config --get instaweb.httpd)"
 root="$(git config --get instaweb.gitwebdir)"
 port=$(git config --get instaweb.port)
 module_path="$(git config --get instaweb.modulepath)"
-no_reuse=true
+no_reuse="$(git config --bool --get instaweb.overwrite)"
 
 conf="$GIT_DIR/gitweb/httpd.conf"
 
@@ -43,6 +43,9 @@ test -z "$root" && root='@@GITWEBDIR@@'
 # any untaken local port will do...
 test -z "$port" && port=1234
 
+# Default is true -> overwrite gitweb_config.perl
+test -z "$no_reuse" && no_reuse=true
+
 resolve_full_httpd () {
 	case "$httpd" in
 	*apache2*|*lighttpd*)
Signature · 1 line
1.7.1.447.gfddfb
#3 lore raw
In reply to Pavan Kumar Sunkara

Hi!

I think this is a good start!

I have couple of concerns; maybe they were addressed in the previous
discussion which I admit I did not read completely, but in that case they ought to be addressed in the commit message as well.

gitweb/gitweb.perl use Encode; · line 23

Quoted 3 lines · Pavan Kumar Sunkara
gitweb/gitweb.perl +0 -3
-our $t0;
-if (eval { require Time::HiRes; 1; }) {
-	$t0 = [Time::HiRes::gettimeofday()];

Why is this moved to Gitweb::Config? Shouldn't this be rather part of Gitweb::Request?

gitweb/gitweb.perl use Encode; · line 26

Quoted 6 lines
gitweb/gitweb.perl +4 -1
+# __DIR__ is taken from Dir::Self __DIR__ fragment
+sub __DIR__ () {
+	File::Spec->rel2abs(join '', (File::Spec->splitpath(__FILE__))[0, 1]);
 }
-our $number_of_git_cmds = 0;
+use lib __DIR__ . "/lib";

Wouldn't it be more elegant to use FindBin? I'm just not sure how long is it part of core Perl.

Quoted 13 lines
gitweb/gitweb.perl +3 -1
+
+use Gitweb::Config;
 
 BEGIN {
 	CGI->compile() if $ENV{'MOD_PERL'};
 }
 
-our $version = "++GIT_VERSION++";
+$version = "++GIT_VERSION++";
 
 our ($my_url, $my_uri, $base_url, $path_info, $home_link);
 sub evaluate_uri {

gitweb/gitweb.perl sub evaluate_uri { · line 74

Quoted 5 lines
gitweb/gitweb.perl +1 -1
@@ -68,402 +71,58 @@ sub evaluate_uri {
 
 # core git executable to use
 # this can just be "git" if your webserver has a sensible PATH
-our $GIT = "++GIT_BINDIR++/git";
+$GIT = "++GIT_BINDIR++/git";

I dislike the new schema in one aspect - the list of configuration variables together with their description is not at a single place
anymore: the build-time overridable variables have their descriptions still in gitweb.pl and only very brief mentions in Gitweb::Config, while the rest has moved fully to Gitweb::Config. I think it would be best to move all descriptions to Gitweb::Config and keep only the override assignments in gitweb.pl. So, Gitweb::Config would have

	# core git executable to use
	# this can just be "git" if your webserver has a sensible PATH
	our $GIT;

and gitweb.pl would have _just_

	$GIT = "++GIT_BINDIR++/git";

How does that sound?

I think you ought to add a comment in front of this section explaining that not all configuration variables are listed here anymore. Something like

# Only configuration variables with build-time overridable # defaults are listed below. The complete set of variables # with their descriptions is listed in Gitweb::Config.

gitweb/gitweb.perl sub evaluate_uri { · line 90

Quoted 5 lines
gitweb/gitweb.perl +1 -1
 # name of your site or organization to appear in page titles
 # replace this with something more descriptive for clearer bookmarks
-our $site_name = "++GITWEB_SITENAME++"
+$site_name = "++GITWEB_SITENAME++"
                  || ($ENV{'SERVER_NAME'} || "Untitled") . " Git";

This looks like some new feature; please do that in a separate patch. (BTW, I assume that there are no other changes like this in the rest of the moved code blocks!)

Signature · 3 lines
				Petr "Pasky" Baudis
The true meaning of life is to plant a tree under whose shade
you will never sit.
#4 lore raw
Quoted 5 lines · Petr Baudis

I have couple of concerns; maybe they were addressed in the previous
discussion which I admit I did not read completely, but in that case they ought to be addressed in the commit message as well.

Quoted 7 lines

gitweb/gitweb.perl use Encode; · line 23

Quoted 3 lines · Pavan Kumar Sunkara
gitweb/gitweb.perl +0 -3
-our $t0;
-if (eval { require Time::HiRes; 1; }) {
-	$t0 = [Time::HiRes::gettimeofday()];

Why is this moved to Gitweb::Config? Shouldn't this be rather part of Gitweb::Request?

I also think that this should be either part of Gitweb::Request, oe even be left in gitweb.perl. I think having it in Gitweb::Request would be a better idea, because it is about time (and number of git commands) it took to process request.

Quoted 9 lines

gitweb/gitweb.perl use Encode; · line 26

Quoted 6 lines
gitweb/gitweb.perl +4 -1
+# __DIR__ is taken from Dir::Self __DIR__ fragment
+sub __DIR__ () {
+	File::Spec->rel2abs(join '', (File::Spec->splitpath(__FILE__))[0, 1]);
 }
-our $number_of_git_cmds = 0;
+use lib __DIR__ . "/lib";

Wouldn't it be more elegant to use FindBin? I'm just not sure how long is it part of core Perl.

Actually FindBin is in core since 5.4, and we require Perl 5.8+ for gitweb anyway (for Encode and proper Unicode support).

But from what I've heard FindBin is not recommended anymore, although perhaps the disadvantages of FindBin doesn't matter in our situation.

Quoted 1 line

From FindBin(3pm) manpage:

KNOWN ISSUES

If there are two modules using FindBin from different directories under the same interpreter, this won't work. Since FindBin uses a BEGIN block, it'll be executed only once, and only the first caller will get it right. **This is a problem under mod_perl** and other persistent Perl environments, where you shouldn't use this module.

Quoted 4 lines

From what I remember there might also be problems with symlinks.

From Dir::Self(3pm) manpage:

DESCRIPTION

Perl has two pseudo-constants describing the current location in your source code, __FILE__ and __LINE__. This module adds __DIR__, which expands to the directory your source file is in, as an absolute pathname.

This is useful if your code wants to access files in the same directory, like helper modules or configuration data. This is a bit like FindBin except it's not limited to the main program, i.e. you can also use it in modules. **And it actually works.**

Is there on git mailing list a Perl hacker that can tell us one way or another? (Not that this matter much, if it works).

Quoted 10 lines

gitweb/gitweb.perl use Encode; · line 34

Quoted 10 lines
gitweb/gitweb.perl +3 -1
+
+use Gitweb::Config;
 
 BEGIN {
 	CGI->compile() if $ENV{'MOD_PERL'};
 }
 
-our $version = "++GIT_VERSION++";
+$version = "++GIT_VERSION++";

This change is not necessary.

  our $version = "++GIT_VERSION++";

would keep working even if '$version' is declared in other module and exported by this module (is imported into current scope).

Quoted 18 lines

gitweb/gitweb.perl sub evaluate_uri { · line 74

Quoted 9 lines

our ($my_url, $my_uri, $base_url, $path_info, $home_link); sub evaluate_uri {

gitweb/gitweb.perl +1 -1
@@ -68,402 +71,58 @@ sub evaluate_uri {
 
 # core git executable to use
 # this can just be "git" if your webserver has a sensible PATH
-our $GIT = "++GIT_BINDIR++/git";
+$GIT = "++GIT_BINDIR++/git";

I dislike the new schema in one aspect - the list of configuration variables together with their description is not at a single place
anymore: the build-time overridable variables have their descriptions still in gitweb.pl and only very brief mentions in Gitweb::Config, while the rest has moved fully to Gitweb::Config. I think it would be best to move all descriptions to Gitweb::Config and keep only the override assignments in gitweb.pl. So, Gitweb::Config would have

Quoted 3 lines
	# core git executable to use
	# this can just be "git" if your webserver has a sensible PATH
	our $GIT;

Good idea.

Perhaps we should provide some sane default fallback values, like for example

  	our $GIT = "git";
Quoted 4 lines

and gitweb.pl would have _just_

	$GIT = "++GIT_BINDIR++/git";

I would say

  	our $GIT = "++GIT_BINDIR++/git";
Quoted 7 lines

I think you ought to add a comment in front of this section explaining that not all configuration variables are listed here anymore. Something like

# Only configuration variables with build-time overridable # defaults are listed below. The complete set of variables # with their descriptions is listed in Gitweb::Config.

Right. I wholehartily agree.

Quoted 9 lines

gitweb/gitweb.perl sub evaluate_uri { · line 90

Quoted 5 lines
gitweb/gitweb.perl +1 -1
 # name of your site or organization to appear in page titles
 # replace this with something more descriptive for clearer bookmarks
-our $site_name = "++GITWEB_SITENAME++"
+$site_name = "++GITWEB_SITENAME++"
                  || ($ENV{'SERVER_NAME'} || "Untitled") . " Git";

This looks like some new feature; please do that in a separate patch. (BTW, I assume that there are no other changes like this in the rest of the moved code blocks!)

No, it isn't. And without 'our $var = VALUE' -> '$var = VALUE' change, which is not necessary and artifically inflates the size of patch, this chunk wouldn't even be present.

Signature · 2 lines
Jakub Narebski
Poland
#5 lore raw
Quoted 2 lines · Jakub Narebski

But from what I've heard FindBin is not recommended anymore, although perhaps the disadvantages of FindBin doesn't matter in our situation.

Ah, never mind then. It's probably more trouble than it's worth, even if it's not problematic for us right at the moment.

Quoted 12 lines
Quoted 9 lines

gitweb/gitweb.perl use Encode; · line 34

Quoted 9 lines
gitweb/gitweb.perl +3 -1
+
+use Gitweb::Config;
 
 BEGIN {
 	CGI->compile() if $ENV{'MOD_PERL'};
 }
 
-our $version = "++GIT_VERSION++";
+$version = "++GIT_VERSION++";

This change is not necessary.

Quoted 4 lines
  our $version = "++GIT_VERSION++";

would keep working even if '$version' is declared in other module and exported by this module (is imported into current scope).

Hmm, that's right, but it feels dirty since it strongly suggests that $version is then a variable local to this package. It would reduce the diff size, but I perosnally don't think it's worth it. I'll leave this up to Pavan personally, though.

Quoted 4 lines

Perhaps we should provide some sane default fallback values, like for example

  	our $GIT = "git";

I considered that, but I'm not too fond of this within this patch, I'd rather keep the pieces simple and stupid.

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
 # name of your site or organization to appear in page titles
 # replace this with something more descriptive for clearer bookmarks
-our $site_name = "++GITWEB_SITENAME++"
+$site_name = "++GITWEB_SITENAME++"
                  || ($ENV{'SERVER_NAME'} || "Untitled") . " Git";
Quoted 7 lines
Quoted 3 lines

This looks like some new feature; please do that in a separate patch. (BTW, I assume that there are no other changes like this in the rest of the moved code blocks!)

No, it isn't. And without 'our $var = VALUE' -> '$var = VALUE' change, which is not necessary and artifically inflates the size of patch, this chunk wouldn't even be present.

I'm sorry, I was just blind.

Signature · 3 lines
				Petr "Pasky" Baudis
The true meaning of life is to plant a tree under whose shade
you will never sit.
#6 lore raw
In reply to Jakub Narebski

2010/6/3 Jakub Narebski <[email protected]>:

Quoted 14 lines · Petr Baudis
Quoted 5 lines

  I have couple of concerns; maybe they were addressed in the previous discussion which I admit I did not read completely, but in that case they ought to be addressed in the commit message as well.

Quoted 7 lines

gitweb/gitweb.perl use Encode; · line 23

Quoted 3 lines · Pavan Kumar Sunkara
gitweb/gitweb.perl +0 -3
-our $t0;
-if (eval { require Time::HiRes; 1; }) {
-   $t0 = [Time::HiRes::gettimeofday()];

Why is this moved to Gitweb::Config? Shouldn't this be rather part of Gitweb::Request?

Quoted 4 lines

I also think that this should be either part of Gitweb::Request, oe even be left in gitweb.perl.  I think having it in Gitweb::Request would be a better idea, because it is about time (and number of git commands) it took to process request.

Ok. It will be done.

Quoted 12 lines
Quoted 9 lines
Quoted 9 lines
gitweb/gitweb.perl +2 -0
+
+use Gitweb::Config;

 BEGIN {
    CGI->compile() if $ENV{'MOD_PERL'};
 }

-our $version = "++GIT_VERSION++";
+$version = "++GIT_VERSION++";

This change is not necessary.

Quoted 4 lines

 our $version = "++GIT_VERSION++";

would keep working even if '$version' is declared in other module and exported by this module (is imported into current scope).

Ok. Will change it.

Quoted 30 lines
Quoted 18 lines

gitweb/gitweb.perl sub evaluate_uri { · line 74

Quoted 9 lines

 our ($my_url, $my_uri, $base_url, $path_info, $home_link); sub evaluate_uri {

gitweb/gitweb.perl +1 -1
@@ -68,402 +71,58 @@ sub evaluate_uri {
 
  # core git executable to use
  # this can just be "git" if your webserver has a sensible PATH
-our $GIT = "++GIT_BINDIR++/git";
+$GIT = "++GIT_BINDIR++/git";

I dislike the new schema in one aspect - the list of configuration variables together with their description is not at a single place
anymore: the build-time overridable variables have their descriptions still in gitweb.pl and only very brief mentions in Gitweb::Config, while the rest has moved fully to Gitweb::Config. I think it would be best to move all descriptions to Gitweb::Config and keep only the override assignments in gitweb.pl. So, Gitweb::Config would have

Quoted 3 lines
      # core git executable to use
      # this can just be "git" if your webserver has a sensible PATH
      our $GIT;

Good idea.

Perhaps we should provide some sane default fallback values, like for example

       our $GIT = "git";

Quoted 1 line
Quoted 7 lines
Quoted 3 lines

and gitweb.pl would have _just_

      $GIT = "++GIT_BINDIR++/git";

I would say

       our $GIT = "++GIT_BINDIR++/git";

But, I think when we start reading the code, it would seem that 'our $GIT' implies that it is a variable created locally rather than an exported variable from Gitweb::Config module.

Even though it increases the patch size, I don't think it will be much of a concern when it comes to good redability of code.

Jakub: Can you reply, what you think about this argument ?

Thanks,
Pavan.

#7 lore raw
Quoted 21 lines · Pavan Kumar Sunkara

2010/6/3 Jakub Narebski <[email protected]>:

Quoted 14 lines · Petr Baudis
Quoted 10 lines
Quoted 10 lines
gitweb/gitweb.perl +2 -0
+
+use Gitweb::Config;

 BEGIN {
    CGI->compile() if $ENV{'MOD_PERL'};
 }

-our $version = "++GIT_VERSION++";
+$version = "++GIT_VERSION++";

This change is not necessary.

Quoted 4 lines

 our $version = "++GIT_VERSION++";

would keep working even if '$version' is declared in other module and exported by this module (is imported into current scope).

Ok. Will change it.

[...]

Quoted 7 lines
Quoted 3 lines

I would say

       our $GIT = "++GIT_BINDIR++/git";

But, I think when we start reading the code, it would seem that 'our $GIT' implies that it is a variable created locally rather than an exported variable from Gitweb::Config module.

From perldoc -f our:

An "our" declares the listed variables to be valid globals within the enclosing block, file, or "eval". That is, it has the same scoping rules as a "my" declaration, but does not create a local variable.

[...] The package in which the variable is entered is determined at the point of the declaration, [...]

So if the variable already exists in given scope, for example if the variable was imported from other package, the 'our' declaration would be a no-op.

Quoted 5 lines

Even though it increases the patch size, I don't think it will be much of a concern when it comes to good redability of code.

Jakub: Can you reply, what you think about this argument ?

But I agree that first, 'our $var' seems to imply that it is _new_ variable declared in current scope, and second if we make a typo in variable name it wouldn't be detected as different from exported
variable: 'our' will create new variable.

So I agree that removing 'our' is a good idea, especially together with putting all variables that should be there in Gitweb::Config together with comments, even if they are configured during build process.

Perhaps those declarations in Gitweb::Config should have in-line comment that they are defined in gitweb.cgi / gitweb.perl?

Signature · 2 lines
Jakub Narebski
Poland
#8 lore raw
Quoted 11 lines · Jakub Narebski
Quoted 5 lines · Pavan Kumar Sunkara

Even though it increases the patch size, I don't think it will be much of a concern when it comes to good redability of code.

Jakub: Can you reply, what you think about this argument ?

But I agree that first, 'our $var' seems to imply that it is _new_ variable declared in current scope, and second if we make a typo in variable name it wouldn't be detected as different from exported
variable: 'our' will create new variable.

And it's hard to detect the typo while debugging.

Quoted 8 lines

So I agree that removing 'our' is a good idea, especially together with putting all variables that should be there in Gitweb::Config together with comments, even if they are configured during build process.

Perhaps those declarations in Gitweb::Config should have in-line comment that they are defined in gitweb.cgi / gitweb.perl?

Yeah, Sure.

Thanks,
Pavan.

#9 lore raw
In reply to Petr Baudis
Quoted 10 lines · Petr Baudis

gitweb/gitweb.perl use Encode; · line 23

Quoted 3 lines · Pavan Kumar Sunkara
gitweb/gitweb.perl +0 -3
-our $t0;
-if (eval { require Time::HiRes; 1; }) {
-     $t0 = [Time::HiRes::gettimeofday()];

Why is this moved to Gitweb::Config? Shouldn't this be rather part of Gitweb::Request?

Quoted 1 line

+our @ISA = qw(Exporter);

This is also re-arranging deck chairs on the Titanic, but 'use base qw(Exporter)' is nicer.

Quoted 9 lines

gitweb/gitweb.perl use Encode; · line 26

Quoted 6 lines
gitweb/gitweb.perl +3 -0
+# __DIR__ is taken from Dir::Self __DIR__ fragment
+sub __DIR__ () {
+     File::Spec->rel2abs(join '', (File::Spec->splitpath(__FILE__))[0, 1]);

 }

gitweb/gitweb.perl +1 -1
-our $number_of_git_cmds = 0;
+use lib __DIR__ . "/lib";

Wouldn't it be more elegant to use FindBin? I'm just not sure how long is it part of core Perl.

No, those don't do the same thing as discussed in previous reviews. FindBin finds the invoked binary, Dir::Self finds the the current file.

#10 lore raw
Quoted 7 lines · Ævar Arnfjörð Bjarmason
Quoted 3 lines · Petr Baudis
Quoted 2 lines · Pavan Kumar Sunkara

+our @ISA = qw(Exporter);

This is also re-arranging deck chairs on the Titanic, but 'use base qw(Exporter)' is nicer.

Or simply 'use Exporter qw(import);', as Perl 5.8+ supports 'use Module LIST' form.

Signature · 2 lines
Jakub Narebski
Poland
#11 lore raw
Quoted 11 lines · Jakub Narebski
Quoted 7 lines · Ævar Arnfjörð Bjarmason
Quoted 3 lines · Petr Baudis
Quoted 2 lines · Pavan Kumar Sunkara

+our @ISA = qw(Exporter);

This is also re-arranging deck chairs on the Titanic, but 'use base qw(Exporter)' is nicer.

Or simply 'use Exporter qw(import);', as Perl 5.8+ supports 'use Module LIST' form.

Ah yes, if the code is lucky enough to require 5.8 in the first place. I didn't know whether gitweb was one of those things.

#12 lore raw
In reply to Pavan Kumar Sunkara

gitweb/lib/Gitweb/Config.pm line 406

Quoted 10 lines · Pavan Kumar Sunkara
gitweb/lib/Gitweb/Config.pm new file +10 -0
+sub evaluate_gitweb_config {
+       # die if there are errors parsing config file
+       if (-e $GITWEB_CONFIG) {
+               do $GITWEB_CONFIG;
+               die $@ if $@;
+       } elsif (-e $GITWEB_CONFIG_SYSTEM) {
+               do $GITWEB_CONFIG_SYSTEM;
+               die $@ if $@;
+       }
+}

I think I mentioned this before, but why not *optionally* use Config::Any (or something similar) and if it doesn't exists fall back on do(), and document this, along with a way to disable Perl execution.

It'd be completely compatible, but admins could then allow someone to edit a gitweb config file without opening themselves up to that someone having permission to execute code as the webserver.

Check out Gitalist (the Catalyst rewrite of Gitweb) for some prior art.