Do not use system gitweb.cgi when gitweb URL set, cgi unset

Until 1b2d47e7a2 (Extract CGI
configuration from GitWebConfig, 2015-06-12), setting

	[gitweb]
		url = url://of/my/gitweb/instance
		; cgi not set

was a way to request use of an externally managed gitweb instance
instead of the internal GitwebServlet.  That patch accidentally
dropped support for that configuration, though it mostly worked if
/usr/lib/cgi-bin/gitweb.cgi happened to be missing or non-executable.

Noticed by running gitweb in such a configuration with
/usr/lib/cgi-bin/gitweb.cgi present and executable.  GitwebServlet
failed to provision because I do not use LocalDiskRepositoryManager
and gerrit.basepath was not set.

 Unexpected exception caught during GET localhost/
 com.google.inject.ProvisionException: Unable to provision, see the following errors:

 1) Error injecting constructor, java.lang.IllegalStateException: gerrit.basePath must be configured
    at com.google.gerrit.server.git.LocalDiskRepositoryManager.<init>(LocalDiskRepositoryManager.java:146)
    at com.google.gerrit.server.git.LocalDiskRepositoryManager.class(LocalDiskRepositoryManager.java:69)
    while locating com.google.gerrit.server.git.LocalDiskRepositoryManager
     for parameter 0 at com.google.gerrit.httpd.gitweb.GitwebServlet.<init>(GitwebServlet.java:111)
    at com.google.gerrit.httpd.gitweb.GitwebServlet.class(GitwebServlet.java:85)
    while locating com.google.gerrit.httpd.gitweb.GitwebServlet

Change-Id: I6aeecd2d6230711eb45a85abbd0000f663f95d74
This commit is contained in:
Jonathan Nieder 2015-06-19 18:06:01 -07:00
parent f5fa310691
commit 4793fd48c5

View File

@ -77,6 +77,12 @@ public class GitwebCgiConfig {
resourcePaths = new String[] {absPath + "/static", absPath}; resourcePaths = new String[] {absPath + "/static", absPath};
} }
} else if (cfg.getString("gitweb", null, "url") != null) {
// Use an externally managed gitweb instance, and not an internal one.
//
cgi = null;
resourcePaths = new String[] {};
} else if (isRegularFile(pkgCgi) && isExecutable(pkgCgi)) { } else if (isRegularFile(pkgCgi) && isExecutable(pkgCgi)) {
// Use the OS packaged CGI. // Use the OS packaged CGI.
// //