From: jamie.couture at gmail.com (Jamie Couture)
Subject: [PATCH 2/2] Add feature: obtain repo section from git config
Date: Fri, 3 Jun 2011 19:21:02 -0400 [thread overview]
Message-ID: <1307143262-11018-3-git-send-email-jamie.couture@gmail.com> (raw)
In-Reply-To: <1307143262-11018-1-git-send-email-jamie.couture@gmail.com>
From: Jamie Couture <jamie.couture at gmail.com>
---
cgit.c | 2 ++
cgit.h | 1 +
cgitrc.5.txt | 8 ++++++++
scan-tree.c | 10 ++++++++++
4 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/cgit.c b/cgit.c
index f4dd6ef..6a51bec 100644
--- a/cgit.c
+++ b/cgit.c
@@ -207,6 +207,8 @@ void config_cb(const char *name, const char *value)
ctx.cfg.scan_hidden_path = atoi(value);
else if (!strcmp(name, "section-from-path"))
ctx.cfg.section_from_path = atoi(value);
+ else if (!strcmp(name, "section-from-repo-config"))
+ ctx.cfg.section_from_repo_config = atoi(value);
else if (!strcmp(name, "source-filter"))
ctx.cfg.source_filter = new_filter(value, 1);
else if (!strcmp(name, "summary-log"))
diff --git a/cgit.h b/cgit.h
index b5f00fc..14e8243 100644
--- a/cgit.h
+++ b/cgit.h
@@ -214,6 +214,7 @@ struct cgit_config {
int remove_suffix;
int scan_hidden_path;
int section_from_path;
+ int section_from_repo_config;
int snapshots;
int summary_branches;
int summary_log;
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index c3698a6..a78d226 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -301,6 +301,14 @@ section-from-path::
If negative, cgit will discard the specified number of path elements
above the repo directory. Default value: 0.
+section-from-repo-config::
+ If set to "1" obtain the section name from git config. The expected config
+ section.key that is used is "cgit.section".
+ Ex: $ git config cgit.section mysection
+ An alternative to section-from-path, and will not check git config if
+ section-from-path is set. See also: scan-path. This must be defined prior
+ to scan-path.
+
side-by-side-diffs::
If set to "1" shows side-by-side diffs instead of unidiffs per
default. Default value: "0".
diff --git a/scan-tree.c b/scan-tree.c
index 3f579ec..3bbc4bc 100644
--- a/scan-tree.c
+++ b/scan-tree.c
@@ -61,6 +61,13 @@ static int git_owner_config(const char *key, const char *value, void *cb)
return 0;
}
+static int git_section_config(const char *key, const char *value, void *cb)
+{
+ if (!strcmp(key, "cgit.section"))
+ repo->section = xstrdup(value);
+ return 0;
+}
+
static char *xstrrchr(char *s, char *from, int c)
{
while (from >= s && *from != c)
@@ -149,6 +156,9 @@ static void add_repo(const char *base, const char *path, repo_config_fn fn)
}
}
}
+ else if (ctx.cfg.section_from_repo_config) {
+ git_config_from_file(git_section_config, fmt("%s/config", path), NULL);
+ }
p = fmt("%s/cgitrc", path);
if (!stat(p, &st)) {
--
1.7.5.4
next prev parent reply other threads:[~2011-06-03 23:21 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-03 23:21 [PATCH 0/2] Set section via " jamie.couture
2011-06-03 23:21 ` [PATCH 1/2] avoid memory leak jamie.couture
2011-06-06 16:57 ` larsh
2011-06-03 23:21 ` jamie.couture [this message]
2011-06-06 17:13 ` [PATCH 2/2] Add feature: obtain repo section from git config larsh
2011-06-06 17:38 ` mailings
2011-06-06 17:48 ` larsh
2011-06-06 18:18 ` mailings
2011-06-06 18:31 ` jamie.couture
2011-06-06 18:39 ` mailings
-- strict thread matches above, loose matches on Subject: below --
2011-06-03 13:54 [PATCH 1/2] avoid memory leak jamie.couture
2011-06-03 13:54 ` [PATCH 2/2] Add feature: obtain repo section from git config jamie.couture
[not found] <jamie.couture@gmail.com>
2011-06-02 23:40 ` [PATCH 1/2] avoid memory leak jamie.couture
2011-06-02 23:40 ` [PATCH 2/2] Add feature: obtain repo section from git config jamie.couture
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=1307143262-11018-3-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).