Allow agefile to be set per-repository

This adds "repo.agefile", since namespaced repositories share the same files,
and we'd like to be able to see the ages of the refs for each namespace.

Whatever the git server uses for updating the age file must be namespace aware
and must write the age file to a path consistent with "repo.agefile".

Signed-off-by: Richard Maw <richard.maw@gmail.com>
This commit is contained in:
Richard Maw 2016-06-30 21:06:46 +01:00
parent bb2391a96b
commit aa69de50d3
3 changed files with 5 additions and 1 deletions

2
cgit.c
View File

@ -88,6 +88,8 @@ static void repo_config(struct cgit_repo *repo, const char *name, const char *va
repo->logo = xstrdup(value); repo->logo = xstrdup(value);
else if (!strcmp(name, "logo-link") && value != NULL) else if (!strcmp(name, "logo-link") && value != NULL)
repo->logo_link = xstrdup(value); repo->logo_link = xstrdup(value);
else if (!strcmp(name, "agefile") && value != NULL)
repo->agefile = xstrdup(value);
else if (!strcmp(name, "hide")) else if (!strcmp(name, "hide"))
repo->hide = atoi(value); repo->hide = atoi(value);
else if (!strcmp(name, "ignore")) else if (!strcmp(name, "ignore"))

1
cgit.h
View File

@ -88,6 +88,7 @@ struct cgit_repo {
char *section; char *section;
char *clone_url; char *clone_url;
char *namespace; char *namespace;
char *agefile;
char *logo; char *logo;
char *logo_link; char *logo_link;
int snapshots; int snapshots;

View File

@ -42,7 +42,8 @@ static int get_repo_modtime(const struct cgit_repo *repo, time_t *mtime)
*mtime = repo->mtime; *mtime = repo->mtime;
return 1; return 1;
} }
strbuf_addf(&path, "%s/%s", repo->path, ctx.cfg.agefile); strbuf_addf(&path, "%s/%s", repo->path,
repo->agefile ? repo->agefile : ctx.cfg.agefile);
if (stat(path.buf, &s) == 0) { if (stat(path.buf, &s) == 0) {
*mtime = read_agefile(path.buf); *mtime = read_agefile(path.buf);
if (*mtime) { if (*mtime) {