List for cgit developers and users
 help / color / mirror / Atom feed
From: jamie.couture at gmail.com (Jamie Couture)
Subject: [PATCH 1/2] add git config parsing during scan-path
Date: Mon,  8 Oct 2012 12:48:23 -0400	[thread overview]
Message-ID: <1349714904-10431-1-git-send-email-jamie.couture@gmail.com> (raw)
In-Reply-To: <CAHmME9qQv5QDk=48kdV0sYxS5nuv7KVm_anGOZ1Q4Vff-1q7=Q@mail.gmail.com>

Signed-off-by: Jamie Couture <jamie.couture at gmail.com>
---
 cgit.c      |  3 +++
 cgit.h      |  1 +
 scan-tree.c | 19 +++++++++++++++----
 3 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/cgit.c b/cgit.c
index 1ec02e7..910bf1d 100644
--- a/cgit.c
+++ b/cgit.c
@@ -183,6 +183,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"))
@@ -348,6 +350,7 @@ static void prepare_context(struct cgit_context *ctx)
 	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 79ba7ad..4ac6f80 100644
--- a/cgit.h
+++ b/cgit.h
@@ -211,6 +211,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 6d1941e..7e711d5 100644
--- a/scan-tree.c
+++ b/scan-tree.c
@@ -67,7 +67,14 @@ static int gitweb_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, "cgit.")) {
+		config_fn(repo, key + 5, value);
+	}
 
+	return 0;
+}
 
 static char *xstrrchr(char *s, char *from, int c)
 {
@@ -166,10 +173,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.11.4





  parent reply	other threads:[~2012-10-08 16:48 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-27  1:39 Maintaining My Own Cgit Tree Jason
2012-09-27  4:22 ` william.bell
2012-09-27  9:00   ` Tobias.Bieniek
2012-09-27 15:53   ` webmaster
2012-09-29  0:30 ` [PATCH] Added code to output the age as seconds instead of "0 min." lsworkemail112
2012-09-29  5:20   ` Jason
2012-09-29 18:43     ` lsworkemail112
2012-09-29 18:51       ` Jason
2012-09-29 19:14         ` lsworkemail112
2012-09-29 19:15           ` Jason
2012-09-29 19:17             ` lsworkemail112
2012-09-29 19:16           ` lsworkemail112
2012-09-30  5:51       ` mailings
2012-09-30 17:28         ` lsworkemail112
2012-09-30 17:29         ` Jason
2012-09-30 17:40           ` mailings
2012-09-30 21:06           ` lsworkemail112
2012-09-30 21:33             ` Jason
2012-10-01  6:12               ` mailings
2012-10-02  1:46                 ` lsworkemail112
2012-10-02  2:04                   ` Jason
2012-10-02  2:08                     ` lsworkemail112
2012-10-01 13:56       ` webmaster
2012-10-08 16:48 ` jamie.couture [this message]
2012-10-08 16:48   ` [PATCH 2/2] update documentation jamie.couture
2012-10-08 21:05     ` 
2012-10-08 21:18     ` 
2012-10-08 16:49 ` [PATCH] repolist pagination changes jamie.couture
2012-10-08 21:39   ` Jason
2012-10-08 17:12 ` [PATCH] add tag target to generate ctags jamie.couture
2012-10-08 21:41   ` Jason
2012-10-09 10:56 ` [PATCH] add git config parsing during scan-path jamie.couture
2012-10-09 11:33   ` Jason
2012-10-09 11:15 ` Maintaining My Own Cgit Tree mailings
2012-10-09 11:18   ` Jason

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1349714904-10431-1-git-send-email-jamie.couture@gmail.com \
    --to=cgit@lists.zx2c4.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).