git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 4/7] gitweb: Optionally add "git" links in project list page

From
John 'Warthog9' Hawley <warthog9@eaglescrag.net>
Date
Jan 13, 2010, 09:34 UTC
Message-ID
<1263375282-15508-5-git-send-email-warthog9@eaglescrag.net>
In-Reply-To
<1263375282-15508-4-git-send-email-warthog9@eaglescrag.net>
From: John 'Warthog9' Hawley <warthog9@kernel.org>

This adds a "git" link for each project in the project list page, should a common $gitlinkurl_project be defined and not empty. The full URL of each link is composed of $git_base_url_list[0] and project name. It is intended for git:// links or that something can reference the git repository using a smart protocol directly.

This does make the assumption that the git repositories share a common path, which is no different than the assumption @git_base_url_list makes. Nothing to date is known to actually make use of introduced link.

Created "git" link follows rel=vcs-* microformat specification:
  http://kitenet.net/~joey/rfc/rel-vcs/
Signed-off-by: John 'Warthog9' Hawley <warthog9@kernel.org>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
 gitweb/README      |    4 ++++
 gitweb/gitweb.perl |    9 +++++++++
 2 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/gitweb/README b/gitweb/README
index 608b0f8..2ec66e7 100644
--- a/gitweb/README
+++ b/gitweb/README
@@ -71,6 +71,7 @@ You can specify the following configuration variables when building GIT:
  * GITWEB_BASE_URL
    Git base URLs used for URL to where fetch project from, i.e. full
    URL is "$git_base_url/$project".  Shown on projects summary page.
+   If it begins with "git://" it is also used for $gitlinkurl_base, see below.
    Repository URL for project can be also configured per repository; this
    takes precedence over URLs composed from base URL and a project name.
    Note that you can setup multiple base URLs (for example one for
@@ -204,6 +205,9 @@ not include variables usually directly set during build):
    access, and one for http:// "dumb" protocol access).  Note that per
    repository configuration in 'cloneurl' file, or as values of gitweb.url
    project config.
+ * $gitlinkurl_project
+   Boolean (if it is defined and not empty) to add "git" link in
+   projects list, for each project.  Full URL is "$git_base_url_list[0]/$project".
  * $default_blob_plain_mimetype
    Default mimetype for blob_plain (raw) view, if mimetype checking
    doesn't result in some other type; by default 'text/plain'.
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index f17593f..b8f2a67 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -224,6 +224,11 @@ our %avatar_size = (
 # If it is true, exit if gitweb version and git binary version don't match
 our $git_versions_must_match = 0;
 
+# This is a boolean on/off switch to add a "git" link for each project in
+#  project list.  It uses the first element of @git_base_url_list as the
+#  base of the URL.  Full URL is "$git_base_url_list[0]/$project".
+our $gitlinkurl_project = '';
+
 # Used to set the maximum load that we will still respond to gitweb queries.
 # If server load exceed this value then return "503 server busy" error.
 # If gitweb cannot determined server load, it is taken to be 0.
@@ -4473,6 +4478,10 @@ sub git_project_list_body {
 		      $cgi->a({-href => href(project=>$pr->{'path'}, action=>"log")}, "log") . " | " .
 		      $cgi->a({-href => href(project=>$pr->{'path'}, action=>"tree")}, "tree") .
 		      ($pr->{'forks'} ? " | " . $cgi->a({-href => href(project=>$pr->{'path'}, action=>"forks")}, "forks") : '') .
+		      ($gitlinkurl_project && $git_base_url_list[0] ?
+		       " | " . $cgi->a({-href=> $git_base_url_list[0] ."/$pr->{'path'}",
+		                        -rel=>"vcs-git"}, "git")
+		      : '') .
 		      "</td>\n" .
 		      "</tr>\n";
 	}
-- 
1.6.5.2
Previous: John 'Warthog9' HawleyNext: John 'Warthog9' Hawley
Message 5 of 11 in “Gitweb caching v4”
  1. 0/7 Gitweb caching v4John 'Warthog9' Hawley, Jan 13, 2010
  2. 1/7 gitweb: Load checkingJohn 'Warthog9' Hawley, Jan 13, 2010
  3. 2/7 gitweb: Add option to force version matchJohn 'Warthog9' Hawley, Jan 13, 2010
  4. 3/7 gitweb: Makefile improvementsJohn 'Warthog9' Hawley, Jan 13, 2010
  5. 4/7 gitweb: Optionally add "git" links in project list pageJohn 'Warthog9' Hawley, Jan 13, 2010
  6. 5/7 gitweb: Convert output to using indirect file handleJohn 'Warthog9' Hawley, Jan 13, 2010
  7. 6/7 gitweb: add a get function to compliment print_local_timeJohn 'Warthog9' Hawley, Jan 13, 2010
  8. 7/7 gitweb: File based caching layer (from git.kernel.org)John 'Warthog9' Hawley, Jan 13, 2010
  9. Junio C HamanoJan 14, 2010
  10. J.H.Jan 14, 2010
  11. Junio C HamanoJan 14, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.