Skip to contentSkip to conversation

gitweb: Begin splitting gitweb

PATCH Superseded Jakub Narebski 2 participants 7 messages Jun 15, 2016

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover gitweb: Begin splitting gitweb

Gitweb is currently next to largest file (after gitk) in git sources, more than 220K with more than 25,000 lines. Therefore adding any large feature that would require large amount of code added, like gitweb caching by J.H. and my rewrite of it, or "gitweb admin/write" [failed] GSoC 2010 project by Pavan Kumar Sunkara require for new code to be added as a separate module or module. Otherwise gitweb would fast become unmaintainable.

Not in all cases it would require splitting gitweb upfront. At least in the case of gitweb caching it doesn't. What must be done however is preparing the infrastructure for modular gitweb sources; to properly test such infrastructure we need at least one split gitweb module.

This series is intended to bring such infrastructure to gitweb, to prepare way for adding output caching to gitweb. Alternatively it can be thought as beginning of splitting gitweb into smaller submodules, for better maintability.

Table of contents:
~~~~~~~~~~~~~~~~~~
* [PATCH (version A) 1/2] gitweb: Prepare for splitting gitweb

    sub __DIR__ () {
    	File::Spec->rel2abs(join '', (File::Spec->splitpath(__FILE__))[0, 1]);
    }
    use lib __DIR__ . '/lib';

Advantages:
- no changes to t/gitweb-lib.sh, ability to run source version of gitweb without any changes

Disadvantages:
- supports only modules installed either alongside gitweb, or in one of PERL5LIB directories; no support for installing modules not alongside gitweb
- because we cannot rely on FindBin::again being available nor on having Dir::Self installed, __DIR__ must be defined -- more code.

* [PATCH (version B) 1/2] gitweb: Prepare for splitting gitweb

    use lib $ENV{'GITWEBLIBDIR'} || "++GITWEBLIBDIR++";

Advantages:
- supports relocating gitweb modules (to gitweblibdir)
- shortest code of all the cases

Disadvantages:
- required changes to t/gitweb-lib.sh to pick up gitweb modules by source version of gitweb

* [PATCH (version C) 1/2] gitweb: Prepare for splitting gitweb

    sub __DIR__ () {
    	File::Spec->rel2abs(join '', (File::Spec->splitpath(__FILE__))[0, 1]);
    }
    use lib __DIR__ . '/lib';
    use lib "++GITWEBLIBDIR++";

Advantages:
- can run source version of gitweb (gitweb/gitweb.perl) as a script simply
- supports relocating gitweb modules (to gitweblibdir)

Disadvantages:
- most complicated code of all cases

* [PATCH (proof of concept) 2/2] gitweb: Create Gitweb::Util module

Something to actually test previous patch(es) with... and I guess good start to splitting gitweb into smaller modules.

All versions pass "make -C gitweb test" and "make -C gitweb test-installed" after "make -C gitweb install" / "make install-gitweb".

Shortlog:
~~~~~~~~~
Jakub Narebski (1):
gitweb: Prepare for splitting gitweb

Pavan Kumar Sunkara (1):
gitweb: Create Gitweb::Util module

Diffstat (for version C):
~~~~~~~~~~~~~~~~~~~~~~~~~

 gitweb/Makefile           |   22 +++++-
 gitweb/gitweb.perl        |  150 ++++-----------------------------------
 gitweb/lib/Gitweb/Util.pm |  177 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 210 insertions(+), 139 deletions(-)
 create mode 100644 gitweb/lib/Gitweb/Util.pm
Signature · 1 line
1.7.3
#1 lore raw

PATCH 1/2 gitweb: Prepare for splitting gitweb

Prepare gitweb for having been split into modules that are to be installed alongside gitweb in 'lib/' subdirectory, by adding

use lib __DIR__.'/lib';

to gitweb.perl (to main gitweb script), and preparing for putting modules (relative path) in $(GITWEB_MODULES) in gitweb/Makefile.

This preparatory work allows to add new module to gitweb by simply adding

GITWEB_MODULES += <module>

to gitweb/Makefile (assuming that the module is in 'gitweb/lib/' directory).

While at it pass GITWEBLIBDIR in addition to GITWEB_TEST_INSTALLED to allow testing installed version of gitweb and installed version of modules (for future tests which would check individual (sub)modules).

Using __DIR__ from Dir::Self module (not in core, that's why currently gitweb includes excerpt of code from Dir::Self defining __DIR__) was chosen over using FindBin-based solution (in core since perl 5.00307, while gitweb itself requires at least perl 5.8.0) because FindBin uses BEGIN block, which is a problem under mod_perl and other persistent Perl environments (thought there are workarounds).

At Pavan Kumar Sankara suggestion gitweb/Makefile uses

install [OPTION]... SOURCE... DIRECTORY

format (2nd format) with single SOURCE rather than

install [OPTION]... SOURCE DEST

format (1st format) because of security reasons (race conditions). Modern GNU install has -T' / --no-target-directory' option, but we cannot rely that the $(INSTALL) we are using supports this option.

The install-modules target in gitweb/Makefile uses shell 'for' loop, instead of make's $(foreach) function, to avoid possible problem with generating a command line that exceeded the maximum argument list length.

---
 gitweb/Makefile    |   17 +++++++++++++++--
 gitweb/gitweb.perl |    8 ++++++++
 2 files changed, 23 insertions(+), 2 deletions(-)
gitweb/Makefile +15 -2
index 0a6ac00..e6029e1 100644
@@ -57,6 +57,7 @@ PERL_PATH  ?= /usr/bin/perl
 bindir_SQ = $(subst ','\'',$(bindir))#'
 gitwebdir_SQ = $(subst ','\'',$(gitwebdir))#'
 gitwebstaticdir_SQ = $(subst ','\'',$(gitwebdir)/static)#'
+gitweblibdir_SQ = $(subst ','\'',$(gitwebdir)/lib)#'
 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))#'
 PERL_PATH_SQ  = $(subst ','\'',$(PERL_PATH))#'
 DESTDIR_SQ    = $(subst ','\'',$(DESTDIR))#'
@@ -153,20 +154,32 @@ test:
 
 test-installed:
 	GITWEB_TEST_INSTALLED='$(DESTDIR_SQ)$(gitwebdir_SQ)' \
+	GITWEBLIBDIR='$(DESTDIR_SQ)$(gitweblibdir_SQ)' \
 		$(MAKE) -C ../t gitweb-test
 
 ### Installation rules
 
-install: all
+install: all install-modules
 	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebdir_SQ)'
 	$(INSTALL) -m 755 $(GITWEB_PROGRAMS) '$(DESTDIR_SQ)$(gitwebdir_SQ)'
 	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)'
 	$(INSTALL) -m 644 $(GITWEB_FILES) '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)'
 
+install-modules:
+	install_dirs="$(sort $(dir $(GITWEB_MODULES)))" && \
+	for dir in $$install_dirs; do \
+		test -d '$(DESTDIR_SQ)$(gitweblibdir_SQ)'/"$$dir" || \
+		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitweblibdir_SQ)'/"$$dir"; \
+	done
+	gitweb_modules="$(GITWEB_MODULES)" && \
+	for mod in $$gitweb_modules; do \
+		$(INSTALL) -m 644 "lib/$$mod" '$(DESTDIR_SQ)$(gitweblibdir_SQ)'/"$$(dirname $$mod)"; \
+	done
+
 ### Cleaning rules
 
 clean:
 	$(RM) gitweb.cgi static/gitweb.min.js static/gitweb.min.css GITWEB-BUILD-OPTIONS
 
-.PHONY: all clean install test test-installed .FORCE-GIT-VERSION-FILE FORCE
+.PHONY: all clean install install-modules test test-installed .FORCE-GIT-VERSION-FILE FORCE
 
gitweb/gitweb.perl +8 -0
index 1025c2f..1ccea49 100755
@@ -10,6 +10,14 @@
 use 5.008;
 use strict;
 use warnings;
+
+use File::Spec;
+# __DIR__ is taken from Dir::Self __DIR__ fragment
+sub __DIR__ () {
+	File::Spec->rel2abs(join '', (File::Spec->splitpath(__FILE__))[0, 1]);
+}
+use lib __DIR__ . '/lib';
+
 use CGI qw(:standard :escapeHTML -nosticky);
 use CGI::Util qw(unescape);
 use CGI::Carp qw(fatalsToBrowser set_message);
Signature · 1 line
1.6.5.GIT
#2 lore raw

PATCH 1/2 gitweb: Prepare for splitting gitweb

In reply to Jakub Narebski

Prepare gitweb for being split into modules that would be installed in gitweblibdir, by default alongside gitweb in 'lib/' subdirectory, by adding

  use lib $ENV{'GITWEBLIBDIR'} || "++GITWEBLIBDIR++";

to gitweb.perl (to main gitweb script). The first part allow to run gitweb scripts using source version of gitweb (after small change to t/gitweb-lib.sh). The second part is set to appropriate value during build (generating gitweb.cgi). This allows to select where to install gitweb modules via 'gitweblibdir' build time configuration variable, e.g.

  $ make gitwebdir=/var/www/cgi-bin gitweblibdir=/usr/lib/perl5
    install-gitweb

This preparatory work allows to add new module to gitweb by simply adding

GITWEB_MODULES += <module>

to gitweb/Makefile (assuming that the module is in 'gitweb/lib/' directory).

While at it pass GITWEBLIBDIR in addition to GITWEB_TEST_INSTALLED to allow testing installed version of gitweb and installed version of modules (for future tests which would check individual (sub)modules).

At Pavan Kumar Sankara suggestion gitweb/Makefile uses

install [OPTION]... SOURCE... DIRECTORY

format (2nd format) with single SOURCE rather than

install [OPTION]... SOURCE DEST

format (1st format) because of security reasons (race conditions). Modern GNU install has -T' / --no-target-directory' option, but we cannot rely that the $(INSTALL) we are using supports this option.

The install-modules target in gitweb/Makefile uses shell 'for' loop, instead of make's $(foreach) function, to avoid possible problem with generating a command line that exceeded the maximum argument list length.

---
 gitweb/Makefile    |   19 +++++++++++++++++--
 gitweb/gitweb.perl |    4 ++++
 t/gitweb-lib.sh    |    2 ++
 3 files changed, 23 insertions(+), 2 deletions(-)
gitweb/Makefile +17 -2
index 0a6ac00..abe9db8 100644
@@ -13,6 +13,7 @@ all::
 prefix ?= $(HOME)
 bindir ?= $(prefix)/bin
 gitwebdir ?= /var/www/cgi-bin
+gitweblibdir ?= $(gitwebdir)/lib
 
 RM ?= rm -f
 INSTALL ?= install
@@ -57,6 +58,7 @@ PERL_PATH  ?= /usr/bin/perl
 bindir_SQ = $(subst ','\'',$(bindir))#'
 gitwebdir_SQ = $(subst ','\'',$(gitwebdir))#'
 gitwebstaticdir_SQ = $(subst ','\'',$(gitwebdir)/static)#'
+gitweblibdir_SQ = $(subst ','\'',$(gitweblibdir))#'
 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))#'
 PERL_PATH_SQ  = $(subst ','\'',$(PERL_PATH))#'
 DESTDIR_SQ    = $(subst ','\'',$(DESTDIR))#'
@@ -115,6 +117,7 @@ GITWEB_FILES += static/git-logo.png static/git-favicon.png
 GITWEB_REPLACE = \
 	-e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \
 	-e 's|++GIT_BINDIR++|$(bindir)|g' \
+	-e 's|++GITWEBLIBDIR++|$(gitweblibdir)|g' \
 	-e 's|++GITWEB_CONFIG++|$(GITWEB_CONFIG)|g' \
 	-e 's|++GITWEB_CONFIG_SYSTEM++|$(GITWEB_CONFIG_SYSTEM)|g' \
 	-e 's|++GITWEB_HOME_LINK_STR++|$(GITWEB_HOME_LINK_STR)|g' \
@@ -153,20 +156,32 @@ test:
 
 test-installed:
 	GITWEB_TEST_INSTALLED='$(DESTDIR_SQ)$(gitwebdir_SQ)' \
+	GITWEBLIBDIR='$(DESTDIR_SQ)$(gitweblibdir_SQ)' \
 		$(MAKE) -C ../t gitweb-test
 
 ### Installation rules
 
-install: all
+install: all install-modules
 	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebdir_SQ)'
 	$(INSTALL) -m 755 $(GITWEB_PROGRAMS) '$(DESTDIR_SQ)$(gitwebdir_SQ)'
 	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)'
 	$(INSTALL) -m 644 $(GITWEB_FILES) '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)'
 
+install-modules:
+	install_dirs="$(sort $(dir $(GITWEB_MODULES)))" && \
+	for dir in $$install_dirs; do \
+		test -d '$(DESTDIR_SQ)$(gitweblibdir_SQ)'/"$$dir" || \
+		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitweblibdir_SQ)'/"$$dir"; \
+	done
+	gitweb_modules="$(GITWEB_MODULES)" && \
+	for mod in $$gitweb_modules; do \
+		$(INSTALL) -m 644 "lib/$$mod" '$(DESTDIR_SQ)$(gitweblibdir_SQ)'/"$$(dirname $$mod)"; \
+	done
+
 ### Cleaning rules
 
 clean:
 	$(RM) gitweb.cgi static/gitweb.min.js static/gitweb.min.css GITWEB-BUILD-OPTIONS
 
-.PHONY: all clean install test test-installed .FORCE-GIT-VERSION-FILE FORCE
+.PHONY: all clean install install-modules test test-installed .FORCE-GIT-VERSION-FILE FORCE
 
gitweb/gitweb.perl +4 -0
index 1025c2f..bed1eec 100755
@@ -10,6 +10,10 @@
 use 5.008;
 use strict;
 use warnings;
+
+use lib $ENV{'GITWEBLIBDIR'} || "++GITWEBLIBDIR++";
+
+use File::Spec;
 use CGI qw(:standard :escapeHTML -nosticky);
 use CGI::Util qw(unescape);
 use CGI::Carp qw(fatalsToBrowser set_message);
t/gitweb-lib.sh +2 -0
index b9bb95f..8b98047 100644
@@ -48,6 +48,8 @@ EOF
 		say "# Testing $SCRIPT_NAME"
 	else # normal case, use source version of gitweb
 		SCRIPT_NAME="$GIT_BUILD_DIR/gitweb/gitweb.perl"
+		GITWEBLIBDIR="$GIT_BUILD_DIR/gitweb/lib"
+		export GITWEBLIBDIR
 	fi
 	export SCRIPT_NAME
 }
Signature · 1 line
1.6.5.GIT
#3 lore raw

PATCH 1/2 gitweb: Prepare for splitting gitweb

In reply to Jakub Narebski

Prepare gitweb for being split into modules that would be installed in gitweblibdir, by default alongside gitweb in 'lib/' subdirectory.

Gitweb would search first in 'lib/' subdirectory from where it is installed, via

use lib __DIR__.'/lib';

(This allow for tests to work with source version of gitweb without changes.) Then it searches in $(gitweblibdir) directory (set during build time), by default "$(gitwebdir)/lib", via

use lib "++GITWEBLIBDIR++";

"++GITWEBLIBDIR++" is set to appropriate value during build time (generating gitweb.cgi). This allows to select where to install gitweb modules via 'gitweblibdir' build time configuration variable, for example

  $ make gitwebdir=/var/www/cgi-bin gitweblibdir=/usr/lib/perl5
    install-gitweb

This preparatory work allows to add new module to gitweb by simply adding

GITWEB_MODULES += <module>

to gitweb/Makefile (assuming that the module is in 'gitweb/lib/' directory).

While at it pass GITWEBLIBDIR in addition to GITWEB_TEST_INSTALLED to allow testing installed version of gitweb and installed version of modules (for future tests which would check individual (sub)modules).

Using __DIR__ from Dir::Self module (not in core, that's why currently gitweb includes excerpt of code from Dir::Self defining __DIR__) was chosen over using FindBin-based solution (in core since perl 5.00307, while gitweb itself requires at least perl 5.8.0) because FindBin uses BEGIN block, which is a problem under mod_perl and other persistent Perl environments (thought there are workarounds).

At Pavan Kumar Sankara suggestion gitweb/Makefile uses

install [OPTION]... SOURCE... DIRECTORY

format (2nd format) with single SOURCE rather than

install [OPTION]... SOURCE DEST

format (1st format) because of security reasons (race conditions). Modern GNU install has -T' / --no-target-directory' option, but we cannot rely that the $(INSTALL) we are using supports this option.

The install-modules target in gitweb/Makefile uses shell 'for' loop, instead of make's $(foreach) function, to avoid possible problem with generating a command line that exceeded the maximum argument list length.

---
 gitweb/Makefile    |   19 +++++++++++++++++--
 gitweb/gitweb.perl |   10 ++++++++++
 2 files changed, 27 insertions(+), 2 deletions(-)
gitweb/Makefile +17 -2
index 0a6ac00..abe9db8 100644
@@ -13,6 +13,7 @@ all::
 prefix ?= $(HOME)
 bindir ?= $(prefix)/bin
 gitwebdir ?= /var/www/cgi-bin
+gitweblibdir ?= $(gitwebdir)/lib
 
 RM ?= rm -f
 INSTALL ?= install
@@ -57,6 +58,7 @@ PERL_PATH  ?= /usr/bin/perl
 bindir_SQ = $(subst ','\'',$(bindir))#'
 gitwebdir_SQ = $(subst ','\'',$(gitwebdir))#'
 gitwebstaticdir_SQ = $(subst ','\'',$(gitwebdir)/static)#'
+gitweblibdir_SQ = $(subst ','\'',$(gitweblibdir))#'
 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))#'
 PERL_PATH_SQ  = $(subst ','\'',$(PERL_PATH))#'
 DESTDIR_SQ    = $(subst ','\'',$(DESTDIR))#'
@@ -115,6 +117,7 @@ GITWEB_FILES += static/git-logo.png static/git-favicon.png
 GITWEB_REPLACE = \
 	-e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \
 	-e 's|++GIT_BINDIR++|$(bindir)|g' \
+	-e 's|++GITWEBLIBDIR++|$(gitweblibdir)|g' \
 	-e 's|++GITWEB_CONFIG++|$(GITWEB_CONFIG)|g' \
 	-e 's|++GITWEB_CONFIG_SYSTEM++|$(GITWEB_CONFIG_SYSTEM)|g' \
 	-e 's|++GITWEB_HOME_LINK_STR++|$(GITWEB_HOME_LINK_STR)|g' \
@@ -153,20 +156,32 @@ test:
 
 test-installed:
 	GITWEB_TEST_INSTALLED='$(DESTDIR_SQ)$(gitwebdir_SQ)' \
+	GITWEBLIBDIR='$(DESTDIR_SQ)$(gitweblibdir_SQ)' \
 		$(MAKE) -C ../t gitweb-test
 
 ### Installation rules
 
-install: all
+install: all install-modules
 	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebdir_SQ)'
 	$(INSTALL) -m 755 $(GITWEB_PROGRAMS) '$(DESTDIR_SQ)$(gitwebdir_SQ)'
 	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)'
 	$(INSTALL) -m 644 $(GITWEB_FILES) '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)'
 
+install-modules:
+	install_dirs="$(sort $(dir $(GITWEB_MODULES)))" && \
+	for dir in $$install_dirs; do \
+		test -d '$(DESTDIR_SQ)$(gitweblibdir_SQ)'/"$$dir" || \
+		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitweblibdir_SQ)'/"$$dir"; \
+	done
+	gitweb_modules="$(GITWEB_MODULES)" && \
+	for mod in $$gitweb_modules; do \
+		$(INSTALL) -m 644 "lib/$$mod" '$(DESTDIR_SQ)$(gitweblibdir_SQ)'/"$$(dirname $$mod)"; \
+	done
+
 ### Cleaning rules
 
 clean:
 	$(RM) gitweb.cgi static/gitweb.min.js static/gitweb.min.css GITWEB-BUILD-OPTIONS
 
-.PHONY: all clean install test test-installed .FORCE-GIT-VERSION-FILE FORCE
+.PHONY: all clean install install-modules test test-installed .FORCE-GIT-VERSION-FILE FORCE
 
gitweb/gitweb.perl +10 -0
index 1025c2f..ea8ab56 100755
@@ -10,6 +10,16 @@
 use 5.008;
 use strict;
 use warnings;
+
+use File::Spec;
+
+# __DIR__ is excerpt from Dir::Self
+sub __DIR__ () {
+	File::Spec->rel2abs(join '', (File::Spec->splitpath(__FILE__))[0, 1]);
+}
+use lib __DIR__ . '/lib';
+use lib "++GITWEBLIBDIR++";
+
 use CGI qw(:standard :escapeHTML -nosticky);
 use CGI::Util qw(unescape);
 use CGI::Carp qw(fatalsToBrowser set_message);
Signature · 1 line
1.7.3
#4 lore raw

Re: [PATCH (version C) 1/2] gitweb: Prepare for splitting gitweb

Quoted 12 lines · Jakub Narebski

Prepare gitweb for being split into modules that would be installed in gitweblibdir, by default alongside gitweb in 'lib/' subdirectory.

Gitweb would search first in 'lib/' subdirectory from where it is installed, via

use lib __DIR__.'/lib';

(This allow for tests to work with source version of gitweb without changes.) Then it searches in $(gitweblibdir) directory (set during build time), by default "$(gitwebdir)/lib", via

Quoted 5 lines

use lib "++GITWEBLIBDIR++";

"++GITWEBLIBDIR++" is set to appropriate value during build time (generating gitweb.cgi). This allows to select where to install gitweb modules via 'gitweblibdir' build time configuration variable

I would personally prefer to see this path taken, as it seems the most flexible and would fulfill a use case I have.

I maintain a build of git in an AFS volume at MIT. One of its uses is symlinking to the current gitweb.cgi to instantly deploy a gitweb in a shared hosting environment (example: http://git.scripts.mit.edu/).

__DIR__ would point to the directory containing a user symlink to gitweb, which would allow users to add their own libraries, while ++GITWEBLIBDIR++ would allow the standard gitweb libraries to be hosted at a common path without placing additional burdens on the user at upgrade time.

-Alejandro

#5 lore raw

Re: [PATCH (version C) 1/2] gitweb: Prepare for splitting gitweb

Quoted 27 lines · Alejandro R. Sedeño
Quoted 13 lines · Jakub Narebski

Prepare gitweb for being split into modules that would be installed in gitweblibdir, by default alongside gitweb in 'lib/' subdirectory.

Gitweb would search first in 'lib/' subdirectory from where it is installed, via

use lib __DIR__.'/lib';

(This allow for tests to work with source version of gitweb without changes.) Then it searches in $(gitweblibdir) directory (set during build time), by default "$(gitwebdir)/lib", via

Quoted 5 lines

use lib "++GITWEBLIBDIR++";

"++GITWEBLIBDIR++" is set to appropriate value during build time (generating gitweb.cgi). This allows to select where to install gitweb modules via 'gitweblibdir' build time configuration variable

I would personally prefer to see this path taken, as it seems the most flexible and would fulfill a use case I have.

I maintain a build of git in an AFS volume at MIT. One of its uses is symlinking to the current gitweb.cgi to instantly deploy a gitweb in a shared hosting environment (example: http://git.scripts.mit.edu/).

Quoted 5 lines

__DIR__ would point to the directory containing a user symlink to gitweb, which would allow users to add their own libraries, while ++GITWEBLIBDIR++ would allow the standard gitweb libraries to be hosted at a common path without placing additional burdens on the user at upgrade time.

Note however that if you want __DIR__ version to take preference over gitweblibdir version, then the 'use lib' statements have to be in reverse order, i.e.:

+use lib "++GITWEBLIBDIR++";
+use lib __DIR__ . '/lib';

Signature · 2 lines
Jakub Narebski
Poland
#6 lore raw

PATCH 2/2 gitweb: Create Gitweb::Util module

In reply to Jakub Narebski

From: Pavan Kumar Sunkara <[email protected]>

Create a Gitweb::Util module, which is meant to contain internal utilities used by gitweb. Currently it includes all the quoting/unquoting and escaping subroutines that are used by the gitweb.

Update gitweb/Makefile to install Gitweb::Util module alongside gitweb

---
This patch serves two purposes. First, it serves as test that earlier "gitweb: Prepare for splitting gitweb" patch acually work correctly.

Second, it might be good starting point to splitting gitweb. Refactoring well defined parts into separate modules (Perl packages) could be a better, easier way than trying to come with good separation (split) into modules upfront. Such leisure approach to splitting gitweb has more chance to be accepted. Perhaps if such approach were proposed on GSoC 2010, maybe "gitweb write" project wouldn't fail midterm evaluations...

This module was taken out of unfinished GSoC 2010 project with Pavan Kumar Sunkara as a student

git://repo.or.cz/git/gsoc2010-gitweb.git

The module was renamed from Gitweb::Escape to Gitweb::Util. Currently the contents is the same, but it might change.

Code was updated to more modern codebase; since then esc_path_info and esc_attr were added to gitweb - both of those are now in Gitweb::Util.

There were also required some changes and conflicts resolved due to the fact that creating Gitweb::Util (formerly Gitweb::Escape) is no longer in the middle of larger patch series. In particular lack of Gitweb::Config means that $fallback_encoding needed to be added to Gitweb::Util module.

While at it do not export quot_cec and quot_upr helper subroutines by default, but mark them exportable nevrtheless.

 gitweb/Makefile           |    3 +
 gitweb/gitweb.perl        |  140 +-----------------------------------
 gitweb/lib/Gitweb/Util.pm |  177 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 183 insertions(+), 137 deletions(-)
 create mode 100644 gitweb/lib/Gitweb/Util.pm
gitweb/Makefile +3 -0
index abe9db8..9a4053b 100644
@@ -114,6 +114,9 @@ endif
 
 GITWEB_FILES += static/git-logo.png static/git-favicon.png
 
+# Modules: Gitweb::*
+GITWEB_MODULES += Gitweb/Util.pm
+
 GITWEB_REPLACE = \
 	-e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \
 	-e 's|++GIT_BINDIR++|$(bindir)|g' \
gitweb/gitweb.perl +3 -137

162 lines not on this page · raw message

gitweb/lib/Gitweb/Util.pm new file +177 -0

177 lines not on this page · raw message

Signature · 1 line
1.7.3