[PATCH v3 1/3] add git config parsing during scan-path
Jamie Couture
jamie.couture at gmail.com
Fri Nov 25 14:52:53 CET 2011
Signed-off-by: Jamie Couture <jamie.couture at gmail.com>
---
cgit.c | 3 +++
cgit.h | 1 +
scan-tree.c | 21 +++++++++++++++++----
3 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/cgit.c b/cgit.c
index b7807ad..b9c4540 100644
--- a/cgit.c
+++ b/cgit.c
@@ -176,6 +176,8 @@ 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"))
@@ -331,6 +333,7 @@ static void prepare_context(struct cgit_context *ctx)
ctx->cfg.enable_gitweb_owner = 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 bad66f0..b49d68a 100644
--- a/cgit.h
+++ b/cgit.h
@@ -204,6 +204,7 @@ 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;
diff --git a/scan-tree.c b/scan-tree.c
index 378d795..57e7946 100644
--- a/scan-tree.c
+++ b/scan-tree.c
@@ -61,6 +61,15 @@ static int git_owner_config(const char *key, const char *value, void *cb)
return 0;
}
+static int cgit_repo_config(const char *key, const char *value, void *cb)
+{
+ if (!prefixcmp(key, "repo.")) {
+ config_fn(repo, key + 5, value);
+ }
+
+ return 0;
+}
+
static char *xstrrchr(char *s, char *from, int c)
{
while (from >= s && *from != c)
@@ -150,10 +159,14 @@ static void add_repo(const char *base, const char *path, repo_config_fn fn)
}
}
- p = fmt("%s/cgitrc", path);
- if (!stat(p, &st)) {
- config_fn = fn;
- parse_configfile(xstrdup(p), &repo_config);
+ config_fn = fn;
+ if (ctx.cfg.enable_git_config) {
+ git_config_from_file(cgit_repo_config, fmt("%s/config", path), NULL);
+ } else {
+ p = fmt("%s/cgitrc", path);
+ if (!stat(p, &st)) {
+ parse_configfile(xstrdup(p), &repo_config);
+ }
}
free(rel);
--
1.7.7.4
More information about the CGit
mailing list