Fix gitweb CGI when in subdirectory

If Gerrit is mounted inside of a subdirectory, we need to include
the context path as part of the SCRIPT_NAME environment variable
when we run the gitweb.cgi script.  If we don't, gitweb produces
links to /gitweb, which won't work on the site.

Bug: issue 495
Change-Id: I3f806c360c3d6b517e8aeea65b0387875ba12621
Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce
2010-03-13 17:33:49 -08:00
parent 618dae2a03
commit 1646874104

View File

@@ -428,7 +428,7 @@ class GitWebServlet extends HttpServlet {
// "REMOTE_IDENT" => "NYI"
//
env.set("REQUEST_METHOD", req.getMethod());
env.set("SCRIPT_NAME", req.getServletPath());
env.set("SCRIPT_NAME", req.getContextPath() + req.getServletPath());
env.set("SCRIPT_FILENAME", gitwebCgi.getAbsolutePath());
env.set("SERVER_NAME", req.getServerName());
env.set("SERVER_PORT", Integer.toString(req.getServerPort()));