From: Junio C Hamano <gitster@pobox.com>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: Jonathan Nieder <jrnieder@gmail.com>, Martin Mares <mj@ucw.cz>,
git@vger.kernel.org
Subject: Re: gitweb: local configuration not found
Date: Thu, 06 Dec 2018 09:56:48 +0900 [thread overview]
Message-ID: <xmqq5zw7bhgv.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <87bm5zzt4a.fsf@evledraar.gmail.com> ("Ævar Arnfjörð Bjarmason"'s message of "Wed, 05 Dec 2018 20:11:17 +0100")
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
>> Documentation says "If you are absolutely certain that you want your
>> script to load and execute a file from the current directory, then use
>> a ./ prefix". We can do that, like so:
>>
>> diff --git i/gitweb/Makefile w/gitweb/Makefile
>> index cd194d057f..3160b6cc5d 100644
>> --- i/gitweb/Makefile
>> +++ w/gitweb/Makefile
>> @@ -18,7 +18,7 @@ RM ?= rm -f
>> INSTALL ?= install
>>
>> # default configuration for gitweb
>> -GITWEB_CONFIG = gitweb_config.perl
>> +GITWEB_CONFIG = ./gitweb_config.perl
>> GITWEB_CONFIG_SYSTEM = /etc/gitweb.conf
>> GITWEB_CONFIG_COMMON = /etc/gitweb-common.conf
>> GITWEB_HOME_LINK_STR = projects
>>
>> but that does not help if someone overrides GITWEB_CONFIG, and besides,
>> it would be nicer to avoid the possibility of an @INC search altogether.
>> ...
> Just:
>
> local @INC = '.';
> do 'FILE.pl';
>
> Would do the same thing, but seems like a more indirect way to do it if
> all we want is ./ anyway.
Yeah, it does look indirect. Despite what you said, it also would
support users giving an absolute path via GITWEB_CONFIG.
With "use File::Spec", perhaps something like this?
gitweb/gitweb.perl | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 2594a4badb..239e7cbc25 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -719,6 +719,10 @@ sub filter_and_validate_refs {
sub read_config_file {
my $filename = shift;
return unless defined $filename;
+
+ $filename = File::Spec->catfile(".", $filename)
+ unless File::Spec->file_name_is_absolute($filename);
+
# die if there are errors parsing config file
if (-e $filename) {
do $filename;
next prev parent reply other threads:[~2018-12-06 0:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <154401401074.29584.11169979442731329694.reportbug@gimli.ms.mff.cuni.cz>
2018-12-05 18:44 ` gitweb: local configuration not found Jonathan Nieder
2018-12-05 19:11 ` Ævar Arnfjörð Bjarmason
2018-12-06 0:56 ` Junio C Hamano [this message]
2018-12-06 15:02 ` Martin Mareš
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqq5zw7bhgv.fsf@gitster-ct.c.googlers.com \
--to=gitster@pobox.com \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=jrnieder@gmail.com \
--cc=mj@ucw.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).