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"))
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));
ctx.cfg.cache_dynamic_ttl = atoi(value);
else if (!strcmp(name, "cache-about-ttl"))
ctx.cfg.cache_about_ttl = atoi(value);
+ else if (!strcmp(name, "cache-snapshot-ttl"))
+ ctx.cfg.cache_snapshot_ttl = atoi(value);
else if (!strcmp(name, "case-sensitive-sort"))
ctx.cfg.case_sensitive_sort = atoi(value);
else if (!strcmp(name, "about-filter"))
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"))
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);
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")) {
ctx.cfg.cache_max_create_time = 5;
ctx.cfg.cache_root = CGIT_CACHE_ROOT;
ctx.cfg.cache_about_ttl = 15;
+ ctx.cfg.cache_snapshot_ttl = 5;
ctx.cfg.cache_repo_ttl = 5;
ctx.cfg.cache_root_ttl = 5;
ctx.cfg.cache_scanrc_ttl = 15;
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");
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);
}
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;
int scan = 0;
for (i = 1; i < argc; i++) {
- if (!prefixcmp(argv[i], "--cache=")) {
+ if (!strcmp(argv[i], "--version")) {
+ printf("CGit %s | http://git.zx2c4.com/cgit/\n\nCompiled in features:\n", CGIT_VERSION);
+#ifdef NO_LUA
+ printf("[-] ");
+#else
+ printf("[+] ");
+#endif
+ printf("Lua scripting\n");
+#ifndef HAVE_LINUX_SENDFILE
+ printf("[-] ");
+#else
+ printf("[+] ");
+#endif
+ printf("Linux sendfile() usage\n");
+
+ exit(0);
+ }
+ 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
if (!strcmp(ctx.qry.page, "about"))
return ctx.cfg.cache_about_ttl;
+ if (!strcmp(ctx.qry.page, "snapshot"))
+ return ctx.cfg.cache_snapshot_ttl;
+
if (ctx.qry.has_sha1)
return ctx.cfg.cache_static_ttl;