aboutsummaryrefslogtreecommitdiff
diff refs
from: back
to: back
| flip
diff options
context:
space:
mode:
-rw-r--r--cgit.c10
-rw-r--r--cgit.h5
-rw-r--r--cgitrc.5.txt28
-rw-r--r--scan-tree.c48
-rw-r--r--shared.c3
5 files changed, 58 insertions, 36 deletions
diff --git a/cgit.c b/cgit.c
index d699cb6..a8dda23 100644
--- a/cgit.c
+++ b/cgit.c
@@ -163,6 +163,10 @@ void config_cb(const char *name, const char *value)
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"))
@@ -179,8 +183,6 @@ void config_cb(const char *name, const char *value)
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"))
@@ -341,9 +343,11 @@ static void prepare_context(struct cgit_context *ctx)
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;
diff --git a/cgit.h b/cgit.h
index 2742058..8846e88 100644
--- a/cgit.h
+++ b/cgit.h
@@ -200,6 +200,9 @@ struct cgit_config {
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;
@@ -208,7 +211,6 @@ struct cgit_config {
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;
@@ -283,7 +285,6 @@ extern struct cgit_repolist cgit_repolist;
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);
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index 278de90..7e1a93a 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -110,6 +110,24 @@ enable-filter-overrides::
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
@@ -145,15 +163,6 @@ enable-tree-linenumbers::
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
@@ -385,7 +394,6 @@ virtual-root::
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::
diff --git a/scan-tree.c b/scan-tree.c
index 6ce8036..6d1941e 100644
--- a/scan-tree.c
+++ b/scan-tree.c
@@ -47,26 +47,28 @@ static int is_git_dir(const char *path)
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 gitconfig_config(const char *key, const char *value, void *cb)
+static int gitweb_config(const char *key, const char *value, void *cb)
{
- 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);
-
+ 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);
return 0;
}
+
+
static char *xstrrchr(char *s, char *from, int c)
{
while (from >= s && *from != c)
@@ -94,6 +96,11 @@ static void add_repo(const char *base, const char *path, repo_config_fn fn)
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
@@ -103,15 +110,12 @@ static void add_repo(const char *base, const char *path, repo_config_fn fn)
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 (!repo->owner) {
+ while (!owner) {
if ((pwd = getpwuid(st.st_uid)) == NULL) {
fprintf(stderr, "Error reading owner-info for %s: %s (%d)\n",
path, strerror(errno), errno);
@@ -120,10 +124,13 @@ static void add_repo(const char *base, const char *path, repo_config_fn fn)
if (pwd->pw_gecos)
if ((p = strchr(pwd->pw_gecos, ',')))
*p = '\0';
- repo->owner = xstrdup(pwd->pw_gecos ? pwd->pw_gecos : pwd->pw_name);
+ owner = xstrdup(pwd->pw_gecos ? pwd->pw_gecos : pwd->pw_name);
}
+ repo->owner = owner;
- if (repo->desc == cgit_default_repo_desc || !repo->desc) {
+ if (desc)
+ repo->desc = desc;
+ else {
p = fmt("%s/description", path);
if (!stat(p, &st))
readfile(p, &repo->desc, &size);
@@ -134,6 +141,8 @@ static void add_repo(const char *base, const char *path, repo_config_fn fn)
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) {
@@ -158,9 +167,10 @@ static void add_repo(const char *base, const char *path, repo_config_fn fn)
}
p = fmt("%s/cgitrc", path);
- if (!stat(p, &st))
+ if (!stat(p, &st)) {
+ config_fn = fn;
parse_configfile(xstrdup(p), &repo_config);
-
+ }
free(rel);
}
diff --git a/shared.c b/shared.c
index 3e20937..0a0e22e 100644
--- a/shared.c
+++ b/shared.c
@@ -33,7 +33,6 @@ int chk_non_negative(int result, char *msg)
return result;
}
-char *cgit_default_repo_desc = "[no description]";
struct cgit_repo *cgit_add_repo(const char *url)
{
struct cgit_repo *ret;
@@ -53,7 +52,7 @@ struct cgit_repo *cgit_add_repo(const char *url)
ret->url = trim_end(url, '/');
ret->name = ret->url;
ret->path = NULL;
- ret->desc = cgit_default_repo_desc;
+ ret->desc = "[no description]";
ret->owner = NULL;
ret->section = ctx.cfg.section;
ret->snapshots = ctx.cfg.snapshots;