]> gitweb.ps.run Git - ps-cgit/blobdiff - cgit.c
Add URL parameter 'context' for changing the number of context lines in diffs
[ps-cgit] / cgit.c
diff --git a/cgit.c b/cgit.c
index 4f68a4bbd7434f597aac6d6f8b3c59a11a371b47..e9bafb506ef38c24c4b4300de08d0b5965a738f6 100644 (file)
--- a/cgit.c
+++ b/cgit.c
@@ -60,6 +60,8 @@ void repo_config(struct cgit_repo *repo, const char *name, const char *value)
                repo->enable_log_filecount = ctx.cfg.enable_log_filecount * atoi(value);
        else if (!strcmp(name, "enable-log-linecount"))
                repo->enable_log_linecount = ctx.cfg.enable_log_linecount * atoi(value);
+       else if (!strcmp(name, "enable-remote-branches"))
+               repo->enable_remote_branches = atoi(value);
        else if (!strcmp(name, "max-stats"))
                repo->max_stats = cgit_find_stats_period(value, NULL);
        else if (!strcmp(name, "module-link"))
@@ -137,6 +139,8 @@ void config_cb(const char *name, const char *value)
                ctx.cfg.enable_log_filecount = atoi(value);
        else if (!strcmp(name, "enable-log-linecount"))
                ctx.cfg.enable_log_linecount = atoi(value);
+       else if (!strcmp(name, "enable-remote-branches"))
+               ctx.cfg.enable_remote_branches = atoi(value);
        else if (!strcmp(name, "enable-tree-linenumbers"))
                ctx.cfg.enable_tree_linenumbers = atoi(value);
        else if (!strcmp(name, "max-stats"))
@@ -246,6 +250,8 @@ static void querystring_cb(const char *name, const char *value)
                ctx.qry.period = xstrdup(value);
        } else if (!strcmp(name, "ss")) {
                ctx.qry.ssdiff = atoi(value);
+       } else if (!strcmp(name, "context")) {
+               ctx.qry.context = atoi(value);
        }
 }
 
@@ -256,7 +262,7 @@ char *xstrdupn(const char *str)
 
 static void prepare_context(struct cgit_context *ctx)
 {
-       memset(ctx, 0, sizeof(ctx));
+       memset(ctx, 0, sizeof(*ctx));
        ctx->cfg.agefile = "info/web/last-modified";
        ctx->cfg.nocache = 0;
        ctx->cfg.cache_size = 0;
@@ -420,6 +426,12 @@ static void process_request(void *cbdata)
                return;
        }
 
+       /* If cmd->want_vpath is set, assume ctx->qry.path contains a "virtual"
+        * in-project path limit to be made available at ctx->qry.vpath.
+        * Otherwise, no path limit is in effect (ctx->qry.vpath = NULL).
+        */
+       ctx->qry.vpath = cmd->want_vpath ? ctx->qry.path : NULL;
+
        if (cmd->want_repo && !ctx->repo) {
                cgit_print_http_headers(ctx);
                cgit_print_docstart(ctx);