* [PATCH] gitweb: use single quotes for values replaced by the Makefile
2006-08-02 19:23 [PATCH] gitweb: optionally read config from GITWEB_CONFIG Jeff King
@ 2006-08-02 20:17 ` Matthias Lederhofer
2006-08-02 20:50 ` Junio C Hamano
2006-08-02 20:21 ` [PATCH] gitweb: optionally read config from GITWEB_CONFIG Jakub Narebski
` (3 subsequent siblings)
4 siblings, 1 reply; 16+ messages in thread
From: Matthias Lederhofer @ 2006-08-02 20:17 UTC (permalink / raw)
To: Jeff King; +Cc: Junio C Hamano, git
Signed-off-by: Matthias Lederhofer <matled@gmx.net>
---
This patch is on top of the last one.
> Now I noticed a problem: do not use the @@FOO@@ in double quotes
> because perl will spit a lot of warnings like "Possible unintended
> interpolation of @GIT_VERSION in string" Either we should use
> another delimiter or use single quotes (this is the way it is done
> in git-send-email.perl and git-svn.perl). I don't know how likely
> it is that characters that are interpreted different in double
> quotes are in filenames but I'd prefer single quotes just to be on
> the safe site. This disallows using '/etc/foo/$ENV{SITE_NAME}' as
> config file but one can just use '/etc/foo/bar' which requires
> '/etc/foo/$ENV{SITE_NAME}'.
---
gitweb/gitweb.perl | 18 +++++++++---------
1 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index d5b2de8..f4c0d87 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -18,18 +18,18 @@ use File::Find qw();
binmode STDOUT, ':utf8';
our $cgi = new CGI;
-our $version = "@@GIT_VERSION@@";
+our $version = '@@GIT_VERSION@@';
our $my_url = $cgi->url();
our $my_uri = $cgi->url(-absolute => 1);
our $rss_link = "";
# core git executable to use
# this can just be "git" if your webserver has a sensible PATH
-our $GIT = "@@GIT_BINDIR@@/git";
+our $GIT = '@@GIT_BINDIR@@/git';
# absolute fs-path which will be prepended to the project path
#our $projectroot = "/pub/scm";
-our $projectroot = "@@GITWEB_PROJECTROOT@@";
+our $projectroot = '@@GITWEB_PROJECTROOT@@';
# location for temporary files needed for diffs
our $git_temp = "/tmp/gitweb";
@@ -39,18 +39,18 @@ our $home_link = $my_uri;
# 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@@" || $ENV{'SERVER_NAME'} || "Untitled";
+our $site_name = '@@GITWEB_SITENAME@@' || $ENV{'SERVER_NAME'} || "Untitled";
# html text to include at home page
-our $home_text = "@@GITWEB_HOMETEXT@@";
+our $home_text = '@@GITWEB_HOMETEXT@@';
# URI of default stylesheet
-our $stylesheet = "@@GITWEB_CSS@@";
+our $stylesheet = '@@GITWEB_CSS@@';
# URI of GIT logo
-our $logo = "@@GITWEB_LOGO@@";
+our $logo = '@@GITWEB_LOGO@@';
# source of projects list
-our $projects_list = "@@GITWEB_LIST@@";
+our $projects_list = '@@GITWEB_LIST@@';
# default blob_plain mimetype and default charset for text/plain blob
our $default_blob_plain_mimetype = 'text/plain';
@@ -60,7 +60,7 @@ # file to use for guessing MIME types be
# (relative to the current git repository)
our $mimetypes_file = undef;
-our $GITWEB_CONFIG = "@@GITWEB_CONFIG@@";
+our $GITWEB_CONFIG = '@@GITWEB_CONFIG@@';
require $GITWEB_CONFIG if -e $GITWEB_CONFIG;
# version of the core git binary
--
1.4.2.rc2.g4713
^ permalink raw reply related [flat|nested] 16+ messages in thread* Re: [PATCH] gitweb: use single quotes for values replaced by the Makefile
2006-08-02 20:17 ` [PATCH] gitweb: use single quotes for values replaced by the Makefile Matthias Lederhofer
@ 2006-08-02 20:50 ` Junio C Hamano
2006-08-02 20:57 ` Matthias Lederhofer
2006-08-02 20:58 ` Jeff King
0 siblings, 2 replies; 16+ messages in thread
From: Junio C Hamano @ 2006-08-02 20:50 UTC (permalink / raw)
To: Jeff King; +Cc: git
I understand that (1) "@@FOO@@" is problematic, (2) being able
to run gitweb/gitweb.perl while coming up with improvements is
nice, but (3) not being able to say "/etc/foo/$ENV{SITE_NAME}"
is quite a drawback on the deployment side.
So why don't we use something other than @@, perhaps "++FOO++"?
I'm inclined to take these two patches:
gitweb: optionally read config from GITWEB_CONFIG (Jeff King)
gitweb: require $ENV{'GITWEB_CONFIG'} (Matthias Lederhofer)
so on top of them something like this?
-- >8 --
[PATCH] gitweb: do not use @@FOO@@ for replaced tokens
This makes it easier to run gitweb/gitweb.perl without token substitution.
Using @@ makes Perl emit "unintended interpolation" warnings.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
Makefile | 18 +++++++++---------
gitweb/gitweb.perl | 18 +++++++++---------
2 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/Makefile b/Makefile
index a2b4aca..3816ef7 100644
--- a/Makefile
+++ b/Makefile
@@ -584,15 +584,15 @@ git-status: git-commit
gitweb/gitweb.cgi: gitweb/gitweb.perl
rm -f $@ $@+
sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \
- -e 's|@@GIT_VERSION@@|$(GIT_VERSION)|g' \
- -e 's|@@GIT_BINDIR@@|$(bindir)|g' \
- -e 's|@@GITWEB_CONFIG@@|$(GITWEB_CONFIG)|g' \
- -e 's|@@GITWEB_SITENAME@@|$(GITWEB_SITENAME)|g' \
- -e 's|@@GITWEB_PROJECTROOT@@|$(GITWEB_PROJECTROOT)|g' \
- -e 's|@@GITWEB_LIST@@|$(GITWEB_LIST)|g' \
- -e 's|@@GITWEB_HOMETEXT@@|$(GITWEB_HOMETEXT)|g' \
- -e 's|@@GITWEB_CSS@@|$(GITWEB_CSS)|g' \
- -e 's|@@GITWEB_LOGO@@|$(GITWEB_LOGO)|g' \
+ -e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \
+ -e 's|++GIT_BINDIR++|$(bindir)|g' \
+ -e 's|++GITWEB_CONFIG++|$(GITWEB_CONFIG)|g' \
+ -e 's|++GITWEB_SITENAME++|$(GITWEB_SITENAME)|g' \
+ -e 's|++GITWEB_PROJECTROOT++|$(GITWEB_PROJECTROOT)|g' \
+ -e 's|++GITWEB_LIST++|$(GITWEB_LIST)|g' \
+ -e 's|++GITWEB_HOMETEXT++|$(GITWEB_HOMETEXT)|g' \
+ -e 's|++GITWEB_CSS++|$(GITWEB_CSS)|g' \
+ -e 's|++GITWEB_LOGO++|$(GITWEB_LOGO)|g' \
$< >$@+
chmod +x $@+
mv $@+ $@
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index c7f13e7..3cd2b89 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -18,18 +18,18 @@ use File::Find qw();
binmode STDOUT, ':utf8';
our $cgi = new CGI;
-our $version = "@@GIT_VERSION@@";
+our $version = "++GIT_VERSION++";
our $my_url = $cgi->url();
our $my_uri = $cgi->url(-absolute => 1);
our $rss_link = "";
# core git executable to use
# this can just be "git" if your webserver has a sensible PATH
-our $GIT = "@@GIT_BINDIR@@/git";
+our $GIT = "++GIT_BINDIR++/git";
# absolute fs-path which will be prepended to the project path
#our $projectroot = "/pub/scm";
-our $projectroot = "@@GITWEB_PROJECTROOT@@";
+our $projectroot = "++GITWEB_PROJECTROOT++";
# location for temporary files needed for diffs
our $git_temp = "/tmp/gitweb";
@@ -39,18 +39,18 @@ our $home_link = $my_uri;
# 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@@" || $ENV{'SERVER_NAME'} || "Untitled";
+our $site_name = "++GITWEB_SITENAME++" || $ENV{'SERVER_NAME'} || "Untitled";
# html text to include at home page
-our $home_text = "@@GITWEB_HOMETEXT@@";
+our $home_text = "++GITWEB_HOMETEXT++";
# URI of default stylesheet
-our $stylesheet = "@@GITWEB_CSS@@";
+our $stylesheet = "++GITWEB_CSS++";
# URI of GIT logo
-our $logo = "@@GITWEB_LOGO@@";
+our $logo = "++GITWEB_LOGO++";
# source of projects list
-our $projects_list = "@@GITWEB_LIST@@";
+our $projects_list = "++GITWEB_LIST++";
# default blob_plain mimetype and default charset for text/plain blob
our $default_blob_plain_mimetype = 'text/plain';
@@ -60,7 +60,7 @@ # file to use for guessing MIME types be
# (relative to the current git repository)
our $mimetypes_file = undef;
-our $GITWEB_CONFIG = "@@GITWEB_CONFIG@@";
+our $GITWEB_CONFIG = "++GITWEB_CONFIG++";
require $GITWEB_CONFIG if -e $GITWEB_CONFIG;
if (defined($ENV{'GITWEB_CONFIG'}) && -e $ENV{'GITWEB_CONFIG'}) {
--
1.4.2.rc2.g767b2
^ permalink raw reply related [flat|nested] 16+ messages in thread* Re: [PATCH] gitweb: use single quotes for values replaced by the Makefile
2006-08-02 20:50 ` Junio C Hamano
@ 2006-08-02 20:57 ` Matthias Lederhofer
2006-08-02 20:58 ` Jeff King
1 sibling, 0 replies; 16+ messages in thread
From: Matthias Lederhofer @ 2006-08-02 20:57 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Jeff King, git
Junio C Hamano <junkio@cox.net> wrote:
> I understand that (1) "@@FOO@@" is problematic, (2) being able
> to run gitweb/gitweb.perl while coming up with improvements is
> nice, but (3) not being able to say "/etc/foo/$ENV{SITE_NAME}"
> is quite a drawback on the deployment side.
>
> So why don't we use something other than @@, perhaps "++FOO++"?
That's the other way to solve this. If there is no typical character
for filenames which is handled different in double quotes this is fine
for me too.
> I'm inclined to take these two patches:
>
> gitweb: optionally read config from GITWEB_CONFIG (Jeff King)
> gitweb: require $ENV{'GITWEB_CONFIG'} (Matthias Lederhofer)
The suggestion by Jeff King to use
our $GITWEB_CONFIG = $ENV{GITWEB_CONFIG} || '@@GITWEB_CONFIG@@';
sounds reasonable too.
> so on top of them something like this?
[patch replacing @@ with ++]
Ack.
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: [PATCH] gitweb: use single quotes for values replaced by the Makefile
2006-08-02 20:50 ` Junio C Hamano
2006-08-02 20:57 ` Matthias Lederhofer
@ 2006-08-02 20:58 ` Jeff King
1 sibling, 0 replies; 16+ messages in thread
From: Jeff King @ 2006-08-02 20:58 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
On Wed, Aug 02, 2006 at 01:50:53PM -0700, Junio C Hamano wrote:
> So why don't we use something other than @@, perhaps "++FOO++"?
Acked-by: Jeff King <peff@peff.net>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH] gitweb: optionally read config from GITWEB_CONFIG
2006-08-02 19:23 [PATCH] gitweb: optionally read config from GITWEB_CONFIG Jeff King
2006-08-02 20:17 ` [PATCH] gitweb: use single quotes for values replaced by the Makefile Matthias Lederhofer
@ 2006-08-02 20:21 ` Jakub Narebski
2006-08-02 20:31 ` Matthias Lederhofer
2006-08-02 20:41 ` Jeff King
2006-08-02 20:28 ` Junio C Hamano
` (2 subsequent siblings)
4 siblings, 2 replies; 16+ messages in thread
From: Jakub Narebski @ 2006-08-02 20:21 UTC (permalink / raw)
To: git
Jeff King wrote:
> Configuration will first be taken from variables inside the gitweb.cgi
> script, which in turn come from the Makefile. Afterwards, the contents of
> GITWEB_CONFIG are read, overriding the builtin defaults.
>
> This should eliminate the need for editing the gitweb script at all. Users
> should edit the Makefile and/or add a config file.
Very nice.
> @@ -56,7 +50,7 @@ # URI of GIT logo
> our $logo = "@@GITWEB_LOGO@@";
>
> # source of projects list
> -our $projects_list = "@@GITWEB_LIST@@" || "$projectroot";
> +our $projects_list = "@@GITWEB_LIST@@";
>
> # default blob_plain mimetype and default charset for text/plain blob
> our $default_blob_plain_mimetype = 'text/plain';
But why that change?
--
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: [PATCH] gitweb: optionally read config from GITWEB_CONFIG
2006-08-02 20:21 ` [PATCH] gitweb: optionally read config from GITWEB_CONFIG Jakub Narebski
@ 2006-08-02 20:31 ` Matthias Lederhofer
2006-08-02 20:36 ` Jakub Narebski
2006-08-02 20:41 ` Jeff King
1 sibling, 1 reply; 16+ messages in thread
From: Matthias Lederhofer @ 2006-08-02 20:31 UTC (permalink / raw)
To: Jakub Narebski; +Cc: git
Jakub Narebski <jnareb@gmail.com> wrote:
> Jeff King wrote:
> > @@ -56,7 +50,7 @@ # URI of GIT logo
> > our $logo = "@@GITWEB_LOGO@@";
> >
> > # source of projects list
> > -our $projects_list = "@@GITWEB_LIST@@" || "$projectroot";
> > +our $projects_list = "@@GITWEB_LIST@@";
> >
> > # default blob_plain mimetype and default charset for text/plain blob
> > our $default_blob_plain_mimetype = 'text/plain';
>
> But why that change?
Earlier this was undef if the user did not change it. Now this is
always a string so the second one will probably never come into play
except the user chooses to set the string to undef again.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH] gitweb: optionally read config from GITWEB_CONFIG
2006-08-02 20:31 ` Matthias Lederhofer
@ 2006-08-02 20:36 ` Jakub Narebski
0 siblings, 0 replies; 16+ messages in thread
From: Jakub Narebski @ 2006-08-02 20:36 UTC (permalink / raw)
To: git
Matthias Lederhofer wrote:
> Jakub Narebski <jnareb@gmail.com> wrote:
>> Jeff King wrote:
>> > @@ -56,7 +50,7 @@ # URI of GIT logo
>> > our $logo = "@@GITWEB_LOGO@@";
>> >
>> > # source of projects list
>> > -our $projects_list = "@@GITWEB_LIST@@" || "$projectroot";
>> > +our $projects_list = "@@GITWEB_LIST@@";
>> >
>> > # default blob_plain mimetype and default charset for text/plain blob
>> > our $default_blob_plain_mimetype = 'text/plain';
>>
>> But why that change?
> Earlier this was undef if the user did not change it. Now this is
> always a string so the second one will probably never come into play
> except the user chooses to set the string to undef again.
Empty string is also false in Perl. Try
perl -e 'my $var = "" || "other"; print "var = $var\n";'
I'd rather use $projectroot for $projects_list, preferably without needing
to set $projects_list.
--
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH] gitweb: optionally read config from GITWEB_CONFIG
2006-08-02 20:21 ` [PATCH] gitweb: optionally read config from GITWEB_CONFIG Jakub Narebski
2006-08-02 20:31 ` Matthias Lederhofer
@ 2006-08-02 20:41 ` Jeff King
1 sibling, 0 replies; 16+ messages in thread
From: Jeff King @ 2006-08-02 20:41 UTC (permalink / raw)
To: Jakub Narebski; +Cc: git
On Wed, Aug 02, 2006 at 10:21:43PM +0200, Jakub Narebski wrote:
> > @@ -56,7 +50,7 @@ # URI of GIT logo
> > our $logo = "@@GITWEB_LOGO@@";
> >
> > # source of projects list
> > -our $projects_list = "@@GITWEB_LIST@@" || "$projectroot";
> > +our $projects_list = "@@GITWEB_LIST@@";
> >
> > # default blob_plain mimetype and default charset for text/plain blob
> > our $default_blob_plain_mimetype = 'text/plain';
>
> But why that change?
Because the previous order was:
1. set projectroot to build-time default
2. set projects_list to build-time default or $projectroot
3. read variables, including $projectroot, from config file
If you kept $projects_list empty but set $projectroot in your config,
the value of projects_list would be the build-time $projectroot, not the
config-time. If you look further in the patch, you will see that we set
up projects_list later.
-Peff
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH] gitweb: optionally read config from GITWEB_CONFIG
2006-08-02 19:23 [PATCH] gitweb: optionally read config from GITWEB_CONFIG Jeff King
2006-08-02 20:17 ` [PATCH] gitweb: use single quotes for values replaced by the Makefile Matthias Lederhofer
2006-08-02 20:21 ` [PATCH] gitweb: optionally read config from GITWEB_CONFIG Jakub Narebski
@ 2006-08-02 20:28 ` Junio C Hamano
2006-08-02 20:29 ` [PATCH] gitweb: require $ENV{'GITWEB_CONFIG'} Matthias Lederhofer
2006-08-02 20:51 ` [PATCH] gitweb: optionally read config from GITWEB_CONFIG Luben Tuikov
4 siblings, 0 replies; 16+ messages in thread
From: Junio C Hamano @ 2006-08-02 20:28 UTC (permalink / raw)
To: Jeff King; +Cc: git
Jeff King <peff@peff.net> writes:
> Configuration will first be taken from variables inside the gitweb.cgi
> script, which in turn come from the Makefile. Afterwards, the contents of
> GITWEB_CONFIG are read, overriding the builtin defaults.
>
> This should eliminate the need for editing the gitweb script at all. Users
> should edit the Makefile and/or add a config file.
>
> Signed-off-by: Jeff King <peff@peff.net>
> ---
> This is on top of next.
>
> This patch seemed to get a favorable response, so I cleaned it up and
> actually tested it. The main changes are reordering a few of the setup
> statements so that changes introduced in the config file are respected
> as suggested by Matthias (and a few by me). It would be good if other
> gitweb people could check it over and/or try it with their config to
> make sure I didn't miss anything.
Looks good -- thanks. Further comments from the list are very
much appreciated.
^ permalink raw reply [flat|nested] 16+ messages in thread* [PATCH] gitweb: require $ENV{'GITWEB_CONFIG'}
2006-08-02 19:23 [PATCH] gitweb: optionally read config from GITWEB_CONFIG Jeff King
` (2 preceding siblings ...)
2006-08-02 20:28 ` Junio C Hamano
@ 2006-08-02 20:29 ` Matthias Lederhofer
2006-08-02 20:50 ` Jeff King
2006-08-02 20:51 ` [PATCH] gitweb: optionally read config from GITWEB_CONFIG Luben Tuikov
4 siblings, 1 reply; 16+ messages in thread
From: Matthias Lederhofer @ 2006-08-02 20:29 UTC (permalink / raw)
To: Jeff King; +Cc: Junio C Hamano, git
Signed-off-by: Matthias Lederhofer <matled@gmx.net>
---
With this patch it is possible to use gitweb.perl for developing by
loading the configuration from $GITWEB_CONFIG. This might also be
useful for normal usage of gitweb. Example:
% cat cfg
$GIT = '/usr/bin/git';
$projectroot = '/home/matled/src/git';
$projects_list = '/home/matled/src/git/git/gitweb/list';
% cat run
#!/bin/sh
export GATEWAY_INTERFACE="CGI/1.1"
export HTTP_ACCEPT="*/*"
export REQUEST_METHOD="GET"
export GITWEB_CONFIG='./cfg'
export QUERY_STRING=""$1""
exec ./gitweb.perl
% time ./run p=git/.git > /dev/null
./run p=git/.git > /dev/null 0.47s user 0.58s system 102% cpu 1.025
total
This makes it easy to check for warnings and do performance tests
after changes, you can also pipe this to lynx -dump -force-html
/dev/stdin to get more than just html :)
This also documents the original patch adding require $GITWEB_CONFIG.
---
gitweb/README | 5 +++++
gitweb/gitweb.perl | 4 ++++
2 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/gitweb/README b/gitweb/README
index b91d42a..dc4b850 100644
--- a/gitweb/README
+++ b/gitweb/README
@@ -23,6 +23,11 @@ You can specify the following configurat
Points to the location where you put gitweb.css on your web server.
* GITWEB_LOGO
Points to the location where you put git-logo.png on your web server.
+ * GITWEB_CONFIG
+ This file will be loaded using 'require'. If the environment
+ $GITWEB_CONFIG is set when gitweb.cgi is executed the file in the
+ environment variable will be loaded additionally (after) the file
+ specified when gitweb.cgi was created.
Originally written by:
Kay Sievers <kay.sievers@vrfy.org>
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index f4c0d87..efcc926 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -63,6 +63,10 @@ our $mimetypes_file = undef;
our $GITWEB_CONFIG = '@@GITWEB_CONFIG@@';
require $GITWEB_CONFIG if -e $GITWEB_CONFIG;
+if (defined($ENV{'GITWEB_CONFIG'}) && -e $ENV{'GITWEB_CONFIG'}) {
+ require $ENV{'GITWEB_CONFIG'};
+}
+
# version of the core git binary
our $git_version = qx($GIT --version) =~ m/git version (.*)$/ ? $1 : "unknown";
--
1.4.2.rc2.g4713
^ permalink raw reply related [flat|nested] 16+ messages in thread* Re: [PATCH] gitweb: require $ENV{'GITWEB_CONFIG'}
2006-08-02 20:29 ` [PATCH] gitweb: require $ENV{'GITWEB_CONFIG'} Matthias Lederhofer
@ 2006-08-02 20:50 ` Jeff King
2006-08-02 20:58 ` Junio C Hamano
0 siblings, 1 reply; 16+ messages in thread
From: Jeff King @ 2006-08-02 20:50 UTC (permalink / raw)
To: Matthias Lederhofer; +Cc: Junio C Hamano, git
On Wed, Aug 02, 2006 at 10:29:36PM +0200, Matthias Lederhofer wrote:
> --- a/gitweb/gitweb.perl
> +++ b/gitweb/gitweb.perl
> @@ -63,6 +63,10 @@ our $mimetypes_file = undef;
> our $GITWEB_CONFIG = '@@GITWEB_CONFIG@@';
> require $GITWEB_CONFIG if -e $GITWEB_CONFIG;
>
> +if (defined($ENV{'GITWEB_CONFIG'}) && -e $ENV{'GITWEB_CONFIG'}) {
> + require $ENV{'GITWEB_CONFIG'};
> +}
> +
> # version of the core git binary
> our $git_version = qx($GIT --version) =~ m/git version (.*)$/ ? $1 : "unknown";
I think this patch is a good idea, but it seems confusing to have two
different config files. Maybe the environment should trump the built-in
default:
our $GITWEB_CONFIG = $ENV{GITWEB_CONFIG} || '@@GITWEB_CONFIG@@';
Which actually might be a reasonable thing for all of the config
directives (so people can use a config file, apache environment munging,
or the built-in defaults). I would think the sanest order would be
environment, then config file, then built-ins (which is what all the
rest of the git programs do).
-Peff
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: [PATCH] gitweb: require $ENV{'GITWEB_CONFIG'}
2006-08-02 20:50 ` Jeff King
@ 2006-08-02 20:58 ` Junio C Hamano
2006-08-02 20:59 ` Jeff King
0 siblings, 1 reply; 16+ messages in thread
From: Junio C Hamano @ 2006-08-02 20:58 UTC (permalink / raw)
To: Jeff King; +Cc: git
Jeff King <peff@peff.net> writes:
> I think this patch is a good idea, but it seems confusing to have two
> Maybe the environment should trump the built-in
> default:
> our $GITWEB_CONFIG = $ENV{GITWEB_CONFIG} || '@@GITWEB_CONFIG@@';
> which actually might be a reasonable thing for all of the config
> directives (so people can use a config file, apache environment munging,
> or the built-in defaults).
Sounds very sane. So Matthias's patch now becomes something
like this:
-- >8 --
diff --git a/gitweb/README b/gitweb/README
index b91d42a..dc4b850 100644
--- a/gitweb/README
+++ b/gitweb/README
@@ -23,6 +23,11 @@ You can specify the following configurat
Points to the location where you put gitweb.css on your web server.
* GITWEB_LOGO
Points to the location where you put git-logo.png on your web server.
+ * GITWEB_CONFIG
+ This file will be loaded using 'require'. If the environment
+ $GITWEB_CONFIG is set when gitweb.cgi is executed the file in the
+ environment variable will be loaded instead of the file
+ specified when gitweb.cgi was created.
Originally written by:
Kay Sievers <kay.sievers@vrfy.org>
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index d5b2de8..c7f13e7 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -63,6 +63,6 @@ our $mimetypes_file = undef;
-our $GITWEB_CONFIG = "@@GITWEB_CONFIG@@";
+our $GITWEB_CONFIG = $ENV{'GITWEB_CONFIG'} || "@@GITWEB_CONFIG@@";
require $GITWEB_CONFIG if -e $GITWEB_CONFIG;
# version of the core git binary
our $git_version = qx($GIT --version) =~ m/git version (.*)$/ ? $1 : "unknown";
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH] gitweb: optionally read config from GITWEB_CONFIG
2006-08-02 19:23 [PATCH] gitweb: optionally read config from GITWEB_CONFIG Jeff King
` (3 preceding siblings ...)
2006-08-02 20:29 ` [PATCH] gitweb: require $ENV{'GITWEB_CONFIG'} Matthias Lederhofer
@ 2006-08-02 20:51 ` Luben Tuikov
2006-08-02 20:56 ` Jeff King
4 siblings, 1 reply; 16+ messages in thread
From: Luben Tuikov @ 2006-08-02 20:51 UTC (permalink / raw)
To: Jeff King, Junio C Hamano; +Cc: git
--- Jeff King <peff@peff.net> wrote:
> Configuration will first be taken from variables inside the gitweb.cgi
> script, which in turn come from the Makefile. Afterwards, the contents of
> GITWEB_CONFIG are read, overriding the builtin defaults.
>
> This should eliminate the need for editing the gitweb script at all. Users
> should edit the Makefile and/or add a config file.
I don't think users should even edit the Makefile. Makefiles are normally
edited when the _build_ environment differs, not when the deployment
environment differs.
For example, some of us use the same gitweb.cgi/perl/pl (or whatever the
next completely unnecessary renaming would be) for deployment on several
"sites" and repositories.
I cannot imagine anyone who actually _uses_ and maintains gitweb.cgi/perl/pl
to edit the Makefile for their deployment, thus having to have a forked off
branch(es) for each of their deployments (which the only diff editing the Makefile).
Luben
>
> Signed-off-by: Jeff King <peff@peff.net>
> ---
> This is on top of next.
>
> This patch seemed to get a favorable response, so I cleaned it up and
> actually tested it. The main changes are reordering a few of the setup
> statements so that changes introduced in the config file are respected
> as suggested by Matthias (and a few by me). It would be good if other
> gitweb people could check it over and/or try it with their config to
> make sure I didn't miss anything.
>
> Makefile | 2 ++
> gitweb/gitweb.perl | 19 ++++++++++++-------
> 2 files changed, 14 insertions(+), 7 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index 2562a2c..170d082 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -127,6 +127,7 @@ GIT_PYTHON_DIR = $(prefix)/share/git-cor
> # DESTDIR=
>
> # default configuration for gitweb
> +GITWEB_CONFIG = gitweb_config.perl
> GITWEB_SITENAME =
> GITWEB_PROJECTROOT = /pub/git
> GITWEB_LIST =
> @@ -629,6 +630,7 @@ gitweb/gitweb.cgi: gitweb/gitweb.perl
> sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \
> -e 's|@@GIT_VERSION@@|$(GIT_VERSION)|g' \
> -e 's|@@GIT_BINDIR@@|$(bindir)|g' \
> + -e 's|@@GITWEB_CONFIG@@|$(GITWEB_CONFIG)|g' \
> -e 's|@@GITWEB_SITENAME@@|$(GITWEB_SITENAME)|g' \
> -e 's|@@GITWEB_PROJECTROOT@@|$(GITWEB_PROJECTROOT)|g' \
> -e 's|@@GITWEB_LIST@@|$(GITWEB_LIST)|g' \
> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> index 1db1414..d5b2de8 100755
> --- a/gitweb/gitweb.perl
> +++ b/gitweb/gitweb.perl
> @@ -31,14 +31,8 @@ # absolute fs-path which will be prepend
> #our $projectroot = "/pub/scm";
> our $projectroot = "@@GITWEB_PROJECTROOT@@";
>
> -# version of the core git binary
> -our $git_version = qx($GIT --version) =~ m/git version (.*)$/ ? $1 : "unknown";
> -
> # location for temporary files needed for diffs
> our $git_temp = "/tmp/gitweb";
> -if (! -d $git_temp) {
> - mkdir($git_temp, 0700) || die_error("Couldn't mkdir $git_temp");
> -}
>
> # target of the home link on top of all pages
> our $home_link = $my_uri;
> @@ -56,7 +50,7 @@ # URI of GIT logo
> our $logo = "@@GITWEB_LOGO@@";
>
> # source of projects list
> -our $projects_list = "@@GITWEB_LIST@@" || "$projectroot";
> +our $projects_list = "@@GITWEB_LIST@@";
>
> # default blob_plain mimetype and default charset for text/plain blob
> our $default_blob_plain_mimetype = 'text/plain';
> @@ -66,6 +60,17 @@ # file to use for guessing MIME types be
> # (relative to the current git repository)
> our $mimetypes_file = undef;
>
> +our $GITWEB_CONFIG = "@@GITWEB_CONFIG@@";
> +require $GITWEB_CONFIG if -e $GITWEB_CONFIG;
> +
> +# version of the core git binary
> +our $git_version = qx($GIT --version) =~ m/git version (.*)$/ ? $1 : "unknown";
> +
> +$projects_list ||= $projectroot;
> +if (! -d $git_temp) {
> + mkdir($git_temp, 0700) || die_error("Couldn't mkdir $git_temp");
> +}
> +
> # input validation and dispatch
> our $action = $cgi->param('a');
> if (defined $action) {
> --
> 1.4.2.rc2.g59706-dirty
> -
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: [PATCH] gitweb: optionally read config from GITWEB_CONFIG
2006-08-02 20:51 ` [PATCH] gitweb: optionally read config from GITWEB_CONFIG Luben Tuikov
@ 2006-08-02 20:56 ` Jeff King
0 siblings, 0 replies; 16+ messages in thread
From: Jeff King @ 2006-08-02 20:56 UTC (permalink / raw)
To: Luben Tuikov; +Cc: Junio C Hamano, git
On Wed, Aug 02, 2006 at 01:51:20PM -0700, Luben Tuikov wrote:
> I don't think users should even edit the Makefile. Makefiles are normally
> edited when the _build_ environment differs, not when the deployment
> environment differs.
I don't either; I should have stated more clearly: users can edit
config.mak or use command line parameters to make (the same way they do
for prefix or other variables).
You don't even have to do that if the default config-file path is fine
for you. And even if you don't, you should be able to set GITWEB_CONF
with Matthias' patch.
-Peff
^ permalink raw reply [flat|nested] 16+ messages in thread