ctx.cfg.snapshots = cgit_parse_snapshots_mask(value);
else if (!strcmp(name, "enable-filter-overrides"))
ctx.cfg.enable_filter_overrides = atoi(value);
- else if (!strcmp(name, "enable-gitweb-desc"))
- ctx.cfg.enable_gitweb_desc = atoi(value);
- else if (!strcmp(name, "enable-gitweb-owner"))
- ctx.cfg.enable_gitweb_owner = atoi(value);
else if (!strcmp(name, "enable-http-clone"))
ctx.cfg.enable_http_clone = atoi(value);
else if (!strcmp(name, "enable-index-links"))
ctx.cfg.enable_subject_links = atoi(value);
else if (!strcmp(name, "enable-tree-linenumbers"))
ctx.cfg.enable_tree_linenumbers = atoi(value);
+ else if (!strcmp(name, "enable-git-config"))
+ ctx.cfg.enable_git_config = atoi(value);
else if (!strcmp(name, "max-stats"))
ctx.cfg.max_stats = cgit_find_stats_period(value, NULL);
else if (!strcmp(name, "cache-size"))
ctx->cfg.css = "/cgit.css";
ctx->cfg.logo = "/cgit.png";
ctx->cfg.local_time = 0;
- ctx->cfg.enable_gitweb_desc = 1;
- ctx->cfg.enable_gitweb_owner = 1;
- ctx->cfg.enable_gitweb_section = 1;
ctx->cfg.enable_http_clone = 1;
ctx->cfg.enable_tree_linenumbers = 1;
+ ctx->cfg.enable_git_config = 0;
ctx->cfg.max_repo_count = 50;
ctx->cfg.max_commit_count = 50;
ctx->cfg.max_lock_attempts = 5;
int case_sensitive_sort;
int embedded;
int enable_filter_overrides;
- int enable_gitweb_owner;
- int enable_gitweb_desc;
- int enable_gitweb_section;
int enable_http_clone;
int enable_index_links;
int enable_commit_graph;
int enable_remote_branches;
int enable_subject_links;
int enable_tree_linenumbers;
+ int enable_git_config;
int local_time;
int max_atom_items;
int max_repo_count;
extern struct cgit_context ctx;
extern const struct cgit_snapshot_format cgit_snapshot_formats[];
+extern char *cgit_default_repo_desc;
extern struct cgit_repo *cgit_add_repo(const char *url);
extern struct cgit_repo *cgit_get_repoinfo(const char *url);
extern void cgit_repo_config_cb(const char *name, const char *value);
Flag which, when set to "1", allows all filter settings to be
overridden in repository-specific cgitrc files. Default value: none.
-enable-gitweb-desc::
- If set to "1" and scan-path is enabled, we first check each repository
- for the git config value "gitweb.description" to determine the owner.
- Otherwise, the description is read from a file titled "description"
- inside of the repository directory.
- Default value: "1". See also: scan-path.
-
-enable-gitweb-owner::
- If set to "1" and scan-path is enabled, we first check each repository
- for the git config value "gitweb.owner" to determine the owner.
- Default value: "1". See also: scan-path.
-
-enable-gitweb-section::
- If set to "1" and scan-path is enabled, we first check each repository
- for the git config value "gitweb.category" to determine the repository's
- section. This value is overridden if section-from-path is enabled.
- Default value: "1". See also: scan-path section-from-path.
-
enable-http-clone::
If set to "1", cgit will act as an dumb HTTP endpoint for git clones.
If you use an alternate way of serving git repositories, you may wish
Flag which, when set to "1", will make cgit generate linenumber links
for plaintext blobs printed in the tree view. Default value: "1".
+enable-git-config::
+ Flag which, when set to "1", will allow cgit to use git config to set
+ any repo specific settings. This option is used in conjunction with
+ "scan-path" to augment _repo._ settings. The keys gitweb.owner,
+ gitweb.category, and gitweb.description will map to the cgit keys
+ repo.owner, repo.section, and repo.desc, respectivly. All git config
+ keys that begin with "cgit." will be mapped to the corresponding "repo."
+ key in cgit. Default value: "0". See also: scan-path section-from-path.
+
favicon::
Url used as link to a shortcut icon for cgit. If specified, it is
suggested to use the value "/favicon.ico" since certain browsers will
NOTE: cgit has recently learned how to use PATH_INFO to achieve the
same kind of virtual urls, so this option will probably be deprecated.
+
REPOSITORY SETTINGS
-------------------
repo.about-filter::
struct cgit_repo *repo;
repo_config_fn config_fn;
-char *owner;
-char *desc;
-char *section;
static void repo_config(const char *name, const char *value)
{
config_fn(repo, name, value);
}
-static int gitweb_config(const char *key, const char *value, void *cb)
+static int gitconfig_config(const char *key, const char *value, void *cb)
{
- if (ctx.cfg.enable_gitweb_owner && !strcmp(key, "gitweb.owner"))
- owner = xstrdup(value);
- else if (ctx.cfg.enable_gitweb_desc && !strcmp(key, "gitweb.description"))
- desc = xstrdup(value);
- else if (ctx.cfg.enable_gitweb_section && !strcmp(key, "gitweb.category"))
- section = xstrdup(value);
+ if (!strcmp(key, "gitweb.owner"))
+ config_fn(repo, "owner", value);
+ else if (!strcmp(key, "gitweb.description"))
+ config_fn(repo, "desc", value);
+ else if (!strcmp(key, "gitweb.category"))
+ config_fn(repo, "section", value);
+ else if (!prefixcmp(key, "cgit."))
+ config_fn(repo, key + 5, value);
+
return 0;
}
-
-
static char *xstrrchr(char *s, char *from, int c)
{
while (from >= s && *from != c)
if (!stat(fmt("%s/noweb", path), &st))
return;
- owner = NULL;
- desc = NULL;
- section = NULL;
- git_config_from_file(gitweb_config, fmt("%s/config", path), NULL);
-
if (base == path)
rel = xstrdup(fmt("%s", path));
else
rel[strlen(rel) - 5] = '\0';
repo = cgit_add_repo(rel);
+ config_fn = fn;
+ if (ctx.cfg.enable_git_config)
+ git_config_from_file(gitconfig_config, fmt("%s/config", path), NULL);
+
if (ctx.cfg.remove_suffix)
if ((p = strrchr(repo->url, '.')) && !strcmp(p, ".git"))
*p = '\0';
- repo->name = repo->url;
repo->path = xstrdup(path);
- while (!owner) {
+ while (!repo->owner) {
if ((pwd = getpwuid(st.st_uid)) == NULL) {
fprintf(stderr, "Error reading owner-info for %s: %s (%d)\n",
path, strerror(errno), errno);
if (pwd->pw_gecos)
if ((p = strchr(pwd->pw_gecos, ',')))
*p = '\0';
- owner = xstrdup(pwd->pw_gecos ? pwd->pw_gecos : pwd->pw_name);
+ repo->owner = xstrdup(pwd->pw_gecos ? pwd->pw_gecos : pwd->pw_name);
}
- repo->owner = owner;
- if (desc)
- repo->desc = desc;
- else {
+ if (repo->desc == cgit_default_repo_desc || !repo->desc) {
p = fmt("%s/description", path);
if (!stat(p, &st))
readfile(p, &repo->desc, &size);
if (!stat(p, &st))
repo->readme = "README.html";
}
- if (section)
- repo->section = section;
if (ctx.cfg.section_from_path) {
n = ctx.cfg.section_from_path;
if (n > 0) {
}
p = fmt("%s/cgitrc", path);
- if (!stat(p, &st)) {
- config_fn = fn;
+ if (!stat(p, &st))
parse_configfile(xstrdup(p), &repo_config);
- }
+
free(rel);
}
return result;
}
+char *cgit_default_repo_desc = "[no description]";
struct cgit_repo *cgit_add_repo(const char *url)
{
struct cgit_repo *ret;
ret->url = trim_end(url, '/');
ret->name = ret->url;
ret->path = NULL;
- ret->desc = "[no description]";
+ ret->desc = cgit_default_repo_desc;
ret->owner = NULL;
ret->section = ctx.cfg.section;
ret->snapshots = ctx.cfg.snapshots;