aboutsummaryrefslogtreecommitdiffstats
path: root/scan-tree.c
diff options
context:
space:
mode:
authorJason A. Donenfeld2012-07-11 04:24:01 +0200
committerJason A. Donenfeld2012-07-12 20:01:46 +0200
commitb56be4ba3a942dd1978fe4bfecd9afc35aab0027 (patch)
tree1f193f16b3b54e92d1a23a42ed3a9eced13acc0f /scan-tree.c
parent45555512ba63b823c6340875254563ea05737668 (diff)
downloadcgit-b56be4ba3a942dd1978fe4bfecd9afc35aab0027.tar.gz
cgit-b56be4ba3a942dd1978fe4bfecd9afc35aab0027.tar.bz2
cgit-b56be4ba3a942dd1978fe4bfecd9afc35aab0027.zip
scan-tree: Support gitweb.description.
Use gitweb.description instead of description file to determine description, if option is enabled.
Diffstat (limited to 'scan-tree.c')
-rw-r--r--scan-tree.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/scan-tree.c b/scan-tree.c
index 378d795..3d4e417 100644
--- a/scan-tree.c
+++ b/scan-tree.c
@@ -48,19 +48,24 @@ static int is_git_dir(const char *path)
48struct cgit_repo *repo; 48struct cgit_repo *repo;
49repo_config_fn config_fn; 49repo_config_fn config_fn;
50char *owner; 50char *owner;
51char *desc;
51 52
52static void repo_config(const char *name, const char *value) 53static void repo_config(const char *name, const char *value)
53{ 54{
54 config_fn(repo, name, value); 55 config_fn(repo, name, value);
55} 56}
56 57
57static int git_owner_config(const char *key, const char *value, void *cb) 58static int gitweb_config(const char *key, const char *value, void *cb)
58{ 59{
59 if (!strcmp(key, "gitweb.owner")) 60 if (ctx.cfg.enable_gitweb_owner && !strcmp(key, "gitweb.owner"))
60 owner = xstrdup(value); 61 owner = xstrdup(value);
62 else if (ctx.cfg.enable_gitweb_desc && !strcmp(key, "gitweb.description"))
63 desc = xstrdup(value);
61 return 0; 64 return 0;
62} 65}
63 66
67
68
64static char *xstrrchr(char *s, char *from, int c) 69static char *xstrrchr(char *s, char *from, int c)
65{ 70{
66 while (from >= s && *from != c) 71 while (from >= s && *from != c)
@@ -89,8 +94,9 @@ static void add_repo(const char *base, const char *path, repo_config_fn fn)
89 return; 94 return;
90 95
91 owner = NULL; 96 owner = NULL;
92 if (ctx.cfg.enable_gitweb_owner) 97 desc = NULL;
93 git_config_from_file(git_owner_config, fmt("%s/config", path), NULL); 98 git_config_from_file(gitweb_config, fmt("%s/config", path), NULL);
99
94 if (base == path) 100 if (base == path)
95 rel = xstrdup(fmt("%s", path)); 101 rel = xstrdup(fmt("%s", path));
96 else 102 else
@@ -118,9 +124,13 @@ static void add_repo(const char *base, const char *path, repo_config_fn fn)
118 } 124 }
119 repo->owner = owner; 125 repo->owner = owner;
120 126
121 p = fmt("%s/description", path); 127 if (desc)
122 if (!stat(p, &st)) 128 repo->desc = desc;
123 readfile(p, &repo->desc, &size); 129 else {
130 p = fmt("%s/description", path);
131 if (!stat(p, &st))
132 readfile(p, &repo->desc, &size);
133 }
124 134
125 if (!repo->readme) { 135 if (!repo->readme) {
126 p = fmt("%s/README.html", path); 136 p = fmt("%s/README.html", path);