#include "configfile.h"
#include "html.h"
#include "ui-shared.h"
+#include "scan-tree.h"
const char *cgit_version = CGIT_VERSION;
ctx.cfg.robots = xstrdup(value);
else if (!strcmp(name, "clone-prefix"))
ctx.cfg.clone_prefix = xstrdup(value);
+ else if (!strcmp(name, "local-time"))
+ ctx.cfg.local_time = atoi(value);
else if (!strcmp(name, "repo.group"))
ctx.cfg.repo_group = xstrdup(value);
else if (!strcmp(name, "repo.url"))
} else if (!strcmp(name, "p")) {
ctx.qry.page = xstrdup(value);
} else if (!strcmp(name, "url")) {
+ ctx.qry.url = xstrdup(value);
cgit_parse_url(value);
} else if (!strcmp(name, "qt")) {
ctx.qry.grep = xstrdup(value);
ctx->cfg.cache_static_ttl = -1;
ctx->cfg.css = "/cgit.css";
ctx->cfg.logo = "/git-logo.png";
+ ctx->cfg.local_time = 0;
ctx->cfg.max_repo_count = 50;
ctx->cfg.max_commit_count = 50;
ctx->cfg.max_lock_attempts = 5;
- ctx->cfg.max_msg_len = 60;
- ctx->cfg.max_repodesc_len = 60;
+ ctx->cfg.max_msg_len = 80;
+ ctx->cfg.max_repodesc_len = 80;
ctx->cfg.module_link = "./?repo=%s&page=commit&id=%s";
ctx->cfg.renamelimit = -1;
ctx->cfg.robots = "index, nofollow";
ctx->cfg.root_title = "Git repository browser";
ctx->cfg.root_desc = "a fast webinterface for the git dscm";
ctx->cfg.script_name = CGIT_SCRIPT_NAME;
+ ctx->cfg.summary_branches = 10;
+ ctx->cfg.summary_log = 10;
+ ctx->cfg.summary_tags = 10;
ctx->page.mimetype = "text/html";
ctx->page.charset = PAGE_ENCODING;
ctx->page.filename = NULL;
+ ctx->page.size = 0;
ctx->page.modified = time(NULL);
ctx->page.expires = ctx->page.modified;
}
cgit_print_docend();
}
+int cmp_repos(const void *a, const void *b)
+{
+ const struct cgit_repo *ra = a, *rb = b;
+ return strcmp(ra->url, rb->url);
+}
+
+void print_repo(struct cgit_repo *repo)
+{
+ printf("repo.url=%s\n", repo->url);
+ printf("repo.name=%s\n", repo->name);
+ printf("repo.path=%s\n", repo->path);
+ if (repo->owner)
+ printf("repo.owner=%s\n", repo->owner);
+ if (repo->desc)
+ printf("repo.desc=%s\n", repo->desc);
+ if (repo->readme)
+ printf("repo.readme=%s\n", repo->readme);
+ printf("\n");
+}
+
+void print_repolist(struct cgit_repolist *list)
+{
+ int i;
+
+ for(i = 0; i < list->count; i++)
+ print_repo(&list->repos[i]);
+}
+
+
static void cgit_parse_args(int argc, const char **argv)
{
int i;
+ int scan = 0;
for (i = 1; i < argc; i++) {
if (!strncmp(argv[i], "--cache=", 8)) {
if (!strncmp(argv[i], "--ofs=", 6)) {
ctx.qry.ofs = atoi(argv[i]+6);
}
+ if (!strncmp(argv[i], "--scan-tree=", 12)) {
+ scan++;
+ scan_tree(argv[i] + 12);
+ }
+ }
+ if (scan) {
+ qsort(cgit_repolist.repos, cgit_repolist.count,
+ sizeof(struct cgit_repo), cmp_repos);
+ print_repolist(&cgit_repolist);
+ exit(0);
}
}
int main(int argc, const char **argv)
{
const char *cgit_config_env = getenv("CGIT_CONFIG");
+ const char *path;
+ char *qry;
int err, ttl;
prepare_context(&ctx);
cgit_repolist.count = 0;
cgit_repolist.repos = NULL;
- parse_configfile(cgit_config_env ? cgit_config_env : CGIT_CONFIG,
- config_cb);
- ctx.repo = NULL;
if (getenv("SCRIPT_NAME"))
ctx.cfg.script_name = xstrdup(getenv("SCRIPT_NAME"));
if (getenv("QUERY_STRING"))
ctx.qry.raw = xstrdup(getenv("QUERY_STRING"));
cgit_parse_args(argc, argv);
+ parse_configfile(cgit_config_env ? cgit_config_env : CGIT_CONFIG,
+ config_cb);
+ ctx.repo = NULL;
http_parse_querystring(ctx.qry.raw, querystring_cb);
+ /* If virtual-root isn't specified in cgitrc and no url
+ * parameter is specified on the querystring, lets pretend
+ * that virtualroot equals SCRIPT_NAME and use PATH_INFO as
+ * url. This allows cgit to work with virtual urls without
+ * the need for rewriterules in the webserver (as long as
+ * PATH_INFO is included in the cache lookup key).
+ */
+ if (!ctx.cfg.virtual_root && !ctx.qry.url) {
+ ctx.cfg.virtual_root = ctx.cfg.script_name;
+ path = getenv("PATH_INFO");
+ if (path) {
+ if (path[0] == '/')
+ path++;
+ ctx.qry.url = xstrdup(path);
+ if (ctx.qry.raw) {
+ qry = ctx.qry.raw;
+ ctx.qry.raw = xstrdup(fmt("%s?%s", path, qry));
+ free(qry);
+ } else
+ ctx.qry.raw = ctx.qry.url;
+ cgit_parse_url(ctx.qry.url);
+ }
+ }
+
ttl = calc_ttl();
ctx.page.expires += ttl*60;
if (ctx.cfg.nocache)