[PATCH] gitweb: Don't append '/' to project base URL if it ends with '/' or ':'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The base URL 'user@host' would always be appended with a '/', making it
impossible to create clone URLs like: user@host:repo. Setting your base
URL to 'user@host:' will now have the desired effect.

Signed-off-by: Erik Broes <erikbroes@xxxxxxxx>
---
 gitweb/README      |   13 +++++++------
 gitweb/gitweb.perl |    5 ++++-
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/gitweb/README b/gitweb/README
index 8433dd1..efb0f1b 100644
--- a/gitweb/README
+++ b/gitweb/README
@@ -69,12 +69,13 @@ You can specify the following configuration variables when building GIT:
    SERVER_NAME CGI environment variable is not set (e.g. if running
    gitweb as standalone script).  [No default]
  * 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.
-   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
-   git:// protocol access, another for http:// access) from the gitweb
+   Git base URLs used for URL to where fetch project from, i.e. full URL is
+   "$git_base_url/$project".  No '/' will be added between the base URL and and
+   the project if the base URL ends with either a ':' or '/'.  Shown on
+   projects summary page.  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 git:// protocol access, another for http:// access) from the gitweb
    config file.  [No default]
  * GITWEB_CSS
    Points to the location where you put gitweb.css on your web server
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 33ef190..179c48d 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -4503,7 +4503,10 @@ sub git_summary {
 	# or make project git URL from git base URL and project name
 	my $url_tag = "URL";
 	my @url_list = git_get_project_url_list($project);
-	@url_list = map { "$_/$project" } @git_base_url_list unless @url_list;
+
+	# Only join with a '/' if there is no trailing '/' or ':'
+	@url_list = map { $_ .= '/' unless m{[:/]$}; $_.$project } @git_base_url_list unless @url_list;
+
 	foreach my $git_url (@url_list) {
 		next unless $git_url;
 		print "<tr class=\"metadata_url\"><td>$url_tag</td><td>$git_url</td></tr>\n";
-- 
1.6.2.1.519.gcf01bc

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]