diff options
author | Jason A. Donenfeld | 2012-07-11 04:24:01 +0200 |
---|---|---|
committer | Jason A. Donenfeld | 2012-07-12 20:01:46 +0200 |
commit | b56be4ba3a942dd1978fe4bfecd9afc35aab0027 (patch) | |
tree | 1f193f16b3b54e92d1a23a42ed3a9eced13acc0f /scan-tree.c | |
parent | 45555512ba63b823c6340875254563ea05737668 (diff) | |
download | cgit-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.c | 24 |
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) | |||
48 | struct cgit_repo *repo; | 48 | struct cgit_repo *repo; |
49 | repo_config_fn config_fn; | 49 | repo_config_fn config_fn; |
50 | char *owner; | 50 | char *owner; |
51 | char *desc; | ||
51 | 52 | ||
52 | static void repo_config(const char *name, const char *value) | 53 | static 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 | ||
57 | static int git_owner_config(const char *key, const char *value, void *cb) | 58 | static 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 | |||
64 | static char *xstrrchr(char *s, char *from, int c) | 69 | static 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); |