>From 5bf32274e7c038bf1846084807e7e86da45d9efd Mon Sep 17 00:00:00 2001
From: Lauri Kasanen <[email protected]>
Date: Mon, 17 Dec 2012 16:12:45 +0200
Subject: [PATCH 2/2] Add an option to force-on old style urls.


Signed-off-by: Lauri Kasanen <[email protected]>
---
 cgit.c       |    7 ++++++-
 cgit.h       |    1 +
 cgitrc.5.txt |    4 ++++
 3 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/cgit.c b/cgit.c
index a97ed69..47b64dd 100644
--- a/cgit.c
+++ b/cgit.c
@@ -154,6 +154,8 @@ void config_cb(const char *name, const char *value)
                ctx.cfg.module_link = xstrdup(value);
        else if (!strcmp(name, "strict-export"))
                ctx.cfg.strict_export = xstrdup(value);
+       else if (!strcmp(name, "oldstyleurls"))
+               ctx.cfg.oldstyleurls = atoi(value);
        else if (!strcmp(name, "virtual-root")) {
                ctx.cfg.virtual_root = trim_end(value, '/');
                if (!ctx.cfg.virtual_root && (!strcmp(value, "/")))
@@ -826,8 +828,11 @@ int main(int argc, const char **argv)
        /* If virtual-root isn't specified in cgitrc, lets pretend
         * that virtual-root equals SCRIPT_NAME, minus any possibly
         * trailing slashes.
+        *
+        * The user may explicitly disable this with the option
+        * oldstyleurls.
         */
-       if (!ctx.cfg.virtual_root && ctx.cfg.script_name) {
+       if (!ctx.cfg.oldstyleurls && !ctx.cfg.virtual_root && 
ctx.cfg.script_name) {
                ctx.cfg.virtual_root = trim_end(ctx.cfg.script_name, '/');
                if (!ctx.cfg.virtual_root)
                        ctx.cfg.virtual_root = "";
diff --git a/cgit.h b/cgit.h
index 7a99135..7f24c2f 100644
--- a/cgit.h
+++ b/cgit.h
@@ -222,6 +222,7 @@ struct cgit_config {
        int nocache;
        int noplainemail;
        int noheader;
+       int oldstyleurls;
        int renamelimit;
        int remove_suffix;
        int scan_hidden_path;
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index c1038d7..adc2d63 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -271,6 +271,10 @@ noheader::
        Flag which, when set to "1", will make cgit omit the standard header
        on all pages. Default value: none. See also: "embedded".
 
+oldstyleurls::
+       Force on the old-style urls of the type "?url=repo/tree". Default
+       value: "0". See also: virtual-root.
+
 project-list::
        A list of subdirectories inside of scan-path, relative to it, that
        should loaded as git repositories. This must be defined prior to
-- 
1.7.2.1

_______________________________________________
cgit mailing list
[email protected]
http://hjemli.net/mailman/listinfo/cgit

Reply via email to