threads / patch / 5278

patchgitweb: configurable home link string

Subject: [PATCH] gitweb: configurable home link string

## tl;dr

6 messages between Aug 14, 2006 and Aug 15, 2006. Diffs are folded; open one to read it.

replies: 5people: 4as markdown or json

Yasushi SHOJI· Aug 14, 2006, 22:50 UTC · lore

I've always found difficult to figure out git URL for clone from gitweb URL because git:// and http:// are different on many site including kernel.org.

I've found this enhancement at http://dev.laptop.org/git when I was on git channel, and thought that it'd be nice if all public gitweb site show it's git URL on its page.

This patch allow us to change the home link string. The current default is "projects" as we all see on gitweb now.

ie. kernel.org might set this variable to "git://git.kernel.org/pub/scm/"
Signed-off-by: Yasushi SHOJI <yashi@atmark-techno.com>
---
 Makefile           |    2 ++
 gitweb/gitweb.perl |    5 ++++-
 2 files changed, 6 insertions(+), 1 deletions(-)
Show changes to 2 files +6 −1

Makefile, gitweb/gitweb.perl

diff --git a/Makefile b/Makefile
index a538710..b363f50 100644
--- a/Makefile
+++ b/Makefile
@@ -123,6 +123,7 @@ # DESTDIR=
 
 # default configuration for gitweb
 GITWEB_CONFIG = gitweb_config.perl
+GITWEB_HOME_LINK_STR = projects
 GITWEB_SITENAME =
 GITWEB_PROJECTROOT = /pub/git
 GITWEB_LIST =
@@ -617,6 +618,7 @@ gitweb/gitweb.cgi: gitweb/gitweb.perl
 	    -e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \
 	    -e 's|++GIT_BINDIR++|$(bindir)|g' \
 	    -e 's|++GITWEB_CONFIG++|$(GITWEB_CONFIG)|g' \
+	    -e 's|++GITWEB_HOME_LINK_STR++|$(GITWEB_HOME_LINK_STR)|g' \
 	    -e 's|++GITWEB_SITENAME++|$(GITWEB_SITENAME)|g' \
 	    -e 's|++GITWEB_PROJECTROOT++|$(GITWEB_PROJECTROOT)|g' \
 	    -e 's|++GITWEB_LIST++|$(GITWEB_LIST)|g' \
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 626fcc9..76e8376 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -36,6 +36,9 @@ our $git_temp = "/tmp/gitweb";
 # target of the home link on top of all pages
 our $home_link = $my_uri;
 
+# string of the home link on top of all pages
+our $home_link_str = "++GITWEB_HOME_LINK_STR++";
+
 # name of your site or organization to appear in page titles
 # replace this with something more descriptive for clearer bookmarks
 our $site_name = "++GITWEB_SITENAME++" || $ENV{'SERVER_NAME'} || "Untitled";
@@ -890,7 +893,7 @@ EOF
 	      "<a href=\"http://www.kernel.org/pub/software/scm/git/docs/\" title=\"git documentation\">" .
 	      "<img src=\"$logo\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/>" .
 	      "</a>\n";
-	print $cgi->a({-href => esc_param($home_link)}, "projects") . " / ";
+	print $cgi->a({-href => esc_param($home_link)}, $home_link_str) . " / ";
 	if (defined $project) {
 		print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, esc_html($project));
 		if (defined $action) {
-- 
1.4.2.g182a
Jakub Narebski· Aug 15, 2006, 16:15 UTC · re: Yasushi SHOJI · lore

Re: [PATCH] gitweb: configurable home link string

Yasushi SHOJI wrote:
Show 14 quoted lines
> I've always found difficult to figure out git URL for clone from
> gitweb URL because git:// and http:// are different on many site
> including kernel.org.
> 
> I've found this enhancement at http://dev.laptop.org/git when I was on
> git channel, and thought that it'd be nice if all public gitweb site
> show it's git URL on its page.
> 
> This patch allow us to change the home link string.  The current
> default is "projects" as we all see on gitweb now.
> 
> ie. kernel.org might set this variable to "git://git.kernel.org/pub/scm/"
> 
> Signed-off-by: Yasushi SHOJI <yashi@atmark-techno.com>
There is similar improvement in gitweb-xmms2, where the git clone/fetch
URL for an individual project is visible in the "summary" page for project,
see e.g.
  http://git.xmms.se/?p=gitweb-xmms2.git;a=summary
I plan on implementing such a feature, with an improvement that URL is not
displayed if $git_base_url (your $home_link_str) is not defined (e.g.
repository is not published)... or you can reimplement this feature.
 
http://git.xmms.se/?p=gitweb-xmms2.git;a=commit;h=8e327dfbdebedd0c5fc02fe606fd4675b43237d7
-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
Martin Waitz· Aug 15, 2006, 19:27 UTC · re: Jakub Narebski · lore

Re: [PATCH] gitweb: configurable home link string

hoi :)
On Tue, Aug 15, 2006 at 06:15:05PM +0200, Jakub Narebski wrote:
> There is similar improvement in gitweb-xmms2, where the git clone/fetch
> URL for an individual project is visible in the "summary" page for project,

doesn't it make more sense to make it more easy to use the same URL for git:, http: and gitweb?

-- 
Martin Waitz
Jakub Narebski· Aug 15, 2006, 19:36 UTC · re: Martin Waitz · lore

Re: [PATCH] gitweb: configurable home link string

On 8/15/06, Martin Waitz <tali@admingilde.org> wrote:
Show 6 quoted lines
> On Tue, Aug 15, 2006 at 06:15:05PM +0200, Jakub Narebski wrote:
>> There is similar improvement in gitweb-xmms2, where the git clone/fetch
>> URL for an individual project is visible in the "summary" page for project,
>
> doesn't it make more sense to make it more easy to use the same URL for
> git:, http: and gitweb?

It is not always possible to use the same URL for gitweb and http:// access, for example gitweb might require /cgi-bin/ in path. git:// and git+ssh:// access migh need different path than http:// access.

With PATH_INFO for 'project' parameter actually used gitweb link would be the same as http:// access link; the problem would be to differentiate which handle using gitweb.cgi, and which handle directly.

-- 
Jakub Narebski
Carl Worth· Aug 15, 2006, 20:24 UTC · re: Jakub Narebski · lore

Re: [PATCH] gitweb: configurable home link string

On Tue, 15 Aug 2006 21:36:43 +0200, "Jakub Narebski" wrote:
Show 11 quoted lines
> On 8/15/06, Martin Waitz <tali@admingilde.org> wrote:
> >
> > doesn't it make more sense to make it more easy to use the same URL for
> > git:, http: and gitweb?
>
> It is not always possible to use the same URL for gitweb and http://
> access, for example gitweb might require /cgi-bin/ in path. git:// and
> git+ssh:// access migh need different path than http:// access.
>
> With PATH_INFO for 'project' parameter actually used gitweb link would
> be the same as http:// access link;

And for someone who has enough control to make consistent URLs happen, could anyone provide guidance on how to make this work? Specifically, I'm interested in getting at the PATH_INFO for project functionality.

Currently I've got gitweb running at the root URL on its own domain with the following apache configuration:

	ScriptAlias / /usr/lib/cgi-bin/gitweb
So I can currently browse a project with something like:
	http://gitweb.freedesktop.org/?p=cairo.git
But if I try to put the project name as part of the path:
	http://gitweb.freedesktop.org/cairo.git

Then I just get a 404. So what do I need to configure to get the PATH_INFO stuff to work?

Also, is there support in gitweb for not requiring the ".git" suffix even though that exists in the directory on the filesystem? The URL I really want to use is:

	http://gitweb.freedesktop.org/cairo

Finally, once I get that working, I would like gitweb to generate URLs of this form in the link it generates. Does it have that capability yet? (It would also be nice if it didn't append options that are the default anyway, such as ";a=summary").

Thanks in advance,
-Carl

PS. Oh, and then the final thing I'd want is to allow someone to cut and paste a gitweb URL such as the above to "git clone" and then some magic would forward things such that the git daemon would serve the data. Has anyone got that working? And for bonus points, it would also fail over to http:// cloning if git:// cloning weren't possible for some reason.

Martin Waitz· Aug 15, 2006, 22:11 UTC · re: Carl Worth · lore

Re: [PATCH] gitweb: configurable home link string

hoi :)
On Tue, Aug 15, 2006 at 01:24:40PM -0700, Carl Worth wrote:
> Currently I've got gitweb running at the root URL on its own domain
> with the following apache configuration:
> 
> 	ScriptAlias / /usr/lib/cgi-bin/gitweb
I use the following configuration:
    DocumentRoot /pub/git
    RewriteEngine on
    RewriteRule ^/(.*\.git/(.*\.html)?)?$ /cgi-bin/gitweb.cgi%{REQUEST_URI}  [L,PT]

this has the advantage that normal http: repository accesses go to the normal web server and only gitweb accesses go to the CGI.

> Finally, once I get that working, I would like gitweb to generate URLs
> of this form in the link it generates. Does it have that capability
> yet? (It would also be nice if it didn't append options that are the
> default anyway, such as ";a=summary").

I had this for an very old gitweb version and am currently reimplementing it for current gitweb versions.

-- 
Martin Waitz

← back to recent threads