]> git.cameronkatri.com Git - cgit.git/blobdiff - shared.c
Merge branch 'lh/menu'
[cgit.git] / shared.c
index f7f43b2e8e083d4c7ba5c15fc8b5d4e36e8d2819..1a5b866e86630df4964961086edbb0ea1ec0d48e 100644 (file)
--- a/shared.c
+++ b/shared.c
@@ -28,6 +28,7 @@ char *cgit_repo_group   = NULL;
 
 int cgit_nocache               =  0;
 int cgit_snapshots             =  0;
+int cgit_enable_index_links    =  0;
 int cgit_enable_log_filecount  =  0;
 int cgit_enable_log_linecount  =  0;
 int cgit_max_lock_attempts     =  5;
@@ -148,6 +149,8 @@ void cgit_global_config_cb(const char *name, const char *value)
                cgit_nocache = atoi(value);
        else if (!strcmp(name, "snapshots"))
                cgit_snapshots = atoi(value);
+       else if (!strcmp(name, "enable-index-links"))
+               cgit_enable_index_links = atoi(value);
        else if (!strcmp(name, "enable-log-filecount"))
                cgit_enable_log_filecount = atoi(value);
        else if (!strcmp(name, "enable-log-linecount"))
@@ -227,7 +230,7 @@ void cgit_querystring_cb(const char *name, const char *value)
        } else if (!strcmp(name, "ofs")) {
                cgit_query_ofs = atoi(value);
        } else if (!strcmp(name, "path")) {
-               cgit_query_path = xstrdup(value);
+               cgit_query_path = trim_end(value, '/');
        } else if (!strcmp(name, "name")) {
                cgit_query_name = xstrdup(value);
        }
@@ -256,6 +259,28 @@ int hextoint(char c)
                return -1;
 }
 
+char *trim_end(const char *str, char c)
+{
+       int len;
+       char *s, *t;
+
+       if (str == NULL)
+               return NULL;
+       t = (char *)str;
+       len = strlen(t);
+       while(len > 0 && t[len - 1] == c)
+               len--;
+
+       if (len == 0)
+               return NULL;
+
+       c = t[len];
+       t[len] = '\0';
+       s = xstrdup(t);
+       t[len] = c;
+       return s;
+}
+
 void cgit_diff_tree_cb(struct diff_queue_struct *q,
                       struct diff_options *options, void *data)
 {