about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--cgit.c3
-rw-r--r--cgit.h1
-rw-r--r--cgitrc.5.txt7
-rw-r--r--scan-tree.c24
4 files changed, 28 insertions, 7 deletions
diff --git a/cgit.c b/cgit.c index b9b3a66..ec5bbce 100644 --- a/cgit.c +++ b/cgit.c
@@ -163,6 +163,8 @@ void config_cb(const char *name, const char *value)
163 ctx.cfg.snapshots = cgit_parse_snapshots_mask(value); 163 ctx.cfg.snapshots = cgit_parse_snapshots_mask(value);
164 else if (!strcmp(name, "enable-filter-overrides")) 164 else if (!strcmp(name, "enable-filter-overrides"))
165 ctx.cfg.enable_filter_overrides = atoi(value); 165 ctx.cfg.enable_filter_overrides = atoi(value);
166 else if (!strcmp(name, "enable-gitweb-desc"))
167 ctx.cfg.enable_gitweb_desc = atoi(value);
166 else if (!strcmp(name, "enable-gitweb-owner")) 168 else if (!strcmp(name, "enable-gitweb-owner"))
167 ctx.cfg.enable_gitweb_owner = atoi(value); 169 ctx.cfg.enable_gitweb_owner = atoi(value);
168 else if (!strcmp(name, "enable-http-clone")) 170 else if (!strcmp(name, "enable-http-clone"))
@@ -336,6 +338,7 @@ static void prepare_context(struct cgit_context *ctx)
336 ctx->cfg.css = "/cgit.css"; 338 ctx->cfg.css = "/cgit.css";
337 ctx->cfg.logo = "/cgit.png"; 339 ctx->cfg.logo = "/cgit.png";
338 ctx->cfg.local_time = 0; 340 ctx->cfg.local_time = 0;
341 ctx->cfg.enable_gitweb_desc = 1;
339 ctx->cfg.enable_gitweb_owner = 1; 342 ctx->cfg.enable_gitweb_owner = 1;
340 ctx->cfg.enable_http_clone = 1; 343 ctx->cfg.enable_http_clone = 1;
341 ctx->cfg.enable_tree_linenumbers = 1; 344 ctx->cfg.enable_tree_linenumbers = 1;
diff --git a/cgit.h b/cgit.h index 6ee6769..f4d0e52 100644 --- a/cgit.h +++ b/cgit.h
@@ -199,6 +199,7 @@ struct cgit_config {
199 int embedded; 199 int embedded;
200 int enable_filter_overrides; 200 int enable_filter_overrides;
201 int enable_gitweb_owner; 201 int enable_gitweb_owner;
202 int enable_gitweb_desc;
202 int enable_http_clone; 203 int enable_http_clone;
203 int enable_index_links; 204 int enable_index_links;
204 int enable_commit_graph; 205 int enable_commit_graph;
diff --git a/cgitrc.5.txt b/cgitrc.5.txt index a72241f..86a19a9 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt
@@ -106,6 +106,13 @@ enable-filter-overrides::
106 Flag which, when set to "1", allows all filter settings to be 106 Flag which, when set to "1", allows all filter settings to be
107 overridden in repository-specific cgitrc files. Default value: none. 107 overridden in repository-specific cgitrc files. Default value: none.
108 108
109enable-gitweb-desc::
110 If set to "1" and scan-path is enabled, we first check each repository
111 for the git config value "gitweb.description" to determine the owner.
112 Otherwise, the description is read from a file titled "description"
113 inside of the repository directory.
114 Default value: "1". See also: scan-path.
115
109enable-gitweb-owner:: 116enable-gitweb-owner::
110 If set to "1" and scan-path is enabled, we first check each repository 117 If set to "1" and scan-path is enabled, we first check each repository
111 for the git config value "gitweb.owner" to determine the owner. 118 for the git config value "gitweb.owner" to determine the owner.
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);