]> git.cameronkatri.com Git - cgit.git/blobdiff - cgit.c
git: update to v2.2.1
[cgit.git] / cgit.c
diff --git a/cgit.c b/cgit.c
index f488ebfa8cefbe8e9ca041c2bf6bee79cd891e92..796cb7fa9127ff2c9576e9567bc421fba9e498cb 100644 (file)
--- a/cgit.c
+++ b/cgit.c
@@ -69,7 +69,7 @@ static void repo_config(struct cgit_repo *repo, const char *name, const char *va
                repo->max_stats = cgit_find_stats_period(value, NULL);
        else if (!strcmp(name, "module-link"))
                repo->module_link= xstrdup(value);
-       else if (!prefixcmp(name, "module-link.")) {
+       else if (starts_with(name, "module-link.")) {
                item = string_list_append(&repo->submodules, xstrdup(name + 12));
                item->util = xstrdup(value);
        } else if (!strcmp(name, "section"))
@@ -102,7 +102,7 @@ static void config_cb(const char *name, const char *value)
                ctx.repo = cgit_add_repo(value);
        else if (ctx.repo && !strcmp(name, "repo.path"))
                ctx.repo->path = trim_end(value, '/');
-       else if (ctx.repo && !prefixcmp(name, "repo."))
+       else if (ctx.repo && starts_with(name, "repo."))
                repo_config(ctx.repo, name + 5, value);
        else if (!strcmp(name, "readme") && value != NULL)
                string_list_append(&ctx.cfg.readme, xstrdup(value));
@@ -237,7 +237,7 @@ static void config_cb(const char *name, const char *value)
        else if (!strcmp(name, "summary-tags"))
                ctx.cfg.summary_tags = atoi(value);
        else if (!strcmp(name, "side-by-side-diffs"))
-               ctx.cfg.ssdiff = atoi(value);
+               ctx.cfg.difftype = atoi(value) ? DIFF_SSDIFF : DIFF_UNIFIED;
        else if (!strcmp(name, "agefile"))
                ctx.cfg.agefile = xstrdup(value);
        else if (!strcmp(name, "mimetype-file"))
@@ -264,7 +264,7 @@ static void config_cb(const char *name, const char *value)
                        ctx.cfg.branch_sort = 1;
                if (!strcmp(value, "name"))
                        ctx.cfg.branch_sort = 0;
-       } else if (!prefixcmp(name, "mimetype."))
+       } else if (starts_with(name, "mimetype."))
                add_mimetype(name + 9, value);
        else if (!strcmp(name, "include"))
                parse_configfile(expand_macros(value), config_cb);
@@ -312,9 +312,13 @@ static void querystring_cb(const char *name, const char *value)
                ctx.qry.showmsg = atoi(value);
        } else if (!strcmp(name, "period")) {
                ctx.qry.period = xstrdup(value);
+       } else if (!strcmp(name, "dt")) {
+               ctx.qry.difftype = atoi(value);
+               ctx.qry.has_difftype = 1;
        } else if (!strcmp(name, "ss")) {
-               ctx.qry.ssdiff = atoi(value);
-               ctx.qry.has_ssdiff = 1;
+               /* No longer generated, but there may be links out there. */
+               ctx.qry.difftype = atoi(value) ? DIFF_SSDIFF : DIFF_UNIFIED;
+               ctx.qry.has_difftype = 1;
        } else if (!strcmp(name, "all")) {
                ctx.qry.show_all = atoi(value);
        } else if (!strcmp(name, "context")) {
@@ -372,7 +376,7 @@ static void prepare_context(void)
        ctx.cfg.summary_log = 10;
        ctx.cfg.summary_tags = 10;
        ctx.cfg.max_atom_items = 10;
-       ctx.cfg.ssdiff = 0;
+       ctx.cfg.difftype = DIFF_UNIFIED;
        ctx.env.cgit_config = getenv("CGIT_CONFIG");
        ctx.env.http_host = getenv("HTTP_HOST");
        ctx.env.https = getenv("HTTPS");
@@ -453,8 +457,8 @@ static char *guess_defbranch(void)
        const char *ref;
        unsigned char sha1[20];
 
-       ref = resolve_ref_unsafe("HEAD", sha1, 0, NULL);
-       if (!ref || prefixcmp(ref, "refs/heads/"))
+       ref = resolve_ref_unsafe("HEAD", 0, sha1, NULL);
+       if (!ref || !starts_with(ref, "refs/heads/"))
                return "master";
        return xstrdup(ref + 11);
 }
@@ -504,12 +508,6 @@ static void choose_readme(struct cgit_repo *repo)
                        free(ref);
                        continue;
                }
-               /* If there's only one item, we skip the possibly expensive
-                * selection process. */
-               if (repo->readme.nr == 1) {
-                       found = 1;
-                       break;
-               }
                if (ref) {
                        if (cgit_ref_path_exists(filename, ref, 1)) {
                                found = 1;
@@ -941,28 +939,28 @@ static void cgit_parse_args(int argc, const char **argv)
 
                        exit(0);
                }
-               if (!prefixcmp(argv[i], "--cache=")) {
+               if (starts_with(argv[i], "--cache=")) {
                        ctx.cfg.cache_root = xstrdup(argv[i] + 8);
                } else if (!strcmp(argv[i], "--nocache")) {
                        ctx.cfg.nocache = 1;
                } else if (!strcmp(argv[i], "--nohttp")) {
                        ctx.env.no_http = "1";
-               } else if (!prefixcmp(argv[i], "--query=")) {
+               } else if (starts_with(argv[i], "--query=")) {
                        ctx.qry.raw = xstrdup(argv[i] + 8);
-               } else if (!prefixcmp(argv[i], "--repo=")) {
+               } else if (starts_with(argv[i], "--repo=")) {
                        ctx.qry.repo = xstrdup(argv[i] + 7);
-               } else if (!prefixcmp(argv[i], "--page=")) {
+               } else if (starts_with(argv[i], "--page=")) {
                        ctx.qry.page = xstrdup(argv[i] + 7);
-               } else if (!prefixcmp(argv[i], "--head=")) {
+               } else if (starts_with(argv[i], "--head=")) {
                        ctx.qry.head = xstrdup(argv[i] + 7);
                        ctx.qry.has_symref = 1;
-               } else if (!prefixcmp(argv[i], "--sha1=")) {
+               } else if (starts_with(argv[i], "--sha1=")) {
                        ctx.qry.sha1 = xstrdup(argv[i] + 7);
                        ctx.qry.has_sha1 = 1;
-               } else if (!prefixcmp(argv[i], "--ofs=")) {
+               } else if (starts_with(argv[i], "--ofs=")) {
                        ctx.qry.ofs = atoi(argv[i] + 6);
-               } else if (!prefixcmp(argv[i], "--scan-tree=") ||
-                          !prefixcmp(argv[i], "--scan-path=")) {
+               } else if (starts_with(argv[i], "--scan-tree=") ||
+                          starts_with(argv[i], "--scan-path=")) {
                        /*
                         * HACK: The global snapshot bit mask defines the set
                         * of allowed snapshot formats, but the config file