]> git.cameronkatri.com Git - cgit.git/blobdiff - cgit.c
Merge branch 'stable'
[cgit.git] / cgit.c
diff --git a/cgit.c b/cgit.c
index 93a7a69f78d2fa37aa86df19fb9d4c6724f2eaf0..bfde9f98ccfdf1c793aa1d70e1558e90a4b5ace5 100644 (file)
--- a/cgit.c
+++ b/cgit.c
@@ -68,9 +68,9 @@ void repo_config(struct cgit_repo *repo, const char *name, const char *value)
                repo->section = xstrdup(value);
        else if (!strcmp(name, "readme") && value != NULL) {
                if (*value == '/')
-                       ctx.repo->readme = xstrdup(value);
+                       repo->readme = xstrdup(value);
                else
-                       ctx.repo->readme = xstrdup(fmt("%s/%s", ctx.repo->path, value));
+                       repo->readme = xstrdup(fmt("%s/%s", repo->path, value));
        } else if (ctx.cfg.enable_filter_overrides) {
                if (!strcmp(name, "about-filter"))
                        repo->about_filter = new_filter(value, 0);
@@ -137,6 +137,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-tree-linenumbers"))
+               ctx.cfg.enable_tree_linenumbers = atoi(value);
        else if (!strcmp(name, "max-stats"))
                ctx.cfg.max_stats = cgit_find_stats_period(value, NULL);
        else if (!strcmp(name, "cache-size"))
@@ -207,6 +209,8 @@ static void querystring_cb(const char *name, const char *value)
        } else if (!strcmp(name, "p")) {
                ctx.qry.page = xstrdup(value);
        } else if (!strcmp(name, "url")) {
+               if (*value == '/')
+                       value++;
                ctx.qry.url = xstrdup(value);
                cgit_parse_url(value);
        } else if (!strcmp(name, "qt")) {
@@ -260,6 +264,7 @@ static void prepare_context(struct cgit_context *ctx)
        ctx->cfg.css = "/cgit.css";
        ctx->cfg.logo = "/cgit.png";
        ctx->cfg.local_time = 0;
+       ctx->cfg.enable_tree_linenumbers = 1;
        ctx->cfg.max_repo_count = 50;
        ctx->cfg.max_commit_count = 50;
        ctx->cfg.max_lock_attempts = 5;
@@ -457,6 +462,15 @@ char *build_snapshot_setting(int bitmap)
        return result;
 }
 
+char *get_first_line(char *txt)
+{
+       char *t = xstrdup(txt);
+       char *p = strchr(t, '\n');
+       if (p)
+               *p = '\0';
+       return t;
+}
+
 void print_repo(FILE *f, struct cgit_repo *repo)
 {
        fprintf(f, "repo.url=%s\n", repo->url);
@@ -464,8 +478,11 @@ void print_repo(FILE *f, struct cgit_repo *repo)
        fprintf(f, "repo.path=%s\n", repo->path);
        if (repo->owner)
                fprintf(f, "repo.owner=%s\n", repo->owner);
-       if (repo->desc)
-               fprintf(f, "repo.desc=%s\n", repo->desc);
+       if (repo->desc) {
+               char *tmp = get_first_line(repo->desc);
+               fprintf(f, "repo.desc=%s\n", tmp);
+               free(tmp);
+       }
        if (repo->readme)
                fprintf(f, "repo.readme=%s\n", repo->readme);
        if (repo->defbranch)
@@ -608,6 +625,16 @@ static void cgit_parse_args(int argc, const char **argv)
                }
                if (!strncmp(argv[i], "--scan-tree=", 12) ||
                    !strncmp(argv[i], "--scan-path=", 12)) {
+                       /* HACK: the global snapshot bitmask defines the
+                        * set of allowed snapshot formats, but the config
+                        * file hasn't been parsed yet so the mask is
+                        * currently 0. By setting all bits high before
+                        * scanning we make sure that any in-repo cgitrc
+                        * snapshot setting is respected by scan_tree().
+                        * BTW: we assume that there'll never be more than
+                        * 255 different snapshot formats supported by cgit...
+                        */
+                       ctx.cfg.snapshots = 0xFF;
                        scan++;
                        scan_tree(argv[i] + 12, repo_config);
                }