Skip to contentSkip to conversation

gitweb: fill in gitweb configuration by Makefile

PATCH NAK Martin Waitz 6 participants 13 messages Jun 15, 2016 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gitweb: fill in gitweb configuration by Makefile

Generate gitweb/gitweb.cgi to reduce the need to patch gitweb.cgi by the end user.
The GIT installation directory and version are already known by the Makefile, they can be inserted directly into gitweb.
All other gitweb configuration parameters can now be specified by providing GITWEB_* variables while building GIT.
These are described in gitweb/README.

---
 Makefile                         |   25 +++++++++++++++++++++++--
 gitweb/.gitignore                |    1 +
 gitweb/README                    |   17 +++++++++++++++++
 gitweb/{gitweb.cgi => gitweb.pl} |   15 +++++++--------
 4 files changed, 48 insertions(+), 10 deletions(-)
Makefile +23 -2
index 8349e3defacca69ae48c477ff99be527b9af3b77..bd59d6b58d1cfcaecd033f186d7c2cc537416b75 100644
@@ -116,6 +116,13 @@ template_dir = $(prefix)/share/git-core/
 GIT_PYTHON_DIR = $(prefix)/share/git-core/python
 # DESTDIR=
 
+# default configuration for gitweb
+GITWEB_SITENAME = 
+GITWEB_PROJECTROOT = /pub/git
+GITWEB_LIST = 
+GITWEB_HOMETEXT = indextext.html
+GITWEB_CSS = gitweb.css
+
 export prefix bindir gitexecdir template_dir GIT_PYTHON_DIR
 
 CC = gcc
@@ -509,7 +516,7 @@ LIB_OBJS += $(COMPAT_OBJS)
 export prefix TAR INSTALL DESTDIR SHELL_PATH template_dir
 ### Build rules
 
-all: $(ALL_PROGRAMS) $(BUILT_INS) git$X gitk
+all: $(ALL_PROGRAMS) $(BUILT_INS) git$X gitk gitweb/gitweb.cgi
 
 all:
 	$(MAKE) -C templates
@@ -567,6 +574,20 @@ git-status: git-commit
 	cp $< $@+
 	mv $@+ $@
 
+gitweb/gitweb.cgi: gitweb/gitweb.pl
+	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_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' \
+	    $< >$@+
+	chmod +x $@+
+	mv $@+ $@
+
 git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css
 	rm -f $@ $@+
 	sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
@@ -577,7 +598,7 @@ git-instaweb: git-instaweb.sh gitweb/git
 	    -e '/@@GITWEB_CGI@@/d' \
 	    -e '/@@GITWEB_CSS@@/r gitweb/gitweb.css' \
 	    -e '/@@GITWEB_CSS@@/d' \
-	    [email protected] | sed "s|/usr/bin/git|$(bindir)/git|" > $@+
+	    [email protected] > $@+
 	chmod +x $@+
 	mv $@+ $@
 
gitweb/.gitignore new file +1 -0
new file mode 100644
index 0000000000000000000000000000000000000000..e83127e3f09f8496d0cd07b8f632ff341c96fd00
@@ -0,0 +1 @@
+gitweb.cgi
gitweb/README +17 -0
index 8d672762eab427f3b732626d6b3f8e05a7e8f8c9..ed939e2fb5264cce24e770272583b12372c3ab68 100644
@@ -5,5 +5,22 @@ The one working on:
 
 From the git version 1.4.0 gitweb is bundled with git.
 
+
+How to configure gitweb for your local system:
+
+You can specify the following configuration variables when building GIT:
+ * GITWEB_SITENAME
+   Shown in the title of all generated pages, defaults to the servers name.
+ * GITWEB_PROJECTROOT
+   The root directory for all projects shown by gitweb.
+ * GITWEB_LIST
+   points to a directory to scan for projects (defaults to project root)
+   or to a file for explicit listing of projects.
+ * GITWEB_HOMETEXT
+   points to an .html file which is included on the gitweb project
+   overview page.
+ * GITWEB_CSS
+   Points to the location where you put gitweb.css on your web server.
+
 Any comment/question/concern to:
   Kay Sievers <[email protected]>
gitweb/gitweb.pl renamed from gitweb/gitweb.cgi +7 -8
similarity index 100%
rename from gitweb/gitweb.cgi
rename to gitweb/gitweb.pl
index 243a2921f849568260e848201d238b3b9fe7e1f2..8e05c335f801d4c52a9b348fa56fccfae36ce621 100755
@@ -24,14 +24,14 @@ our $rss_link = "";
 
 # core git executable to use
 # this can just be "git" if your webserver has a sensible PATH
-our $GIT = "/usr/bin/git";
+our $GIT = "@@GIT_BINDIR@@/git";
 
 # absolute fs-path which will be prepended to the project path
 #our $projectroot = "/pub/scm";
-our $projectroot = "/home/kay/public_html/pub/scm";
+our $projectroot = "@@GITWEB_PROJECTROOT@@";
 
 # version of the core git binary
-our $git_version = qx($GIT --version) =~ m/git version (.*)$/ ? $1 : "unknown";
+our $git_version = "@@GIT_VERSION@@";
 
 # location for temporary files needed for diffs
 our $git_temp = "/tmp/gitweb";
@@ -44,17 +44,16 @@ 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 = $ENV{'SERVER_NAME'} || "Untitled";
+our $site_name = "@@GITWEB_SITENAME@@" || $ENV{'SERVER_NAME'} || "Untitled";
 
 # html text to include at home page
-our $home_text = "indextext.html";
+our $home_text = "@@GITWEB_HOMETEXT@@";
 
 # URI of default stylesheet
-our $stylesheet = "gitweb.css";
+our $stylesheet = "@@GITWEB_CSS@@";
 
 # source of projects list
-#our $projects_list = $projectroot;
-our $projects_list = "index/index.aux";
+our $projects_list = "@@GITWEB_LIST@@" || "$projectroot";
 
 # default blob_plain mimetype and default charset for text/plain blob
 our $default_blob_plain_mimetype = 'text/plain';
Signature · 4 lines
1.4.2.rc2.gf055

-- 
Martin Waitz
#1 lore raw
Quoted 7 lines · --- Martin Waitz

Generate gitweb/gitweb.cgi to reduce the need to patch gitweb.cgi by the end user.
The GIT installation directory and version are already known by the Makefile, they can be inserted directly into gitweb.
All other gitweb configuration parameters can now be specified by providing GITWEB_* variables while building GIT.
These are described in gitweb/README.

NACK.

I don't like it. While this method works, it is too much effort to have to run make to do this, plus it pollutes your tree.

Instead, what you can do is make gitweb.cgi read a text file from . which has those variables defined.

This way, I can just copy gitweb.cgi into my web-server directory and voila it works, since the variable definition file would always be there. This way:
- no need to run make to build "gitweb.cgi" or "gitweb.pl" whatever you call it,
- no need to pollute your tree with site defined variables,
- simple copy (cp) would install a working version, instead of the current cp + patch with local settings method.

Luben

Quoted 157 lines
---
 Makefile                         |   25 +++++++++++++++++++++++--
 gitweb/.gitignore                |    1 +
 gitweb/README                    |   17 +++++++++++++++++
 gitweb/{gitweb.cgi => gitweb.pl} |   15 +++++++--------
 4 files changed, 48 insertions(+), 10 deletions(-)
Makefile +23 -2
index 8349e3defacca69ae48c477ff99be527b9af3b77..bd59d6b58d1cfcaecd033f186d7c2cc537416b75 100644
@@ -116,6 +116,13 @@ template_dir = $(prefix)/share/git-core/
 GIT_PYTHON_DIR = $(prefix)/share/git-core/python
 # DESTDIR=
 
+# default configuration for gitweb
+GITWEB_SITENAME = 
+GITWEB_PROJECTROOT = /pub/git
+GITWEB_LIST = 
+GITWEB_HOMETEXT = indextext.html
+GITWEB_CSS = gitweb.css
+
 export prefix bindir gitexecdir template_dir GIT_PYTHON_DIR
 
 CC = gcc
@@ -509,7 +516,7 @@ LIB_OBJS += $(COMPAT_OBJS)
 export prefix TAR INSTALL DESTDIR SHELL_PATH template_dir
 ### Build rules
 
-all: $(ALL_PROGRAMS) $(BUILT_INS) git$X gitk
+all: $(ALL_PROGRAMS) $(BUILT_INS) git$X gitk gitweb/gitweb.cgi
 
 all:
 	$(MAKE) -C templates
@@ -567,6 +574,20 @@ git-status: git-commit
 	cp $< $@+
 	mv $@+ $@
 
+gitweb/gitweb.cgi: gitweb/gitweb.pl
+	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_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' \
+	    $< >$@+
+	chmod +x $@+
+	mv $@+ $@
+
 git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css
 	rm -f $@ $@+
 	sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
@@ -577,7 +598,7 @@ git-instaweb: git-instaweb.sh gitweb/git
 	    -e '/@@GITWEB_CGI@@/d' \
 	    -e '/@@GITWEB_CSS@@/r gitweb/gitweb.css' \
 	    -e '/@@GITWEB_CSS@@/d' \
-	    [email protected] | sed "s|/usr/bin/git|$(bindir)/git|" > $@+
+	    [email protected] > $@+
 	chmod +x $@+
 	mv $@+ $@
 
gitweb/.gitignore new file +1 -0
new file mode 100644
index 0000000000000000000000000000000000000000..e83127e3f09f8496d0cd07b8f632ff341c96fd00
@@ -0,0 +1 @@
+gitweb.cgi
gitweb/README +17 -0
index 8d672762eab427f3b732626d6b3f8e05a7e8f8c9..ed939e2fb5264cce24e770272583b12372c3ab68 100644
@@ -5,5 +5,22 @@ The one working on:
 
 From the git version 1.4.0 gitweb is bundled with git.
 
+
+How to configure gitweb for your local system:
+
+You can specify the following configuration variables when building GIT:
+ * GITWEB_SITENAME
+   Shown in the title of all generated pages, defaults to the servers name.
+ * GITWEB_PROJECTROOT
+   The root directory for all projects shown by gitweb.
+ * GITWEB_LIST
+   points to a directory to scan for projects (defaults to project root)
+   or to a file for explicit listing of projects.
+ * GITWEB_HOMETEXT
+   points to an .html file which is included on the gitweb project
+   overview page.
+ * GITWEB_CSS
+   Points to the location where you put gitweb.css on your web server.
+
 Any comment/question/concern to:
   Kay Sievers <[email protected]>
gitweb/gitweb.pl renamed from gitweb/gitweb.cgi +7 -8
similarity index 100%
rename from gitweb/gitweb.cgi
rename to gitweb/gitweb.pl
index 243a2921f849568260e848201d238b3b9fe7e1f2..8e05c335f801d4c52a9b348fa56fccfae36ce621 100755
@@ -24,14 +24,14 @@ our $rss_link = "";
 
 # core git executable to use
 # this can just be "git" if your webserver has a sensible PATH
-our $GIT = "/usr/bin/git";
+our $GIT = "@@GIT_BINDIR@@/git";
 
 # absolute fs-path which will be prepended to the project path
 #our $projectroot = "/pub/scm";
-our $projectroot = "/home/kay/public_html/pub/scm";
+our $projectroot = "@@GITWEB_PROJECTROOT@@";
 
 # version of the core git binary
-our $git_version = qx($GIT --version) =~ m/git version (.*)$/ ? $1 : "unknown";
+our $git_version = "@@GIT_VERSION@@";
 
 # location for temporary files needed for diffs
 our $git_temp = "/tmp/gitweb";
@@ -44,17 +44,16 @@ 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 = $ENV{'SERVER_NAME'} || "Untitled";
+our $site_name = "@@GITWEB_SITENAME@@" || $ENV{'SERVER_NAME'} || "Untitled";
 
 # html text to include at home page
-our $home_text = "indextext.html";
+our $home_text = "@@GITWEB_HOMETEXT@@";
 
 # URI of default stylesheet
-our $stylesheet = "gitweb.css";
+our $stylesheet = "@@GITWEB_CSS@@";
 
 # source of projects list
-#our $projects_list = $projectroot;
-our $projects_list = "index/index.aux";
+our $projects_list = "@@GITWEB_LIST@@" || "$projectroot";
 
 # default blob_plain mimetype and default charset for text/plain blob
 our $default_blob_plain_mimetype = 'text/plain';
Signature · 8 lines
1.4.2.rc2.gf055

-- 
Martin Waitz
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw
Quoted 26 lines · Luben Tuikov
Quoted 7 lines · --- Martin Waitz

Generate gitweb/gitweb.cgi to reduce the need to patch gitweb.cgi by the end user.
The GIT installation directory and version are already known by the Makefile, they can be inserted directly into gitweb.
All other gitweb configuration parameters can now be specified by providing GITWEB_* variables while building GIT.
These are described in gitweb/README.

NACK.

I don't like it. While this method works, it is too much effort to have to run make to do this, plus it pollutes your tree.

Instead, what you can do is make gitweb.cgi read a text file from . which has those variables defined.

This way, I can just copy gitweb.cgi into my web-server directory and voila it works, since the variable definition file would always be there. This way:
- no need to run make to build "gitweb.cgi" or "gitweb.pl" whatever you call it,
- no need to pollute your tree with site defined variables,
- simple copy (cp) would install a working version, instead of the current cp + patch with local settings method.

Quoted 1 line

Luben

Which sounds frighteningly similar to a patch I submitted quite a while ago, and brought up again twice, and have had stomped on once.

So what now? :-)

jdl

#3 lore raw
In reply to Luben Tuikov

hoi :)

thanks for the feedback!

Quoted 2 lines

I don't like it. While this method works, it is too much effort to have to run make to do this, plus it pollutes your tree.

Do you really think it is that much effort?
What do others think? alternatives?

Quoted 2 lines

Instead, what you can do is make gitweb.cgi read a text file from . which has those variables defined.

I don't really care if it is a configuration file or a build-time configuration, but I need something now.
If you submit your proposal, we can compare both and choose the best one ;-).

Quoted 5 lines

This way, I can just copy gitweb.cgi into my web-server directory and voila it works, since the variable definition file would always be there. This way:
- no need to run make to build "gitweb.cgi" or "gitweb.pl" whatever you call it,

ok, but you have to call make anyway to build the rest of GIT, so this shouldn't be a big problem.

Quoted 1 line

- no need to pollute your tree with site defined variables,

this is achieved by my patch, too.

Quoted 2 lines

- simple copy (cp) would install a working version, instead of the current cp + patch with local settings method.

this is achieved by my patch, too.

Signature · 1 line
Martin Waitz
#4 lore raw
Quoted 9 lines · --- Martin Waitz
Quoted 5 lines

This way, I can just copy gitweb.cgi into my web-server directory and voila it works, since the variable definition file would always be there. This way:
- no need to run make to build "gitweb.cgi" or "gitweb.pl" whatever you call it,

ok, but you have to call make anyway to build the rest of GIT, so this shouldn't be a big problem.

Quoted 8 lines
Quoted 1 line

- no need to pollute your tree with site defined variables,

this is achieved by my patch, too.

Quoted 2 lines

- simple copy (cp) would install a working version, instead of the current cp + patch with local settings method.

this is achieved by my patch, too.

That's true, but the difference is that one needs to keep a per-site-installation tree which keeps the configuration of gitweb for that site (installation).

Since you're working on this, can you come up with an alternative way? At this point I don't care either way, but _if_ there is an alternative way, I'd rather we considered it. (Possibly using a symbol table file ("package") to only keep those variables?)

The bash-sed editing is kind of, you have to admit, hackish.

Luben

#5 lore raw
In reply to Martin Waitz

Hi,

Quoted 5 lines · Martin Waitz
Quoted 2 lines

I don't like it. While this method works, it is too much effort to have to run make to do this, plus it pollutes your tree.

Do you really think it is that much effort?
What do others think? alternatives?

I think it is worth it, and it is cleaner. The only drawback: we have to stuff it somehow into git-instaweb...

Ciao,
Dscho

#6 lore raw
In reply to Luben Tuikov

-

Quoted 9 lines · Luben Tuikov
Quoted 7 lines · -- Martin Waitz

Generate gitweb/gitweb.cgi to reduce the need to patch gitweb.cgi by the end user.
The GIT installation directory and version are already known by the Makefile, they can be inserted directly into gitweb.
All other gitweb configuration parameters can now be specified by providing GITWEB_* variables while building GIT.
These are described in gitweb/README.

Quoted 4 lines

NACK.

I don't like it. While this method works, it is too much effort to have to run make to do this, plus it pollutes your tree.

I do not quite agree with this reasoning. With that definition of "polluting your tree", all build of git-*.{sh,perl,py} are polluting your tree. If compile/install time customization is handier I do not have problem doing it that way.

Quoted 2 lines

Instead, what you can do is make gitweb.cgi read a text file from . which has those variables defined.

I think there was a discussion on having a configuration file for gitweb (not per-repository .git/config but installation wide configuration file). If I recall correctly, the killer argument against it was that you would need to bootstrap the process by somehow telling gitweb.cgi where to read from that configuration file, and if you are going to customize gitweb.cgi before installation for the site that way, then giving a bit more configuration in gitweb.cgi (like Martin did in the patch we are discussion) is simpler.

Quoted 5 lines

- no need to run make to build "gitweb.cgi" or "gitweb.pl" whatever you call it,
- no need to pollute your tree with site defined variables,
- simple copy (cp) would install a working version, instead of the current cp + patch with local settings method.

While I agree all of these "no need to" makes things slightly simpler, I do not think it is such a big deal -- we are building git-*.{sh,perl,py,c} anyway.

#7 lore raw
In reply to Martin Waitz
Quoted 12 lines · Martin Waitz
gitweb/gitweb.pl renamed from gitweb/gitweb.cgi +0 -1
similarity index 100%
rename from gitweb/gitweb.cgi
rename to gitweb/gitweb.pl
index 243a2921f849568260e848201d238b3b9fe7e1f2..8e05c335f801d4c52a9b348fa56fccfae36ce621 100755
@@ -24,14 +24,14 @@ our $rss_link = "";
 
 # core git executable to use
 # this can just be "git" if your webserver has a sensible PATH
-our $GIT = "/usr/bin/git";

gitweb/gitweb.pl our $rss_link = ""; · line 34

Quoted 10 lines
gitweb/gitweb.pl renamed from gitweb/gitweb.cgi +3 -2
+our $GIT = "@@GIT_BINDIR@@/git";
 
 # absolute fs-path which will be prepended to the project path
 #our $projectroot = "/pub/scm";
-our $projectroot = "/home/kay/public_html/pub/scm";
+our $projectroot = "@@GITWEB_PROJECTROOT@@";
 
 # version of the core git binary
-our $git_version = qx($GIT --version) =~ m/git version (.*)$/ ? $1 : "unknown";
+our $git_version = "@@GIT_VERSION@@";

I think the other parts are sensible but I am not sure if we want to report the version of git distribution (your patch), or the version of git binary the cgi script happens to use (the current implementation).

#8 lore raw

hoi :)

Quoted 4 lines · Junio C Hamano

I think the other parts are sensible but I am not sure if we want to report the version of git distribution (your patch), or the version of git binary the cgi script happens to use (the current implementation).

hmm, right.
Well, now that gitweb is included with GIT I think that they will be in sync on many sites, but of course that's not guaranteed.

Shall I send a new patch without that change?

Signature · 1 line
Martin Waitz
#9 lore raw
Quoted 7 lines · Martin Waitz
Quoted 5 lines · Junio C Hamano

I think the other parts are sensible but I am not sure if we want to report the version of git distribution (your patch), or the version of git binary the cgi script happens to use (the current implementation).

Quoted 5 lines

hmm, right.
Well, now that gitweb is included with GIT I think that they will be in sync on many sites, but of course that's not guaranteed.

Shall I send a new patch without that change?

There are currently two version variables in gitweb: the version of the script, and the version of git binaries used. They might be different. But now that gitweb is bundled with git, perhaps we could use compile-time git version as gitweb version, i.e.

  our $version = "@@GIT_VERSION@@";

while leaving $git_version as is, i.e.

  our $git_version = 
    qx($GIT --version) =~ m/git version (.*)$/ ? $1 : "unknown"
Signature · 3 lines
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
#10 lore raw

hoi :)

Quoted 4 lines · Jakub Narebski

There are currently two version variables in gitweb: the version of the script, and the version of git binaries used. They might be different. But now that gitweb is bundled with git, perhaps we could use compile-time git version as gitweb version

updated patch below:

+++
Generate gitweb/gitweb.cgi to reduce the need to patch gitweb.cgi by the end user.
The GIT installation directory is already known by the Makefile, and can be inserted directly into gitweb.
All other gitweb configuration parameters can now be specified by providing GITWEB_* variables while building GIT. These are described in gitweb/README.

---
 Makefile                         |   25 +++++++++++++++++++++++--
 gitweb/.gitignore                |    1 +
 gitweb/README                    |   17 +++++++++++++++++
 gitweb/{gitweb.cgi => gitweb.pl} |   15 +++++++--------
 4 files changed, 48 insertions(+), 10 deletions(-)
Makefile +23 -2
index 15864e2..0d66c6a 100644
@@ -116,6 +116,13 @@ template_dir = $(prefix)/share/git-core/
 GIT_PYTHON_DIR = $(prefix)/share/git-core/python
 # DESTDIR=
 
+# default configuration for gitweb
+GITWEB_SITENAME = 
+GITWEB_PROJECTROOT = /pub/git
+GITWEB_LIST = 
+GITWEB_HOMETEXT = indextext.html
+GITWEB_CSS = gitweb.css
+
 export prefix bindir gitexecdir template_dir GIT_PYTHON_DIR
 
 CC = gcc
@@ -514,7 +521,7 @@ LIB_OBJS += $(COMPAT_OBJS)
 export prefix TAR INSTALL DESTDIR SHELL_PATH template_dir
 ### Build rules
 
-all: $(ALL_PROGRAMS) $(BUILT_INS) git$X gitk
+all: $(ALL_PROGRAMS) $(BUILT_INS) git$X gitk gitweb/gitweb.cgi
 
 all:
 	$(MAKE) -C templates
@@ -572,6 +579,20 @@ git-status: git-commit
 	cp $< $@+
 	mv $@+ $@
 
+gitweb/gitweb.cgi: gitweb/gitweb.pl
+	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_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' \
+	    $< >$@+
+	chmod +x $@+
+	mv $@+ $@
+
 git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css
 	rm -f $@ $@+
 	sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
@@ -582,7 +603,7 @@ git-instaweb: git-instaweb.sh gitweb/git
 	    -e '/@@GITWEB_CGI@@/d' \
 	    -e '/@@GITWEB_CSS@@/r gitweb/gitweb.css' \
 	    -e '/@@GITWEB_CSS@@/d' \
-	    [email protected] | sed "s|/usr/bin/git|$(bindir)/git|" > $@+
+	    [email protected] > $@+
 	chmod +x $@+
 	mv $@+ $@
 
gitweb/.gitignore new file +1 -0
new file mode 100644
index 0000000..e83127e
@@ -0,0 +1 @@
+gitweb.cgi
gitweb/README +17 -0
index 8d67276..ed939e2 100644
@@ -5,5 +5,22 @@ The one working on:
 
 From the git version 1.4.0 gitweb is bundled with git.
 
+
+How to configure gitweb for your local system:
+
+You can specify the following configuration variables when building GIT:
+ * GITWEB_SITENAME
+   Shown in the title of all generated pages, defaults to the servers name.
+ * GITWEB_PROJECTROOT
+   The root directory for all projects shown by gitweb.
+ * GITWEB_LIST
+   points to a directory to scan for projects (defaults to project root)
+   or to a file for explicit listing of projects.
+ * GITWEB_HOMETEXT
+   points to an .html file which is included on the gitweb project
+   overview page.
+ * GITWEB_CSS
+   Points to the location where you put gitweb.css on your web server.
+
 Any comment/question/concern to:
   Kay Sievers <[email protected]>
gitweb/gitweb.pl renamed from gitweb/gitweb.cgi +7 -8
similarity index 100%
rename from gitweb/gitweb.cgi
rename to gitweb/gitweb.pl
index e5fca63..20dd901 100755
@@ -17,18 +17,18 @@ use Fcntl ':mode';
 binmode STDOUT, ':utf8';
 
 our $cgi = new CGI;
-our $version = "267";
+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 = "/usr/bin/git";
+our $GIT = "@@GIT_BINDIR@@/git";
 
 # absolute fs-path which will be prepended to the project path
 #our $projectroot = "/pub/scm";
-our $projectroot = "/home/kay/public_html/pub/scm";
+our $projectroot = "@@GITWEB_PROJECTROOT@@";
 
 # version of the core git binary
 our $git_version = qx($GIT --version) =~ m/git version (.*)$/ ? $1 : "unknown";
@@ -44,17 +44,16 @@ 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 = $ENV{'SERVER_NAME'} || "Untitled";
+our $site_name = "@@GITWEB_SITENAME@@" || $ENV{'SERVER_NAME'} || "Untitled";
 
 # html text to include at home page
-our $home_text = "indextext.html";
+our $home_text = "@@GITWEB_HOMETEXT@@";
 
 # URI of default stylesheet
-our $stylesheet = "gitweb.css";
+our $stylesheet = "@@GITWEB_CSS@@";
 
 # source of projects list
-#our $projects_list = $projectroot;
-our $projects_list = "index/index.aux";
+our $projects_list = "@@GITWEB_LIST@@" || "$projectroot";
 
 # default blob_plain mimetype and default charset for text/plain blob
 our $default_blob_plain_mimetype = 'text/plain';
Signature · 4 lines
1.4.2.rc2.gf055

-- 
Martin Waitz
#11 lore raw
In reply to Junio C Hamano
Quoted 22 lines · --- Junio C Hamano

gitweb/gitweb.pl

Quoted 5 lines · Martin Waitz
gitweb/gitweb.pl renamed from gitweb/gitweb.cgi +0 -0
similarity index 100%
rename from gitweb/gitweb.cgi
rename to gitweb/gitweb.pl
index 243a2921f849568260e848201d238b3b9fe7e1f2..8e05c335f801d4c52a9b348fa56fccfae36ce621

100755

Quoted 14 lines
gitweb/gitweb.pl renamed from gitweb/gitweb.cgi +2 -2
@@ -24,14 +24,14 @@ our $rss_link = "";
 
 # core git executable to use
 # this can just be "git" if your webserver has a sensible PATH
-our $GIT = "/usr/bin/git";
+our $GIT = "@@GIT_BINDIR@@/git";
 
 # absolute fs-path which will be prepended to the project path
 #our $projectroot = "/pub/scm";
-our $projectroot = "/home/kay/public_html/pub/scm";
+our $projectroot = "@@GITWEB_PROJECTROOT@@";
 
Quoted 8 lines

gitweb/gitweb.pl our $rss_link = ""; · line 34

Quoted 3 lines
gitweb/gitweb.pl renamed from gitweb/gitweb.cgi +1 -1
 # version of the core git binary
-our $git_version = qx($GIT --version) =~ m/git version (.*)$/ ? $1 : "unknown";
+our $git_version = "@@GIT_VERSION@@";

I think the other parts are sensible but I am not sure if we want to report the version of git distribution (your patch), or the version of git binary the cgi script happens to use (the current implementation).

I'd rather see git distribution (Martin's patch) since, after all, gitweb became part of git not so long ago. And as thus, its own numbers don't matter much, but the git distribution.

In fact, I was thinking of submitting a patch to the same effect myself.

Luben

#12 lore raw
In reply to Martin Waitz
Quoted 1 line · Martin Waitz
 gitweb/{gitweb.cgi => gitweb.pl} |   15 +++++++--------

[...]

gitweb/gitweb.pl

Quoted 7 lines
gitweb/gitweb.pl renamed from gitweb/gitweb.cgi +0 -0
similarity index 100%
rename from gitweb/gitweb.cgi
rename to gitweb/gitweb.pl
index 243a2921f849568260e848201d238b3b9fe7e1f2..8e05c335f801d4c52a9b348fa56fccfae36ce621 100755

Shouldn't we use .perl suffix, i.e. gitweb.perl, like almost all other Perl files in git distribution (the exception is Documentation/sort_glossary.pl which never get installed).

Signature · 3 lines
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git