{"thread":{"id":"5095","subject":"[PATCH] gitweb: optionally read config from GITWEB_CONFIG","startedAt":"2006-08-02T19:23:34Z","lastAt":"2006-08-02T20:59:51Z","messageCount":16,"participants":["Jeff King","Matthias Lederhofer","Jakub Narebski","Junio C Hamano","Luben Tuikov"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"24583","messageId":"20060802192333.GA30861@coredump.intra.peff.net","threadId":"5095","inReplyTo":null,"subject":"[PATCH] gitweb: optionally read config from GITWEB_CONFIG","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2006-08-02T19:23:34Z","receivedAt":"2006-08-02T19:23:34Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"Configuration will first be taken from variables inside the gitweb.cgi\nscript, which in turn come from the Makefile. Afterwards, the contents of\nGITWEB_CONFIG are read, overriding the builtin defaults.\n\nThis should eliminate the need for editing the gitweb script at all. Users\nshould edit the Makefile and/or add a config file.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\nThis is on top of next.\n\nThis patch seemed to get a favorable response, so I cleaned it up and\nactually tested it. The main changes are reordering a few of the setup\nstatements so that changes introduced in the config file are respected\nas suggested by Matthias (and a few by me). It would be good if other\ngitweb people could check it over and/or try it with their config to\nmake sure I didn't miss anything.\n\n Makefile           |    2 ++\n gitweb/gitweb.perl |   19 ++++++++++++-------\n 2 files changed, 14 insertions(+), 7 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 2562a2c..170d082 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -127,6 +127,7 @@ GIT_PYTHON_DIR = $(prefix)/share/git-cor\n # DESTDIR=\n \n # default configuration for gitweb\n+GITWEB_CONFIG = gitweb_config.perl\n GITWEB_SITENAME =\n GITWEB_PROJECTROOT = /pub/git\n GITWEB_LIST =\n@@ -629,6 +630,7 @@ gitweb/gitweb.cgi: gitweb/gitweb.perl\n \tsed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \\\n \t    -e 's|@@GIT_VERSION@@|$(GIT_VERSION)|g' \\\n \t    -e 's|@@GIT_BINDIR@@|$(bindir)|g' \\\n+\t    -e 's|@@GITWEB_CONFIG@@|$(GITWEB_CONFIG)|g' \\\n \t    -e 's|@@GITWEB_SITENAME@@|$(GITWEB_SITENAME)|g' \\\n \t    -e 's|@@GITWEB_PROJECTROOT@@|$(GITWEB_PROJECTROOT)|g' \\\n \t    -e 's|@@GITWEB_LIST@@|$(GITWEB_LIST)|g' \\\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 1db1414..d5b2de8 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -31,14 +31,8 @@ # absolute fs-path which will be prepend\n #our $projectroot = \"/pub/scm\";\n our $projectroot = \"@@GITWEB_PROJECTROOT@@\";\n \n-# version of the core git binary\n-our $git_version = qx($GIT --version) =~ m/git version (.*)$/ ? $1 : \"unknown\";\n-\n # location for temporary files needed for diffs\n our $git_temp = \"/tmp/gitweb\";\n-if (! -d $git_temp) {\n-\tmkdir($git_temp, 0700) || die_error(\"Couldn't mkdir $git_temp\");\n-}\n \n # target of the home link on top of all pages\n our $home_link = $my_uri;\n@@ -56,7 +50,7 @@ # URI of GIT logo\n our $logo = \"@@GITWEB_LOGO@@\";\n \n # source of projects list\n-our $projects_list = \"@@GITWEB_LIST@@\" || \"$projectroot\";\n+our $projects_list = \"@@GITWEB_LIST@@\";\n \n # default blob_plain mimetype and default charset for text/plain blob\n our $default_blob_plain_mimetype = 'text/plain';\n@@ -66,6 +60,17 @@ # file to use for guessing MIME types be\n # (relative to the current git repository)\n our $mimetypes_file = undef;\n \n+our $GITWEB_CONFIG = \"@@GITWEB_CONFIG@@\";\n+require $GITWEB_CONFIG if -e $GITWEB_CONFIG;\n+\n+# version of the core git binary\n+our $git_version = qx($GIT --version) =~ m/git version (.*)$/ ? $1 : \"unknown\";\n+\n+$projects_list ||= $projectroot;\n+if (! -d $git_temp) {\n+\tmkdir($git_temp, 0700) || die_error(\"Couldn't mkdir $git_temp\");\n+}\n+\n # input validation and dispatch\n our $action = $cgi->param('a');\n if (defined $action) {\n-- \n1.4.2.rc2.g59706-dirty\n"},{"id":"24586","messageId":"E1G8N9c-0004GK-Gz@moooo.ath.cx","threadId":"5095","inReplyTo":"20060802192333.GA30861@coredump.intra.peff.net","subject":"[PATCH] gitweb: use single quotes for values replaced by the Makefile","fromName":"Matthias Lederhofer","fromEmail":"matled@gmx.net","sentAt":"2006-08-02T20:17:20Z","receivedAt":"2006-08-02T20:17:20Z","isPatch":true,"sender":{"key":"matled@gmx.net","avatar":null},"body":"Signed-off-by: Matthias Lederhofer <matled@gmx.net>\n---\nThis patch is on top of the last one.\n> Now I noticed a problem: do not use the @@FOO@@ in double quotes\n> because perl will spit a lot of warnings like \"Possible unintended\n> interpolation of @GIT_VERSION in string\" Either we should use\n> another delimiter or use single quotes (this is the way it is done\n> in git-send-email.perl and git-svn.perl).  I don't know how likely\n> it is that characters that are interpreted different in double\n> quotes are in filenames but I'd prefer single quotes just to be on\n> the safe site.  This disallows using '/etc/foo/$ENV{SITE_NAME}' as\n> config file but one can just use '/etc/foo/bar' which requires\n> '/etc/foo/$ENV{SITE_NAME}'.\n---\n gitweb/gitweb.perl |   18 +++++++++---------\n 1 files changed, 9 insertions(+), 9 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex d5b2de8..f4c0d87 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -18,18 +18,18 @@ use File::Find qw();\n binmode STDOUT, ':utf8';\n \n our $cgi = new CGI;\n-our $version = \"@@GIT_VERSION@@\";\n+our $version = '@@GIT_VERSION@@';\n our $my_url = $cgi->url();\n our $my_uri = $cgi->url(-absolute => 1);\n our $rss_link = \"\";\n \n # core git executable to use\n # this can just be \"git\" if your webserver has a sensible PATH\n-our $GIT = \"@@GIT_BINDIR@@/git\";\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+our $projectroot = '@@GITWEB_PROJECTROOT@@';\n \n # location for temporary files needed for diffs\n our $git_temp = \"/tmp/gitweb\";\n@@ -39,18 +39,18 @@ our $home_link = $my_uri;\n \n # name of your site or organization to appear in page titles\n # replace this with something more descriptive for clearer bookmarks\n-our $site_name = \"@@GITWEB_SITENAME@@\" || $ENV{'SERVER_NAME'} || \"Untitled\";\n+our $site_name = '@@GITWEB_SITENAME@@' || $ENV{'SERVER_NAME'} || \"Untitled\";\n \n # html text to include at home page\n-our $home_text = \"@@GITWEB_HOMETEXT@@\";\n+our $home_text = '@@GITWEB_HOMETEXT@@';\n \n # URI of default stylesheet\n-our $stylesheet = \"@@GITWEB_CSS@@\";\n+our $stylesheet = '@@GITWEB_CSS@@';\n # URI of GIT logo\n-our $logo = \"@@GITWEB_LOGO@@\";\n+our $logo = '@@GITWEB_LOGO@@';\n \n # source of projects list\n-our $projects_list = \"@@GITWEB_LIST@@\";\n+our $projects_list = '@@GITWEB_LIST@@';\n \n # default blob_plain mimetype and default charset for text/plain blob\n our $default_blob_plain_mimetype = 'text/plain';\n@@ -60,7 +60,7 @@ # file to use for guessing MIME types be\n # (relative to the current git repository)\n our $mimetypes_file = undef;\n \n-our $GITWEB_CONFIG = \"@@GITWEB_CONFIG@@\";\n+our $GITWEB_CONFIG = '@@GITWEB_CONFIG@@';\n require $GITWEB_CONFIG if -e $GITWEB_CONFIG;\n \n # version of the core git binary\n-- \n1.4.2.rc2.g4713\n"},{"id":"24588","messageId":"ear1fp$j9p$2@sea.gmane.org","threadId":"5095","inReplyTo":"20060802192333.GA30861@coredump.intra.peff.net","subject":"Re: [PATCH] gitweb: optionally read config from GITWEB_CONFIG","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-08-02T20:21:43Z","receivedAt":"2006-08-02T20:21:43Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Jeff King wrote:\n\n> Configuration will first be taken from variables inside the gitweb.cgi\n> script, which in turn come from the Makefile. Afterwards, the contents of\n> GITWEB_CONFIG are read, overriding the builtin defaults.\n> \n> This should eliminate the need for editing the gitweb script at all. Users\n> should edit the Makefile and/or add a config file.\n\nVery nice.\n\n> @@ -56,7 +50,7 @@ # URI of GIT logo\n>  our $logo = \"@@GITWEB_LOGO@@\";\n>  \n>  # source of projects list\n> -our $projects_list = \"@@GITWEB_LIST@@\" || \"$projectroot\";\n> +our $projects_list = \"@@GITWEB_LIST@@\";\n>  \n>  # default blob_plain mimetype and default charset for text/plain blob\n>  our $default_blob_plain_mimetype = 'text/plain';\n\nBut why that change?\n\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"},{"id":"24589","messageId":"7vu04uubl7.fsf@assigned-by-dhcp.cox.net","threadId":"5095","inReplyTo":"20060802192333.GA30861@coredump.intra.peff.net","subject":"Re: [PATCH] gitweb: optionally read config from GITWEB_CONFIG","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-08-02T20:28:04Z","receivedAt":"2006-08-02T20:28:04Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> Configuration will first be taken from variables inside the gitweb.cgi\n> script, which in turn come from the Makefile. Afterwards, the contents of\n> GITWEB_CONFIG are read, overriding the builtin defaults.\n>\n> This should eliminate the need for editing the gitweb script at all. Users\n> should edit the Makefile and/or add a config file.\n>\n> Signed-off-by: Jeff King <peff@peff.net>\n> ---\n> This is on top of next.\n>\n> This patch seemed to get a favorable response, so I cleaned it up and\n> actually tested it. The main changes are reordering a few of the setup\n> statements so that changes introduced in the config file are respected\n> as suggested by Matthias (and a few by me). It would be good if other\n> gitweb people could check it over and/or try it with their config to\n> make sure I didn't miss anything.\n\nLooks good -- thanks.  Further comments from the list are very\nmuch appreciated.\n"},{"id":"24590","messageId":"E1G8NLU-0006TL-J7@moooo.ath.cx","threadId":"5095","inReplyTo":"20060802192333.GA30861@coredump.intra.peff.net","subject":"[PATCH] gitweb: require $ENV{'GITWEB_CONFIG'}","fromName":"Matthias Lederhofer","fromEmail":"matled@gmx.net","sentAt":"2006-08-02T20:29:36Z","receivedAt":"2006-08-02T20:29:36Z","isPatch":true,"sender":{"key":"matled@gmx.net","avatar":null},"body":"Signed-off-by: Matthias Lederhofer <matled@gmx.net>\n---\nWith this patch it is possible to use gitweb.perl for developing by\nloading the configuration from $GITWEB_CONFIG.  This might also be\nuseful for normal usage of gitweb.  Example:\n% cat cfg \n$GIT = '/usr/bin/git';\n$projectroot = '/home/matled/src/git';\n$projects_list = '/home/matled/src/git/git/gitweb/list';\n% cat run\n#!/bin/sh\nexport GATEWAY_INTERFACE=\"CGI/1.1\"\nexport HTTP_ACCEPT=\"*/*\"\nexport REQUEST_METHOD=\"GET\"\nexport GITWEB_CONFIG='./cfg'\nexport QUERY_STRING=\"\"$1\"\"\nexec ./gitweb.perl\n% time ./run p=git/.git > /dev/null \n./run p=git/.git > /dev/null  0.47s user 0.58s system 102% cpu 1.025\ntotal\n\nThis makes it easy to check for warnings and do performance tests\nafter changes, you can also pipe this to lynx -dump -force-html\n/dev/stdin to get more than just html :)\n\nThis also documents the original patch adding require $GITWEB_CONFIG.\n---\n gitweb/README      |    5 +++++\n gitweb/gitweb.perl |    4 ++++\n 2 files changed, 9 insertions(+), 0 deletions(-)\n\ndiff --git a/gitweb/README b/gitweb/README\nindex b91d42a..dc4b850 100644\n--- a/gitweb/README\n+++ b/gitweb/README\n@@ -23,6 +23,11 @@ You can specify the following configurat\n    Points to the location where you put gitweb.css on your web server.\n  * GITWEB_LOGO\n    Points to the location where you put git-logo.png on your web server.\n+ * GITWEB_CONFIG\n+   This file will be loaded using 'require'.  If the environment\n+   $GITWEB_CONFIG is set when gitweb.cgi is executed the file in the\n+   environment variable will be loaded additionally (after) the file\n+   specified when gitweb.cgi was created.\n \n Originally written by:\n   Kay Sievers <kay.sievers@vrfy.org>\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex f4c0d87..efcc926 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -63,6 +63,10 @@ our $mimetypes_file = undef;\n our $GITWEB_CONFIG = '@@GITWEB_CONFIG@@';\n require $GITWEB_CONFIG if -e $GITWEB_CONFIG;\n \n+if (defined($ENV{'GITWEB_CONFIG'}) && -e $ENV{'GITWEB_CONFIG'}) {\n+\trequire $ENV{'GITWEB_CONFIG'};\n+}\n+\n # version of the core git binary\n our $git_version = qx($GIT --version) =~ m/git version (.*)$/ ? $1 : \"unknown\";\n \n-- \n1.4.2.rc2.g4713\n"},{"id":"24592","messageId":"E1G8NNl-0006ez-6J@moooo.ath.cx","threadId":"5095","inReplyTo":"ear1fp$j9p$2@sea.gmane.org","subject":"Re: [PATCH] gitweb: optionally read config from GITWEB_CONFIG","fromName":"Matthias Lederhofer","fromEmail":"matled@gmx.net","sentAt":"2006-08-02T20:31:57Z","receivedAt":"2006-08-02T20:31:57Z","isPatch":true,"sender":{"key":"matled@gmx.net","avatar":null},"body":"Jakub Narebski <jnareb@gmail.com> wrote:\n> Jeff King wrote:\n> > @@ -56,7 +50,7 @@ # URI of GIT logo\n> >  our $logo = \"@@GITWEB_LOGO@@\";\n> >  \n> >  # source of projects list\n> > -our $projects_list = \"@@GITWEB_LIST@@\" || \"$projectroot\";\n> > +our $projects_list = \"@@GITWEB_LIST@@\";\n> >  \n> >  # default blob_plain mimetype and default charset for text/plain blob\n> >  our $default_blob_plain_mimetype = 'text/plain';\n> \n> But why that change?\nEarlier this was undef if the user did not change it.  Now this is\nalways a string so the second one will probably never come into play\nexcept the user chooses to set the string to undef again.\n"},{"id":"24593","messageId":"ear2bb$j9p$3@sea.gmane.org","threadId":"5095","inReplyTo":"E1G8NNl-0006ez-6J@moooo.ath.cx","subject":"Re: [PATCH] gitweb: optionally read config from GITWEB_CONFIG","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-08-02T20:36:25Z","receivedAt":"2006-08-02T20:36:25Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Matthias Lederhofer wrote:\n\n> Jakub Narebski <jnareb@gmail.com> wrote:\n>> Jeff King wrote:\n>> > @@ -56,7 +50,7 @@ # URI of GIT logo\n>> >  our $logo = \"@@GITWEB_LOGO@@\";\n>> >  \n>> >  # source of projects list\n>> > -our $projects_list = \"@@GITWEB_LIST@@\" || \"$projectroot\";\n>> > +our $projects_list = \"@@GITWEB_LIST@@\";\n>> >  \n>> >  # default blob_plain mimetype and default charset for text/plain blob\n>> >  our $default_blob_plain_mimetype = 'text/plain';\n>> \n>> But why that change?\n> Earlier this was undef if the user did not change it.  Now this is\n> always a string so the second one will probably never come into play\n> except the user chooses to set the string to undef again.\n\nEmpty string is also false in Perl. Try\n\n  perl -e 'my $var = \"\" || \"other\"; print \"var = $var\\n\";'\n\nI'd rather use $projectroot for $projects_list, preferably without needing\nto set $projects_list.\n\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"},{"id":"24594","messageId":"20060802204154.GA15678@sigio.intra.peff.net","threadId":"5095","inReplyTo":"ear1fp$j9p$2@sea.gmane.org","subject":"Re: [PATCH] gitweb: optionally read config from GITWEB_CONFIG","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2006-08-02T20:41:54Z","receivedAt":"2006-08-02T20:41:54Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Aug 02, 2006 at 10:21:43PM +0200, Jakub Narebski wrote:\n\n> > @@ -56,7 +50,7 @@ # URI of GIT logo\n> >  our $logo = \"@@GITWEB_LOGO@@\";\n> >  \n> >  # source of projects list\n> > -our $projects_list = \"@@GITWEB_LIST@@\" || \"$projectroot\";\n> > +our $projects_list = \"@@GITWEB_LIST@@\";\n> >  \n> >  # default blob_plain mimetype and default charset for text/plain blob\n> >  our $default_blob_plain_mimetype = 'text/plain';\n> \n> But why that change?\n\nBecause the previous order was:\n  1. set projectroot to build-time default\n  2. set projects_list to build-time default or $projectroot\n  3. read variables, including $projectroot, from config file\nIf you kept $projects_list empty but set $projectroot in your config,\nthe value of projects_list would be the build-time $projectroot, not the\nconfig-time. If you look further in the patch, you will see that we set\nup projects_list later.\n\n-Peff\n"},{"id":"24595","messageId":"20060802205033.GB15678@sigio.intra.peff.net","threadId":"5095","inReplyTo":"E1G8NLU-0006TL-J7@moooo.ath.cx","subject":"Re: [PATCH] gitweb: require $ENV{'GITWEB_CONFIG'}","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2006-08-02T20:50:33Z","receivedAt":"2006-08-02T20:50:33Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Aug 02, 2006 at 10:29:36PM +0200, Matthias Lederhofer wrote:\n\n> --- a/gitweb/gitweb.perl\n> +++ b/gitweb/gitweb.perl\n> @@ -63,6 +63,10 @@ our $mimetypes_file = undef;\n>  our $GITWEB_CONFIG = '@@GITWEB_CONFIG@@';\n>  require $GITWEB_CONFIG if -e $GITWEB_CONFIG;\n>  \n> +if (defined($ENV{'GITWEB_CONFIG'}) && -e $ENV{'GITWEB_CONFIG'}) {\n> +\trequire $ENV{'GITWEB_CONFIG'};\n> +}\n> +\n>  # version of the core git binary\n>  our $git_version = qx($GIT --version) =~ m/git version (.*)$/ ? $1 : \"unknown\";\n\nI think this patch is a good idea, but it seems confusing to have two\ndifferent config files. Maybe the environment should trump the built-in\ndefault:\n  our $GITWEB_CONFIG = $ENV{GITWEB_CONFIG} || '@@GITWEB_CONFIG@@';\nWhich actually might be a reasonable thing for all of the config\ndirectives (so people can use a config file, apache environment munging,\nor the built-in defaults). I would think the sanest order would be\nenvironment, then config file, then built-ins (which is what all the\nrest of the git programs do).\n\n-Peff\n"},{"id":"24596","messageId":"7vmzamuaj6.fsf@assigned-by-dhcp.cox.net","threadId":"5095","inReplyTo":"E1G8N9c-0004GK-Gz@moooo.ath.cx","subject":"Re: [PATCH] gitweb: use single quotes for values replaced by the Makefile","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-08-02T20:50:53Z","receivedAt":"2006-08-02T20:50:53Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"I understand that (1) \"@@FOO@@\" is problematic, (2) being able\nto run gitweb/gitweb.perl while coming up with improvements is\nnice, but (3) not being able to say \"/etc/foo/$ENV{SITE_NAME}\"\nis quite a drawback on the deployment side.\n\nSo why don't we use something other than @@, perhaps \"++FOO++\"?\n\nI'm inclined to take these two patches:\n\n    gitweb: optionally read config from GITWEB_CONFIG (Jeff King)\n    gitweb: require $ENV{'GITWEB_CONFIG'} (Matthias Lederhofer)\n\nso on top of them something like this?\n\n-- >8 --\n[PATCH] gitweb: do not use @@FOO@@ for replaced tokens\n\nThis makes it easier to run gitweb/gitweb.perl without token substitution.\nUsing @@ makes Perl emit \"unintended interpolation\" warnings.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n Makefile           |   18 +++++++++---------\n gitweb/gitweb.perl |   18 +++++++++---------\n 2 files changed, 18 insertions(+), 18 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex a2b4aca..3816ef7 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -584,15 +584,15 @@ git-status: git-commit\n gitweb/gitweb.cgi: gitweb/gitweb.perl\n \trm -f $@ $@+\n \tsed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \\\n-\t    -e 's|@@GIT_VERSION@@|$(GIT_VERSION)|g' \\\n-\t    -e 's|@@GIT_BINDIR@@|$(bindir)|g' \\\n-\t    -e 's|@@GITWEB_CONFIG@@|$(GITWEB_CONFIG)|g' \\\n-\t    -e 's|@@GITWEB_SITENAME@@|$(GITWEB_SITENAME)|g' \\\n-\t    -e 's|@@GITWEB_PROJECTROOT@@|$(GITWEB_PROJECTROOT)|g' \\\n-\t    -e 's|@@GITWEB_LIST@@|$(GITWEB_LIST)|g' \\\n-\t    -e 's|@@GITWEB_HOMETEXT@@|$(GITWEB_HOMETEXT)|g' \\\n-\t    -e 's|@@GITWEB_CSS@@|$(GITWEB_CSS)|g' \\\n-\t    -e 's|@@GITWEB_LOGO@@|$(GITWEB_LOGO)|g' \\\n+\t    -e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \\\n+\t    -e 's|++GIT_BINDIR++|$(bindir)|g' \\\n+\t    -e 's|++GITWEB_CONFIG++|$(GITWEB_CONFIG)|g' \\\n+\t    -e 's|++GITWEB_SITENAME++|$(GITWEB_SITENAME)|g' \\\n+\t    -e 's|++GITWEB_PROJECTROOT++|$(GITWEB_PROJECTROOT)|g' \\\n+\t    -e 's|++GITWEB_LIST++|$(GITWEB_LIST)|g' \\\n+\t    -e 's|++GITWEB_HOMETEXT++|$(GITWEB_HOMETEXT)|g' \\\n+\t    -e 's|++GITWEB_CSS++|$(GITWEB_CSS)|g' \\\n+\t    -e 's|++GITWEB_LOGO++|$(GITWEB_LOGO)|g' \\\n \t    $< >$@+\n \tchmod +x $@+\n \tmv $@+ $@\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex c7f13e7..3cd2b89 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -18,18 +18,18 @@ use File::Find qw();\n binmode STDOUT, ':utf8';\n \n our $cgi = new CGI;\n-our $version = \"@@GIT_VERSION@@\";\n+our $version = \"++GIT_VERSION++\";\n our $my_url = $cgi->url();\n our $my_uri = $cgi->url(-absolute => 1);\n our $rss_link = \"\";\n \n # core git executable to use\n # this can just be \"git\" if your webserver has a sensible PATH\n-our $GIT = \"@@GIT_BINDIR@@/git\";\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+our $projectroot = \"++GITWEB_PROJECTROOT++\";\n \n # location for temporary files needed for diffs\n our $git_temp = \"/tmp/gitweb\";\n@@ -39,18 +39,18 @@ our $home_link = $my_uri;\n \n # name of your site or organization to appear in page titles\n # replace this with something more descriptive for clearer bookmarks\n-our $site_name = \"@@GITWEB_SITENAME@@\" || $ENV{'SERVER_NAME'} || \"Untitled\";\n+our $site_name = \"++GITWEB_SITENAME++\" || $ENV{'SERVER_NAME'} || \"Untitled\";\n \n # html text to include at home page\n-our $home_text = \"@@GITWEB_HOMETEXT@@\";\n+our $home_text = \"++GITWEB_HOMETEXT++\";\n \n # URI of default stylesheet\n-our $stylesheet = \"@@GITWEB_CSS@@\";\n+our $stylesheet = \"++GITWEB_CSS++\";\n # URI of GIT logo\n-our $logo = \"@@GITWEB_LOGO@@\";\n+our $logo = \"++GITWEB_LOGO++\";\n \n # source of projects list\n-our $projects_list = \"@@GITWEB_LIST@@\";\n+our $projects_list = \"++GITWEB_LIST++\";\n \n # default blob_plain mimetype and default charset for text/plain blob\n our $default_blob_plain_mimetype = 'text/plain';\n@@ -60,7 +60,7 @@ # file to use for guessing MIME types be\n # (relative to the current git repository)\n our $mimetypes_file = undef;\n \n-our $GITWEB_CONFIG = \"@@GITWEB_CONFIG@@\";\n+our $GITWEB_CONFIG = \"++GITWEB_CONFIG++\";\n require $GITWEB_CONFIG if -e $GITWEB_CONFIG;\n \n if (defined($ENV{'GITWEB_CONFIG'}) && -e $ENV{'GITWEB_CONFIG'}) {\n-- \n1.4.2.rc2.g767b2\n"},{"id":"24597","messageId":"20060802205120.84032.qmail@web31808.mail.mud.yahoo.com","threadId":"5095","inReplyTo":"20060802192333.GA30861@coredump.intra.peff.net","subject":"Re: [PATCH] gitweb: optionally read config from GITWEB_CONFIG","fromName":"Luben Tuikov","fromEmail":"ltuikov@yahoo.com","sentAt":"2006-08-02T20:51:20Z","receivedAt":"2006-08-02T20:51:20Z","isPatch":true,"sender":{"key":"ltuikov@yahoo.com","avatar":null},"body":"--- Jeff King <peff@peff.net> wrote:\n> Configuration will first be taken from variables inside the gitweb.cgi\n> script, which in turn come from the Makefile. Afterwards, the contents of\n> GITWEB_CONFIG are read, overriding the builtin defaults.\n> \n> This should eliminate the need for editing the gitweb script at all. Users\n> should edit the Makefile and/or add a config file.\n\nI don't think users should even edit the Makefile.  Makefiles are normally\nedited when the _build_ environment differs, not when the deployment\nenvironment differs.\n\nFor example, some of us use the same gitweb.cgi/perl/pl (or whatever the\nnext completely unnecessary renaming would be) for deployment on several\n\"sites\" and repositories.\n\nI cannot imagine anyone who actually _uses_ and maintains gitweb.cgi/perl/pl\nto edit the Makefile for their deployment, thus having to have a forked off\nbranch(es) for each of their deployments (which the only diff editing the Makefile).\n\n    Luben\n\n> \n> Signed-off-by: Jeff King <peff@peff.net>\n> ---\n> This is on top of next.\n> \n> This patch seemed to get a favorable response, so I cleaned it up and\n> actually tested it. The main changes are reordering a few of the setup\n> statements so that changes introduced in the config file are respected\n> as suggested by Matthias (and a few by me). It would be good if other\n> gitweb people could check it over and/or try it with their config to\n> make sure I didn't miss anything.\n> \n>  Makefile           |    2 ++\n>  gitweb/gitweb.perl |   19 ++++++++++++-------\n>  2 files changed, 14 insertions(+), 7 deletions(-)\n> \n> diff --git a/Makefile b/Makefile\n> index 2562a2c..170d082 100644\n> --- a/Makefile\n> +++ b/Makefile\n> @@ -127,6 +127,7 @@ GIT_PYTHON_DIR = $(prefix)/share/git-cor\n>  # DESTDIR=\n>  \n>  # default configuration for gitweb\n> +GITWEB_CONFIG = gitweb_config.perl\n>  GITWEB_SITENAME =\n>  GITWEB_PROJECTROOT = /pub/git\n>  GITWEB_LIST =\n> @@ -629,6 +630,7 @@ gitweb/gitweb.cgi: gitweb/gitweb.perl\n>  \tsed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \\\n>  \t    -e 's|@@GIT_VERSION@@|$(GIT_VERSION)|g' \\\n>  \t    -e 's|@@GIT_BINDIR@@|$(bindir)|g' \\\n> +\t    -e 's|@@GITWEB_CONFIG@@|$(GITWEB_CONFIG)|g' \\\n>  \t    -e 's|@@GITWEB_SITENAME@@|$(GITWEB_SITENAME)|g' \\\n>  \t    -e 's|@@GITWEB_PROJECTROOT@@|$(GITWEB_PROJECTROOT)|g' \\\n>  \t    -e 's|@@GITWEB_LIST@@|$(GITWEB_LIST)|g' \\\n> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\n> index 1db1414..d5b2de8 100755\n> --- a/gitweb/gitweb.perl\n> +++ b/gitweb/gitweb.perl\n> @@ -31,14 +31,8 @@ # absolute fs-path which will be prepend\n>  #our $projectroot = \"/pub/scm\";\n>  our $projectroot = \"@@GITWEB_PROJECTROOT@@\";\n>  \n> -# version of the core git binary\n> -our $git_version = qx($GIT --version) =~ m/git version (.*)$/ ? $1 : \"unknown\";\n> -\n>  # location for temporary files needed for diffs\n>  our $git_temp = \"/tmp/gitweb\";\n> -if (! -d $git_temp) {\n> -\tmkdir($git_temp, 0700) || die_error(\"Couldn't mkdir $git_temp\");\n> -}\n>  \n>  # target of the home link on top of all pages\n>  our $home_link = $my_uri;\n> @@ -56,7 +50,7 @@ # URI of GIT logo\n>  our $logo = \"@@GITWEB_LOGO@@\";\n>  \n>  # source of projects list\n> -our $projects_list = \"@@GITWEB_LIST@@\" || \"$projectroot\";\n> +our $projects_list = \"@@GITWEB_LIST@@\";\n>  \n>  # default blob_plain mimetype and default charset for text/plain blob\n>  our $default_blob_plain_mimetype = 'text/plain';\n> @@ -66,6 +60,17 @@ # file to use for guessing MIME types be\n>  # (relative to the current git repository)\n>  our $mimetypes_file = undef;\n>  \n> +our $GITWEB_CONFIG = \"@@GITWEB_CONFIG@@\";\n> +require $GITWEB_CONFIG if -e $GITWEB_CONFIG;\n> +\n> +# version of the core git binary\n> +our $git_version = qx($GIT --version) =~ m/git version (.*)$/ ? $1 : \"unknown\";\n> +\n> +$projects_list ||= $projectroot;\n> +if (! -d $git_temp) {\n> +\tmkdir($git_temp, 0700) || die_error(\"Couldn't mkdir $git_temp\");\n> +}\n> +\n>  # input validation and dispatch\n>  our $action = $cgi->param('a');\n>  if (defined $action) {\n> -- \n> 1.4.2.rc2.g59706-dirty\n> -\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n> \n"},{"id":"24599","messageId":"20060802205606.GC15678@sigio.intra.peff.net","threadId":"5095","inReplyTo":"20060802205120.84032.qmail@web31808.mail.mud.yahoo.com","subject":"Re: [PATCH] gitweb: optionally read config from GITWEB_CONFIG","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2006-08-02T20:56:06Z","receivedAt":"2006-08-02T20:56:06Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Aug 02, 2006 at 01:51:20PM -0700, Luben Tuikov wrote:\n\n> I don't think users should even edit the Makefile.  Makefiles are normally\n> edited when the _build_ environment differs, not when the deployment\n> environment differs.\n\nI don't either; I should have stated more clearly: users can edit\nconfig.mak or use command line parameters to make (the same way they do\nfor prefix or other variables).\n\nYou don't even have to do that if the default config-file path is fine\nfor you. And even if you don't, you should be able to set GITWEB_CONF\nwith Matthias' patch.\n\n-Peff\n"},{"id":"24600","messageId":"E1G8Nm7-0007bC-7d@moooo.ath.cx","threadId":"5095","inReplyTo":"7vmzamuaj6.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] gitweb: use single quotes for values replaced by the Makefile","fromName":"Matthias Lederhofer","fromEmail":"matled@gmx.net","sentAt":"2006-08-02T20:57:07Z","receivedAt":"2006-08-02T20:57:07Z","isPatch":true,"sender":{"key":"matled@gmx.net","avatar":null},"body":"Junio C Hamano <junkio@cox.net> wrote:\n> I understand that (1) \"@@FOO@@\" is problematic, (2) being able\n> to run gitweb/gitweb.perl while coming up with improvements is\n> nice, but (3) not being able to say \"/etc/foo/$ENV{SITE_NAME}\"\n> is quite a drawback on the deployment side.\n> \n> So why don't we use something other than @@, perhaps \"++FOO++\"?\nThat's the other way to solve this.  If there is no typical character\nfor filenames which is handled different in double quotes this is fine\nfor me too.\n\n> I'm inclined to take these two patches:\n> \n>     gitweb: optionally read config from GITWEB_CONFIG (Jeff King)\n>     gitweb: require $ENV{'GITWEB_CONFIG'} (Matthias Lederhofer)\nThe suggestion by Jeff King to use\nour $GITWEB_CONFIG = $ENV{GITWEB_CONFIG} || '@@GITWEB_CONFIG@@';\nsounds reasonable too.\n\n> so on top of them something like this?\n[patch replacing @@ with ++]\n\nAck.\n"},{"id":"24601","messageId":"7vhd0uua6e.fsf@assigned-by-dhcp.cox.net","threadId":"5095","inReplyTo":"20060802205033.GB15678@sigio.intra.peff.net","subject":"Re: [PATCH] gitweb: require $ENV{'GITWEB_CONFIG'}","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-08-02T20:58:33Z","receivedAt":"2006-08-02T20:58:33Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> I think this patch is a good idea, but it seems confusing to have two\n> Maybe the environment should trump the built-in\n> default:\n>   our $GITWEB_CONFIG = $ENV{GITWEB_CONFIG} || '@@GITWEB_CONFIG@@';\n> which actually might be a reasonable thing for all of the config\n> directives (so people can use a config file, apache environment munging,\n> or the built-in defaults).\n\nSounds very sane.  So Matthias's patch now becomes something\nlike this:\n\n-- >8 --\ndiff --git a/gitweb/README b/gitweb/README\nindex b91d42a..dc4b850 100644\n--- a/gitweb/README\n+++ b/gitweb/README\n@@ -23,6 +23,11 @@ You can specify the following configurat\n    Points to the location where you put gitweb.css on your web server.\n  * GITWEB_LOGO\n    Points to the location where you put git-logo.png on your web server.\n+ * GITWEB_CONFIG\n+   This file will be loaded using 'require'.  If the environment\n+   $GITWEB_CONFIG is set when gitweb.cgi is executed the file in the\n+   environment variable will be loaded instead of the file\n+   specified when gitweb.cgi was created.\n \n Originally written by:\n   Kay Sievers <kay.sievers@vrfy.org>\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex d5b2de8..c7f13e7 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -63,6 +63,6 @@ our $mimetypes_file = undef;\n-our $GITWEB_CONFIG = \"@@GITWEB_CONFIG@@\";\n+our $GITWEB_CONFIG = $ENV{'GITWEB_CONFIG'} || \"@@GITWEB_CONFIG@@\";\n require $GITWEB_CONFIG if -e $GITWEB_CONFIG;\n \n # version of the core git binary\n our $git_version = qx($GIT --version) =~ m/git version (.*)$/ ? $1 : \"unknown\";\n"},{"id":"24602","messageId":"20060802205858.GA15714@sigio.intra.peff.net","threadId":"5095","inReplyTo":"7vmzamuaj6.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] gitweb: use single quotes for values replaced by the Makefile","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2006-08-02T20:58:58Z","receivedAt":"2006-08-02T20:58:58Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Aug 02, 2006 at 01:50:53PM -0700, Junio C Hamano wrote:\n\n> So why don't we use something other than @@, perhaps \"++FOO++\"?\n\nAcked-by: Jeff King <peff@peff.net>\n"},{"id":"24603","messageId":"20060802205951.GB15714@sigio.intra.peff.net","threadId":"5095","inReplyTo":"7vhd0uua6e.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] gitweb: require $ENV{'GITWEB_CONFIG'}","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2006-08-02T20:59:51Z","receivedAt":"2006-08-02T20:59:51Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Aug 02, 2006 at 01:58:33PM -0700, Junio C Hamano wrote:\n\n> Sounds very sane.  So Matthias's patch now becomes something\n> like this:\n\nAcked-by: Jeff King <peff@peff.net>\n"}]}