summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--cgit.c8
-rw-r--r--cgit.h3
-rw-r--r--cgitrc.5.txt9
-rw-r--r--scan-tree.c30
-rw-r--r--scan-tree.h2
5 files changed, 39 insertions, 13 deletions
diff --git a/cgit.c b/cgit.c
index 90ae124..e281aa9 100644
--- a/cgit.c
+++ b/cgit.c
@@ -170,3 +170,3 @@ void config_cb(const char *name, const char *value)
170 else 170 else
171 scan_tree(value); 171 scan_tree(value, repo_config);
172 else if (!strcmp(name, "source-filter")) 172 else if (!strcmp(name, "source-filter"))
@@ -478,3 +478,3 @@ static int generate_cached_repolist(const char *path, const char *cached_rc)
478 idx = cgit_repolist.count; 478 idx = cgit_repolist.count;
479 scan_tree(path); 479 scan_tree(path, repo_config);
480 print_repolist(f, &cgit_repolist, idx); 480 print_repolist(f, &cgit_repolist, idx);
@@ -502,3 +502,3 @@ static void process_cached_repolist(const char *path)
502 if (generate_cached_repolist(path, cached_rc)) 502 if (generate_cached_repolist(path, cached_rc))
503 scan_tree(path); 503 scan_tree(path, repo_config);
504 return; 504 return;
@@ -561,3 +561,3 @@ static void cgit_parse_args(int argc, const char **argv)
561 scan++; 561 scan++;
562 scan_tree(argv[i] + 12); 562 scan_tree(argv[i] + 12, repo_config);
563 } 563 }
diff --git a/cgit.h b/cgit.h
index fc7c7d5..3359be9 100644
--- a/cgit.h
+++ b/cgit.h
@@ -81,2 +81,5 @@ struct cgit_repo {
81 81
82typedef void (*repo_config_fn)(struct cgit_repo *repo, const char *name,
83 const char *value);
84
82struct cgit_repolist { 85struct cgit_repolist {
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index e99c9f7..df494aa 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -328,2 +328,11 @@ repo.url::
328 328
329REPOSITORY-SPECIFIC CGITRC FILE
330-------------------------------
331When the option 'scan-path' is used to auto-discover git repositories, cgit
332will try to parse the file 'cgitrc' within any found repository. Such a repo-
333specific config file may contain any of the repo-specific options described
334above, except 'repo.url' and 'repo.path'. Also, in a repo-specific config
335file, the 'repo.' prefix is dropped from the config option names.
336
337
329EXAMPLE CGITRC FILE 338EXAMPLE CGITRC FILE
diff --git a/scan-tree.c b/scan-tree.c
index 67f4550..dbca797 100644
--- a/scan-tree.c
+++ b/scan-tree.c
@@ -1,2 +1,3 @@
1#include "cgit.h" 1#include "cgit.h"
2#include "configfile.h"
2#include "html.h" 3#include "html.h"
@@ -37,5 +38,12 @@ static int is_git_dir(const char *path)
37 38
38static void add_repo(const char *base, const char *path)
39{
40 struct cgit_repo *repo; 39 struct cgit_repo *repo;
40repo_config_fn config_fn;
41
42static void repo_config(const char *name, const char *value)
43{
44 config_fn(repo, name, value);
45}
46
47static void add_repo(const char *base, const char *path, repo_config_fn fn)
48{
41 struct stat st; 49 struct stat st;
@@ -78,5 +86,11 @@ static void add_repo(const char *base, const char *path)
78 repo->readme = "README.html"; 86 repo->readme = "README.html";
87
88 p = fmt("%s/cgitrc", path);
89 if (!stat(p, &st)) {
90 config_fn = fn;
91 parse_configfile(xstrdup(p), &repo_config);
92 }
79} 93}
80 94
81static void scan_path(const char *base, const char *path) 95static void scan_path(const char *base, const char *path, repo_config_fn fn)
82{ 96{
@@ -88,3 +102,3 @@ static void scan_path(const char *base, const char *path)
88 if (is_git_dir(path)) { 102 if (is_git_dir(path)) {
89 add_repo(base, path); 103 add_repo(base, path, fn);
90 return; 104 return;
@@ -92,3 +106,3 @@ static void scan_path(const char *base, const char *path)
92 if (is_git_dir(fmt("%s/.git", path))) { 106 if (is_git_dir(fmt("%s/.git", path))) {
93 add_repo(base, fmt("%s/.git", path)); 107 add_repo(base, fmt("%s/.git", path), fn);
94 return; 108 return;
@@ -122,3 +136,3 @@ static void scan_path(const char *base, const char *path)
122 if (S_ISDIR(st.st_mode)) 136 if (S_ISDIR(st.st_mode))
123 scan_path(base, buf); 137 scan_path(base, buf, fn);
124 free(buf); 138 free(buf);
@@ -128,5 +142,5 @@ static void scan_path(const char *base, const char *path)
128 142
129void scan_tree(const char *path) 143void scan_tree(const char *path, repo_config_fn fn)
130{ 144{
131 scan_path(path, path); 145 scan_path(path, path, fn);
132} 146}
diff --git a/scan-tree.h b/scan-tree.h
index b103b16..11539f4 100644
--- a/scan-tree.h
+++ b/scan-tree.h
@@ -2,2 +2,2 @@
2 2
3extern void scan_tree(const char *path); 3extern void scan_tree(const char *path, repo_config_fn fn);