{"thread":{"id":"24317","subject":"[PATCHv2/RFC] gitweb: Prepare for splitting gitweb","startedAt":"2010-07-07T09:57:56Z","lastAt":"2010-07-14T21:21:24Z","messageCount":14,"participants":["Jakub Narebski","Ævar Arnfjörð Bjarmason","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"145014","messageId":"1278496676-26575-1-git-send-email-jnareb@gmail.com","threadId":"24317","inReplyTo":null,"subject":"[PATCHv2/RFC] gitweb: Prepare for splitting gitweb","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2010-07-07T09:57:56Z","receivedAt":"2010-07-07T09:57:56Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Prepare gitweb for having been split into modules that are to be\ninstalled alongside gitweb in 'lib/' subdirectory, by adding\n\n  use lib __DIR__.'/lib';\n\nto gitweb.perl (to main gitweb script), and preparing for putting\nmodules (relative path) in $(GITWEB_MODULES) in gitweb/Makefile.\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\n\nThis version uses shell 'for' loop, instead of make's $(foreach)\nfunction, to avoid possible problem with generating a command line\nthat exceeded the maximum argument list length.  This solution has\nalso advantage of being more readable than original $(foreach ...)\nversion, with its overly long lines.\n\nThis idea is based on discussion surrounding Brandon Casey's patch.\nIn particular Bruce Stephens's suggestion was implemented to solve\nissue of empty $(GITWEB_MODULES) variable (which is in this patch),\nas implemented in\n  [PATCH 2/2 v2] Makefile: work around ksh's failure to handle missing list argument to for loop\n  http://thread.gmane.org/gmane.comp.version-control.git/147796/focus=150413\n\nThis version also moves installing modules to separate install-modules\ntarget, as compared to previous version.\n\nIt also contains improvement from Pavan Kumar Sunkara, namely that\ntarget is a directory, rather than destibation filename.  This might\nbe not necessary (and not much of an improvement).\n\n gitweb/Makefile    |   14 +++++++++++++-\n gitweb/gitweb.perl |    9 +++++++++\n 2 files changed, 22 insertions(+), 1 deletions(-)\n\ndiff --git a/gitweb/Makefile b/gitweb/Makefile\nindex 2fb7c2d..84a1d71 100644\n--- a/gitweb/Makefile\n+++ b/gitweb/Makefile\n@@ -55,6 +55,7 @@ PERL_PATH  ?= /usr/bin/perl\n bindir_SQ = $(subst ','\\'',$(bindir))#'\n gitwebdir_SQ = $(subst ','\\'',$(gitwebdir))#'\n gitwebstaticdir_SQ = $(subst ','\\'',$(gitwebdir)/static)#'\n+gitweblibdir_SQ = $(subst ','\\'',$(gitwebdir)/lib)#'\n SHELL_PATH_SQ = $(subst ','\\'',$(SHELL_PATH))#'\n PERL_PATH_SQ  = $(subst ','\\'',$(PERL_PATH))#'\n DESTDIR_SQ    = $(subst ','\\'',$(DESTDIR))#'\n@@ -145,12 +146,23 @@ gitweb.cgi: gitweb.perl GITWEB-BUILD-OPTIONS\n \n ### Installation rules\n \n-install: all\n+install: all install-modules\n \t$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebdir_SQ)'\n \t$(INSTALL) -m 755 $(GITWEB_PROGRAMS) '$(DESTDIR_SQ)$(gitwebdir_SQ)'\n \t$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)'\n \t$(INSTALL) -m 644 $(GITWEB_FILES) '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)'\n \n+install-modules:\n+\tinstall_dirs=$(sort $(dir $(GITWEB_MODULES))) && \\\n+\tfor dir in $$install_dirs; do \\\n+\t\ttest -d '$(DESTDIR_SQ)$(gitwebdir_SQ)/$$dir' || \\\n+\t\t$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebdir_SQ)/$$dir'; \\\n+\tdone\n+\tgitweb_modules=$(GITWEB_MODULES) && \\\n+\tfor mod in $$gitweb_modules; do \\\n+\t\t$(INSTALL) -m 644 $$mod '$(DESTDIR_SQ)$(gitwebdir_SQ)/$$(dirname $$mod)'; \\\n+\tdone\n+\n ### Cleaning rules\n \n clean:\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 1f611d2..bf1485c 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -9,6 +9,14 @@\n \n use strict;\n use warnings;\n+\n+use File::Spec;\n+# __DIR__ is taken from Dir::Self __DIR__ fragment\n+sub __DIR__ () {\n+\tFile::Spec->rel2abs(join '', (File::Spec->splitpath(__FILE__))[0, 1]);\n+}\n+use lib __DIR__ . '/lib';\n+\n use CGI qw(:standard :escapeHTML -nosticky);\n use CGI::Util qw(unescape);\n use CGI::Carp qw(fatalsToBrowser set_message);\n@@ -16,6 +24,7 @@ use Encode;\n use Fcntl ':mode';\n use File::Find qw();\n use File::Basename qw(basename);\n+\n binmode STDOUT, ':utf8';\n \n our $t0;\n-- \n1.7.0.1\n"},{"id":"145015","messageId":"AANLkTinxDSS2G60_nQ12UqZpSJCvg_kfWYKzmTqJU7Ox@mail.gmail.com","threadId":"24317","inReplyTo":"1278496676-26575-1-git-send-email-jnareb@gmail.com","subject":"Re: [PATCHv2/RFC] gitweb: Prepare for splitting gitweb","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2010-07-07T10:30:12Z","receivedAt":"2010-07-07T10:30:12Z","isPatch":false,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Wed, Jul 7, 2010 at 09:57, Jakub Narebski <jnareb@gmail.com> wrote:\n> [...]\n>  use strict;\n>  use warnings;\n> +\n> +use File::Spec;\n> +# __DIR__ is taken from Dir::Self __DIR__ fragment\n> +sub __DIR__ () {\n> +       File::Spec->rel2abs(join '', (File::Spec->splitpath(__FILE__))[0, 1]);\n> +}\n> +use lib __DIR__ . '/lib';\n> +\n\nWhat was the result of the discussion about using __DIR__ again? You\nonly need to use that method when you call a perl program whith *then*\nincludes a module. If you just need to add the lib/ directory relative\nto the script you're invoking you can use FindBin:\n\n    use FindBin qw($Bin);\n    use lib \"$Bin/lib\";\n\n>  use CGI qw(:standard :escapeHTML -nosticky);\n>  use CGI::Util qw(unescape);\n>  use CGI::Carp qw(fatalsToBrowser set_message);\n> @@ -16,6 +24,7 @@ use Encode;\n>  use Fcntl ':mode';\n>  use File::Find qw();\n>  use File::Basename qw(basename);\n> +\n>  binmode STDOUT, ':utf8';\n\nThe whitespace change distracts from the real patch a bit.\n"},{"id":"145030","messageId":"7viq4rxnro.fsf@alter.siamese.dyndns.org","threadId":"24317","inReplyTo":"1278496676-26575-1-git-send-email-jnareb@gmail.com","subject":"Re: [PATCHv2/RFC] gitweb: Prepare for splitting gitweb","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-07-07T16:25:15Z","receivedAt":"2010-07-07T16:25:15Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n> diff --git a/gitweb/Makefile b/gitweb/Makefile\n> index 2fb7c2d..84a1d71 100644\n> --- a/gitweb/Makefile\n> +++ b/gitweb/Makefile\n> @@ -145,12 +146,23 @@ gitweb.cgi: gitweb.perl GITWEB-BUILD-OPTIONS\n>  \n>  ### Installation rules\n>  \n> -install: all\n> +install: all install-modules\n>  \t$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebdir_SQ)'\n>  \t$(INSTALL) -m 755 $(GITWEB_PROGRAMS) '$(DESTDIR_SQ)$(gitwebdir_SQ)'\n>  \t$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)'\n>  \t$(INSTALL) -m 644 $(GITWEB_FILES) '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)'\n>  \n> +install-modules:\n> +\tinstall_dirs=$(sort $(dir $(GITWEB_MODULES))) && \\\n> +\tfor dir in $$install_dirs; do \\\n> +\t\ttest -d '$(DESTDIR_SQ)$(gitwebdir_SQ)/$$dir' || \\\n> +\t\t$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebdir_SQ)/$$dir'; \\\n> +\tdone\n> +\tgitweb_modules=$(GITWEB_MODULES) && \\\n> +\tfor mod in $$gitweb_modules; do \\\n> +\t\t$(INSTALL) -m 644 $$mod '$(DESTDIR_SQ)$(gitwebdir_SQ)/$$(dirname $$mod)'; \\\n> +\tdone\n> +\n\nSorry, but you lost me here.  Where is GITWEB_MODULES defined (iow, what\ncommit is this patch supposed to be applied)?\n\nI also suspect that your assignment to \"install_dirs\" is completely bogus\nwhen the files listed in GITWEB_MODULES span multiple directories.\n"},{"id":"145048","messageId":"201007072205.14345.jnareb@gmail.com","threadId":"24317","inReplyTo":"AANLkTinxDSS2G60_nQ12UqZpSJCvg_kfWYKzmTqJU7Ox@mail.gmail.com","subject":"Re: [PATCHv2/RFC] gitweb: Prepare for splitting gitweb","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2010-07-07T20:05:12Z","receivedAt":"2010-07-07T20:05:12Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Wed, 7 Jul 2010, Ævar Arnfjörð Bjarmason napisał:\n> On Wed, Jul 7, 2010 at 09:57, Jakub Narebski <jnareb@gmail.com> wrote:\n> > [...]\n> >  use strict;\n> >  use warnings;\n> > +\n> > +use File::Spec;\n> > +# __DIR__ is taken from Dir::Self __DIR__ fragment\n> > +sub __DIR__ () {\n> > +       File::Spec->rel2abs(join '', (File::Spec->splitpath(__FILE__))[0, 1]);\n> > +}\n> > +use lib __DIR__ . '/lib';\n> > +\n> \n> What was the result of the discussion about using __DIR__ again? You\n> only need to use that method when you call a perl program whith *then*\n> includes a module. If you just need to add the lib/ directory relative\n> to the script you're invoking you can use FindBin:\n> \n>     use FindBin qw($Bin);\n>     use lib \"$Bin/lib\";\n\nIt's\n\n      use lib \"$Bin/../lib\";\n\n(I don't like this ../lib here, but that's my personal preference).\n\nBut you might be right that I am overly cautious in avoiding FindBin.\nIt is nowadays not recommended solution (on #perl, for example), but\nit is perhaps true that the conditions where it fails are not fulfilled\nfor the case of gitweb.\n\nOr perhaps not:\n\n  KNOWN ISSUES\n\n  If there are two modules using FindBin from different directories\n  under the same interpreter, this won't work. Since FindBin uses a\n  BEGIN block, it'll be executed only once, and only the first caller\n  will get it right. This is a problem under **mod_perl** and other\n  persistent Perl environments, where you shouldn't use this module.\n\nGitweb can be used under mod_perl (to be more exact ModPerl::Registry).\n\n> >  use CGI qw(:standard :escapeHTML -nosticky);\n> >  use CGI::Util qw(unescape);\n> >  use CGI::Carp qw(fatalsToBrowser set_message);\n> > @@ -16,6 +24,7 @@ use Encode;\n> >  use Fcntl ':mode';\n> >  use File::Find qw();\n> >  use File::Basename qw(basename);\n> > +\n> >  binmode STDOUT, ':utf8';\n> \n> The whitespace change distracts from the real patch a bit.\n\nOoops, I'm sorry.\n\nI'll fix it in resend, if required.\n-- \nJakub Narebski\nPoland\n"},{"id":"145049","messageId":"201007072220.18824.jnareb@gmail.com","threadId":"24317","inReplyTo":"7viq4rxnro.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCHv2/RFC] gitweb: Prepare for splitting gitweb","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2010-07-07T20:20:18Z","receivedAt":"2010-07-07T20:20:18Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Wed, 7 Jul 2010, Junio C Hamano wrote:\n> Jakub Narebski <jnareb@gmail.com> writes:\n> \n> > diff --git a/gitweb/Makefile b/gitweb/Makefile\n> > index 2fb7c2d..84a1d71 100644\n> > --- a/gitweb/Makefile\n> > +++ b/gitweb/Makefile\n> > @@ -145,12 +146,23 @@ gitweb.cgi: gitweb.perl GITWEB-BUILD-OPTIONS\n> >  \n> >  ### Installation rules\n> >  \n> > -install: all\n> > +install: all install-modules\n> >  \t$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebdir_SQ)'\n> >  \t$(INSTALL) -m 755 $(GITWEB_PROGRAMS) '$(DESTDIR_SQ)$(gitwebdir_SQ)'\n> >  \t$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)'\n> >  \t$(INSTALL) -m 644 $(GITWEB_FILES) '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)'\n> >  \n> > +install-modules:\n> > +\tinstall_dirs=$(sort $(dir $(GITWEB_MODULES))) && \\\n> > +\tfor dir in $$install_dirs; do \\\n> > +\t\ttest -d '$(DESTDIR_SQ)$(gitwebdir_SQ)/$$dir' || \\\n> > +\t\t$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebdir_SQ)/$$dir'; \\\n> > +\tdone\n> > +\tgitweb_modules=$(GITWEB_MODULES) && \\\n> > +\tfor mod in $$gitweb_modules; do \\\n> > +\t\t$(INSTALL) -m 644 $$mod '$(DESTDIR_SQ)$(gitwebdir_SQ)/$$(dirname $$mod)'; \\\n> > +\tdone\n> > +\n> \n> Sorry, but you lost me here.  Where is GITWEB_MODULES defined (iow, what\n> commit is this patch supposed to be applied)?\n\nThis is preparatory patch either for Pavan GSoC2010 work on splitting\ngitweb and adding committool / admin write capabilities, or for mine\ngitweb caching series split into modules (based on J.H. patch for \ngit.kernel.org).\n\nSo currently $(GITWEB_MODULES) is not defined / empty.\n\n> I also suspect that your assignment to \"install_dirs\" is completely bogus\n> when the files listed in GITWEB_MODULES span multiple directories.\n\ninstall_dirs contains _list_ of directories gitweb modules are to be\ninstalled into.  `$(dir NAMES...)' extracts the directory-part of each\nfile name in NAMES ('./' if there is no '/' in a file name), and\n`$(sort LIST)' is used to remove duplicate words in LIST.\n\nIt was actually tested that it works for modularized gitweb caching,\nin the older form using `$(foreach ...)' rather than current shell\n'for' loop.\n\n\nFor example with the following Makefile:\n\n  GITWEB_MODULES += GitwebCache/SimpleFileCache.pm\n  GITWEB_MODULES += GitwebCache/Capture.pm\n  GITWEB_MODULES += GitwebCache/Capture/SelectFH.pm\n  GITWEB_MODULES += Gitweb/Config.pm\n  \n  all:\n  \t@echo $(sort $(dir $(GITWEB_MODULES)))\n\nrunning 'make' results in:\n\n  Gitweb/ GitwebCache/ GitwebCache/Capture/\n-- \nJakub Narebski\nPoland\n"},{"id":"145071","messageId":"7v39vustku.fsf@alter.siamese.dyndns.org","threadId":"24317","inReplyTo":"201007072220.18824.jnareb@gmail.com","subject":"Re: [PATCHv2/RFC] gitweb: Prepare for splitting gitweb","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-07-08T00:30:57Z","receivedAt":"2010-07-08T00:30:57Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n>> > +install-modules:\n>> > +\tinstall_dirs=$(sort $(dir $(GITWEB_MODULES))) && \\\n>> > ...\n>\n> For example with the following Makefile:\n>\n>   GITWEB_MODULES += GitwebCache/SimpleFileCache.pm\n>   GITWEB_MODULES += GitwebCache/Capture.pm\n>   GITWEB_MODULES += GitwebCache/Capture/SelectFH.pm\n>   GITWEB_MODULES += Gitweb/Config.pm\n>   \n>   all:\n>   \t@echo $(sort $(dir $(GITWEB_MODULES)))\n>\n> running 'make' results in:\n>\n>   Gitweb/ GitwebCache/ GitwebCache/Capture/\n\n\nTry replacing that with:\n\n\tall:\n        \tinstall_dirs=$(sort $(dir $(GITWEB_MODULES))) && \\\n                echo $$install_dirs\n\nperhaps?\n\nHint: dq.\n"},{"id":"145093","messageId":"201007080859.33958.jnareb@gmail.com","threadId":"24317","inReplyTo":"7v39vustku.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCHv2/RFC] gitweb: Prepare for splitting gitweb","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2010-07-08T06:59:30Z","receivedAt":"2010-07-08T06:59:30Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Dnia czwartek 8. lipca 2010 02:30, Junio C Hamano napisał:\n> Jakub Narebski <jnareb@gmail.com> writes:\n> \n> >> > +install-modules:\n> >> > +\tinstall_dirs=$(sort $(dir $(GITWEB_MODULES))) && \\\n> >> > ...\n> >\n> > For example with the following Makefile:\n> >\n> >   GITWEB_MODULES += GitwebCache/SimpleFileCache.pm\n> >   GITWEB_MODULES += GitwebCache/Capture.pm\n> >   GITWEB_MODULES += GitwebCache/Capture/SelectFH.pm\n> >   GITWEB_MODULES += Gitweb/Config.pm\n> >   \n> >   all:\n> >   \t@echo $(sort $(dir $(GITWEB_MODULES)))\n> >\n> > running 'make' results in:\n> >\n> >   Gitweb/ GitwebCache/ GitwebCache/Capture/\n> \n> \n> Try replacing that with:\n> \n> \tall:\n>         \tinstall_dirs=$(sort $(dir $(GITWEB_MODULES))) && \\\n>                 echo $$install_dirs\n> \n> perhaps?\n> \n> Hint: dq.\n\nYou are completely right.  I'm sorry.  I should have copied the \nstructure from \"[PATCH 2/2 v2] Makefile: work around ksh's failure to \nhandle missing list argument to for loop\" more carefully.\n\nI'll resend it.\n-- \nJakub Narebski\nPoland\n"},{"id":"145094","messageId":"201007080901.23771.jnareb@gmail.com","threadId":"24317","inReplyTo":"201007072205.14345.jnareb@gmail.com","subject":"Re: [PATCHv2/RFC] gitweb: Prepare for splitting gitweb","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2010-07-08T07:01:23Z","receivedAt":"2010-07-08T07:01:23Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Jakub Narebski wrote:\n> On Wed, 7 Jul 2010, Ævar Arnfjörð Bjarmason napisał:\n> > On Wed, Jul 7, 2010 at 09:57, Jakub Narebski <jnareb@gmail.com> wrote:\n> > > [...]\n> > >  use strict;\n> > >  use warnings;\n> > > +\n> > > +use File::Spec;\n> > > +# __DIR__ is taken from Dir::Self __DIR__ fragment\n> > > +sub __DIR__ () {\n> > > +       File::Spec->rel2abs(join '', (File::Spec->splitpath(__FILE__))[0, 1]);\n> > > +}\n> > > +use lib __DIR__ . '/lib';\n> > > +\n> > \n> > What was the result of the discussion about using __DIR__ again? You\n> > only need to use that method when you call a perl program whith *then*\n> > includes a module. If you just need to add the lib/ directory relative\n> > to the script you're invoking you can use FindBin:\n> > \n> >     use FindBin qw($Bin);\n> >     use lib \"$Bin/lib\";\n> \n> It's\n> \n>       use lib \"$Bin/../lib\";\n> \n> (I don't like this ../lib here, but that's my personal preference).\n> \n> But you might be right that I am overly cautious in avoiding FindBin.\n> It is nowadays not recommended solution (on #perl, for example), but\n> it is perhaps true that the conditions where it fails are not fulfilled\n> for the case of gitweb.\n> \n> Or perhaps not:\n> \n>   KNOWN ISSUES\n> \n>   If there are two modules using FindBin from different directories\n>   under the same interpreter, this won't work. Since FindBin uses a\n>   BEGIN block, it'll be executed only once, and only the first caller\n>   will get it right. This is a problem under **mod_perl** and other\n>   persistent Perl environments, where you shouldn't use this module.\n> \n> Gitweb can be used under mod_perl (to be more exact ModPerl::Registry).\n\nAnd there is also nowadays 'plackup' option for git-instaweb, which\nalso would have, I think, this problem with FindBin.\n\n-- \nJakub Narebski\nPoland\n"},{"id":"145095","messageId":"201007080920.38724.jnareb@gmail.com","threadId":"24317","inReplyTo":"201007080859.33958.jnareb@gmail.com","subject":"[PATCHv3/RFC] gitweb: Prepare for splitting gitweb","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2010-07-08T07:20:33Z","receivedAt":"2010-07-08T07:20:33Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Prepare gitweb for having been split into modules that are to be\ninstalled alongside gitweb in 'lib/' subdirectory, by adding\n\n  use lib __DIR__.'/lib';\n\nto gitweb.perl (to main gitweb script), and preparing for putting\nmodules (relative path) in $(GITWEB_MODULES) in gitweb/Makefile.\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\nDifferences from v2:\n* Fixed issue with quoting value of shell variable, pointed by Junio\n* Removed spurious unrelated addition of an empty line, pointed by  \n  Ævar\n\n gitweb/Makefile    |   14 +++++++++++++-\n gitweb/gitweb.perl |    8 ++++++++\n 2 files changed, 21 insertions(+), 1 deletions(-)\n\ndiff --git a/gitweb/Makefile b/gitweb/Makefile\nindex 2fb7c2d..b39d716 100644\n--- a/gitweb/Makefile\n+++ b/gitweb/Makefile\n@@ -55,6 +55,7 @@ PERL_PATH  ?= /usr/bin/perl\n bindir_SQ = $(subst ','\\'',$(bindir))#'\n gitwebdir_SQ = $(subst ','\\'',$(gitwebdir))#'\n gitwebstaticdir_SQ = $(subst ','\\'',$(gitwebdir)/static)#'\n+gitweblibdir_SQ = $(subst ','\\'',$(gitwebdir)/lib)#'\n SHELL_PATH_SQ = $(subst ','\\'',$(SHELL_PATH))#'\n PERL_PATH_SQ  = $(subst ','\\'',$(PERL_PATH))#'\n DESTDIR_SQ    = $(subst ','\\'',$(DESTDIR))#'\n@@ -145,12 +146,23 @@ gitweb.cgi: gitweb.perl GITWEB-BUILD-OPTIONS\n \n ### Installation rules\n \n-install: all\n+install: all install-modules\n \t$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebdir_SQ)'\n \t$(INSTALL) -m 755 $(GITWEB_PROGRAMS) '$(DESTDIR_SQ)$(gitwebdir_SQ)'\n \t$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)'\n \t$(INSTALL) -m 644 $(GITWEB_FILES) '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)'\n \n+install-modules:\n+\tinstall_dirs=\"$(sort $(dir $(GITWEB_MODULES)))\" && \\\n+\tfor dir in $$install_dirs; do \\\n+\t\ttest -d '$(DESTDIR_SQ)$(gitwebdir_SQ)/$$dir' || \\\n+\t\t$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebdir_SQ)/$$dir'; \\\n+\tdone\n+\tgitweb_modules=\"$(GITWEB_MODULES)\" && \\\n+\tfor mod in $$gitweb_modules; do \\\n+\t\t$(INSTALL) -m 644 $$mod '$(DESTDIR_SQ)$(gitwebdir_SQ)/$$(dirname $$mod)'; \\\n+\tdone\n+\n ### Cleaning rules\n \n clean:\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 1f611d2..ec60a4d 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -9,6 +9,14 @@\n \n use strict;\n use warnings;\n+\n+use File::Spec;\n+# __DIR__ is taken from Dir::Self __DIR__ fragment\n+sub __DIR__ () {\n+\tFile::Spec->rel2abs(join '', (File::Spec->splitpath(__FILE__))[0, 1]);\n+}\n+use lib __DIR__ . '/lib';\n+\n use CGI qw(:standard :escapeHTML -nosticky);\n use CGI::Util qw(unescape);\n use CGI::Carp qw(fatalsToBrowser set_message);\n-- \n1.7.0.1\n"},{"id":"145481","messageId":"201007140024.58446.jnareb@gmail.com","threadId":"24317","inReplyTo":"201007072205.14345.jnareb@gmail.com","subject":"Re: [PATCHv2/RFC] gitweb: Prepare for splitting gitweb","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2010-07-13T22:24:57Z","receivedAt":"2010-07-13T22:24:57Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Wed, 7 Jul 2010, Jakub Narebski wrote:\n> On Wed, 7 Jul 2010, Ævar Arnfjörð Bjarmason napisał:\n> > On Wed, Jul 7, 2010 at 09:57, Jakub Narebski <jnareb@gmail.com> wrote:\n> > > [...]\n> > >  use strict;\n> > >  use warnings;\n> > > +\n> > > +use File::Spec;\n> > > +# __DIR__ is taken from Dir::Self __DIR__ fragment\n> > > +sub __DIR__ () {\n> > > +       File::Spec->rel2abs(join '', (File::Spec->splitpath(__FILE__))[0, 1]);\n> > > +}\n> > > +use lib __DIR__ . '/lib';\n> > > +\n> > \n> > What was the result of the discussion about using __DIR__ again? You\n> > only need to use that method when you call a perl program whith *then*\n> > includes a module. If you just need to add the lib/ directory relative\n> > to the script you're invoking you can use FindBin:\n> > \n> >     use FindBin qw($Bin);\n> >     use lib \"$Bin/lib\";\n> \n> It's\n> \n>       use lib \"$Bin/../lib\";\n> \n> (I don't like this ../lib here, but that's my personal preference).\n\nActually for gitweb, where gitweb.cgi is put in \"top\" directory, and\nlib/ directory is in the same directory that the script is, it would\nbe\n\n        use FindBin qw($Bin);\n        use lib \"$Bin/lib\";\n\nThe documentation says that $FindBin::Bin is\n\n        $Bin    - path to bin directory from where script was invoked\n\nso it is path to directory, not to script itself.\n\nIf it worked...\n\n> But you might be right that I am overly cautious in avoiding FindBin.\n> It is nowadays not recommended solution (on #perl, for example), but\n> it is perhaps true that the conditions where it fails are not fulfilled\n> for the case of gitweb.\n> \n> Or perhaps not:\n> \n>   KNOWN ISSUES\n> \n>   If there are two modules using FindBin from different directories\n>   under the same interpreter, this won't work. Since FindBin uses a\n>   BEGIN block, it'll be executed only once, and only the first caller\n>   will get it right. This is a problem under **mod_perl** and other\n>   persistent Perl environments, where you shouldn't use this module.\n> \n> Gitweb can be used under mod_perl (to be more exact ModPerl::Registry).\n\nI wrote simple script that tests result of __DIR__ and $FindBin::Bin.\nFor cgi-bin / mod_cgi it was:\n\n  __DIR__       = /var/www/cgi-bin/gitweb (symlink to /home/local/gitweb)\n  $FindBin::Bin = /home/local/gitweb\n\nFor mod_perl (ModPerl::Registry handler) it was\n\n  __DIR__       = /var/www/perl/gitweb (symlink to /home/local/gitweb)\n  $FindBin::Bin = /\n\nAs you can see it's useless.  I have't checked the FastCGI case...\n\n-- \nJakub Narebski\nPoland\n"},{"id":"145482","messageId":"AANLkTikyxqPHkNnVaN6kLNdbjxl69e_8Yuf1-n7CwnEg@mail.gmail.com","threadId":"24317","inReplyTo":"201007140024.58446.jnareb@gmail.com","subject":"Re: [PATCHv2/RFC] gitweb: Prepare for splitting gitweb","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2010-07-13T22:30:42Z","receivedAt":"2010-07-13T22:30:42Z","isPatch":false,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Tue, Jul 13, 2010 at 22:24, Jakub Narebski <jnareb@gmail.com> wrote:\n\n> I wrote simple script that tests result of __DIR__ and $FindBin::Bin.\n> For cgi-bin / mod_cgi it was:\n>\n>  __DIR__       = /var/www/cgi-bin/gitweb (symlink to /home/local/gitweb)\n>  $FindBin::Bin = /home/local/gitweb\n>\n> For mod_perl (ModPerl::Registry handler) it was\n>\n>  __DIR__       = /var/www/perl/gitweb (symlink to /home/local/gitweb)\n>  $FindBin::Bin = /\n>\n> As you can see it's useless.  I have't checked the FastCGI case...\n\nThanks for spending time researching what was an offhand ignorant \"hey\nwasn't ..\" comment. Also, sorry :)\n\nBut that's very informative. Good to know that FindBin is broken like\nthat under mod_perl.\n"},{"id":"145523","messageId":"201007141125.01863.jnareb@gmail.com","threadId":"24317","inReplyTo":"AANLkTikyxqPHkNnVaN6kLNdbjxl69e_8Yuf1-n7CwnEg@mail.gmail.com","subject":"Re: [PATCHv2/RFC] gitweb: Prepare for splitting gitweb","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2010-07-14T09:24:58Z","receivedAt":"2010-07-14T09:24:58Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Wed, 14 Jul 2010, Ævar Arnfjörð Bjarmason wrote:\n> On Tue, Jul 13, 2010 at 22:24, Jakub Narebski <jnareb@gmail.com> wrote:\n> \n> > I wrote simple script that tests result of __DIR__ and $FindBin::Bin.\n> > For cgi-bin / mod_cgi it was:\n> >\n> >  __DIR__       = /var/www/cgi-bin/gitweb (symlink to /home/local/gitweb)\n> >  $FindBin::Bin = /home/local/gitweb\n> >\n> > For mod_perl (ModPerl::Registry handler) it was\n> >\n> >  __DIR__       = /var/www/perl/gitweb (symlink to /home/local/gitweb)\n> >  $FindBin::Bin = /\n> >\n> > As you can see it's useless.  I have't checked the FastCGI case...\n> \n> Thanks for spending time researching what was an offhand ignorant \"hey\n> wasn't ..\" comment. Also, sorry :)\n\nNothing to it.  I wanted to check if there really is a problem with \nFindBin on mod_perl, as I was not sure with description in \"Known Issues\"\nsection in FindBin manpage.\n\nNote that using 'FindBin->again();' after 'use FindBin;' fixes this\nissue.  So perhaps it would be beter to use FindBin than borrow code\nfor __DIR__ from Dir::Self.\n\n> But that's very informative. Good to know that FindBin is broken like\n> that under mod_perl.\n\nIt might be only under ModPerl::Registry, but it might be not.\n\n-- \nJakub Narebski\nPoland\n"},{"id":"145524","messageId":"AANLkTikDtlHwtk4j0E5vYViFVWtsV_yA5e90z-6nZb8_@mail.gmail.com","threadId":"24317","inReplyTo":"201007141125.01863.jnareb@gmail.com","subject":"Re: [PATCHv2/RFC] gitweb: Prepare for splitting gitweb","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2010-07-14T10:05:56Z","receivedAt":"2010-07-14T10:05:56Z","isPatch":false,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Wed, Jul 14, 2010 at 09:24, Jakub Narebski <jnareb@gmail.com> wrote:\n> On Wed, 14 Jul 2010, Ævar Arnfjörð Bjarmason wrote:\n>> On Tue, Jul 13, 2010 at 22:24, Jakub Narebski <jnareb@gmail.com> wrote:\n>>\n>> > I wrote simple script that tests result of __DIR__ and $FindBin::Bin.\n>> > For cgi-bin / mod_cgi it was:\n>> >\n>> >  __DIR__       = /var/www/cgi-bin/gitweb (symlink to /home/local/gitweb)\n>> >  $FindBin::Bin = /home/local/gitweb\n>> >\n>> > For mod_perl (ModPerl::Registry handler) it was\n>> >\n>> >  __DIR__       = /var/www/perl/gitweb (symlink to /home/local/gitweb)\n>> >  $FindBin::Bin = /\n>> >\n>> > As you can see it's useless.  I have't checked the FastCGI case...\n>>\n>> Thanks for spending time researching what was an offhand ignorant \"hey\n>> wasn't ..\" comment. Also, sorry :)\n>\n> Nothing to it.  I wanted to check if there really is a problem with\n> FindBin on mod_perl, as I was not sure with description in \"Known Issues\"\n> section in FindBin manpage.\n>\n> Note that using 'FindBin->again();' after 'use FindBin;' fixes this\n> issue.  So perhaps it would be beter to use FindBin than borrow code\n> for __DIR__ from Dir::Self.\n\nThat should work, though note that FindBin->again requires at least\nperl 5.8.3. This should work on older versions (if Gitweb cares):\n\n    if ($] <= 5.008003) {\n        delete $INC{'FindBin.pm'};\n        require FindBin;\n    } else {\n        FindBin->again;\n    }\n\nSee https://rt.cpan.org/Public/Bug/Display.html?id=57988 and\nhttp://search.cpan.org/diff?from=Module-Install-0.98&to=Module-Install-0.99\nfor reference.\n"},{"id":"145584","messageId":"201007142321.26034.jnareb@gmail.com","threadId":"24317","inReplyTo":"AANLkTikDtlHwtk4j0E5vYViFVWtsV_yA5e90z-6nZb8_@mail.gmail.com","subject":"Re: [PATCHv2/RFC] gitweb: Prepare for splitting gitweb","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2010-07-14T21:21:24Z","receivedAt":"2010-07-14T21:21:24Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Wed, 14 Jul 2010, Ævar Arnfjörð Bjarmason wrote:\n> On Wed, Jul 14, 2010 at 09:24, Jakub Narebski <jnareb@gmail.com> wrote:\n>> On Wed, 14 Jul 2010, Ævar Arnfjörð Bjarmason wrote:\n>>> On Tue, Jul 13, 2010 at 22:24, Jakub Narebski <jnareb@gmail.com> wrote:\n>>>\n>>>> I wrote simple script that tests result of __DIR__ and $FindBin::Bin.\n>>>> For cgi-bin / mod_cgi it was:\n>>>>\n>>>>  __DIR__       = /var/www/cgi-bin/gitweb (symlink to /home/local/gitweb)\n>>>>  $FindBin::Bin = /home/local/gitweb\n>>>>\n>>>> For mod_perl (ModPerl::Registry handler) it was\n>>>>\n>>>>  __DIR__       = /var/www/perl/gitweb (symlink to /home/local/gitweb)\n>>>>  $FindBin::Bin = /\n>>>>\n>>>> As you can see it's useless.  I have't checked the FastCGI case...\n>>>\n>>> Thanks for spending time researching what was an offhand ignorant \"hey\n>>> wasn't ..\" comment. Also, sorry :)\n>>\n>> Nothing to it.  I wanted to check if there really is a problem with\n>> FindBin on mod_perl, as I was not sure with description in \"Known Issues\"\n>> section in FindBin manpage.\n>>\n>> Note that using 'FindBin->again();' after 'use FindBin;' fixes this\n>> issue.  So perhaps it would be beter to use FindBin than borrow code\n>> for __DIR__ from Dir::Self.\n> \n> That should work, though note that FindBin->again requires at least\n> perl 5.8.3. This should work on older versions (if Gitweb cares):\n> \n>     if ($] <= 5.008003) {\n>         delete $INC{'FindBin.pm'};\n>         require FindBin;\n>     } else {\n>         FindBin->again;\n>     }\n> \n> See https://rt.cpan.org/Public/Bug/Display.html?id=57988 and\n> http://search.cpan.org/diff?from=Module-Install-0.98&to=Module-Install-0.99\n> for reference.\n\nThanks for research.\n\nI don't think gitweb cares, as it requires Perl with sane Unicode support,\nwhich means at least Perl 5.8.0 (for Encode module), but I think it really\nmeans at least 5.8.3\n\n-- \nJakub Narebski\nPoland\n"}]}