author | Jason A. Donenfeld <Jason@zx2c4.com> | 2010-07-29 17:47:50 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2010-08-04 01:09:32 (UTC) |
commit | 2e4a941626c240bc7858aa7564882c01f657f4e8 (patch) (unidiff) | |
tree | 505c17fab5afcb99cfddf2c4aad0b95c8670f001 | |
parent | 3516502aa0df95ecc241caa30161741f59e4e600 (diff) | |
download | cgit-2e4a941626c240bc7858aa7564882c01f657f4e8.zip cgit-2e4a941626c240bc7858aa7564882c01f657f4e8.tar.gz cgit-2e4a941626c240bc7858aa7564882c01f657f4e8.tar.bz2 |
Add support for 'remove-suffix' option
When this option is enabled, the '.git' suffix of repository directories
found while processing the 'scan-path' option will be removed.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | cgit.c | 3 | ||||
-rw-r--r-- | cgit.h | 1 | ||||
-rw-r--r-- | cgitrc.5.txt | 6 | ||||
-rw-r--r-- | scan-tree.c | 3 |
4 files changed, 13 insertions, 0 deletions
@@ -205,6 +205,8 @@ void config_cb(const char *name, const char *value) | |||
205 | ctx.cfg.agefile = xstrdup(value); | 205 | ctx.cfg.agefile = xstrdup(value); |
206 | else if (!strcmp(name, "renamelimit")) | 206 | else if (!strcmp(name, "renamelimit")) |
207 | ctx.cfg.renamelimit = atoi(value); | 207 | ctx.cfg.renamelimit = atoi(value); |
208 | else if (!strcmp(name, "remove-suffix")) | ||
209 | ctx.cfg.remove_suffix = atoi(value); | ||
208 | else if (!strcmp(name, "robots")) | 210 | else if (!strcmp(name, "robots")) |
209 | ctx.cfg.robots = xstrdup(value); | 211 | ctx.cfg.robots = xstrdup(value); |
210 | else if (!strcmp(name, "clone-prefix")) | 212 | else if (!strcmp(name, "clone-prefix")) |
@@ -302,6 +304,7 @@ static void prepare_context(struct cgit_context *ctx) | |||
302 | ctx->cfg.module_link = "./?repo=%s&page=commit&id=%s"; | 304 | ctx->cfg.module_link = "./?repo=%s&page=commit&id=%s"; |
303 | ctx->cfg.project_list = NULL; | 305 | ctx->cfg.project_list = NULL; |
304 | ctx->cfg.renamelimit = -1; | 306 | ctx->cfg.renamelimit = -1; |
307 | ctx->cfg.remove_suffix = 0; | ||
305 | ctx->cfg.robots = "index, nofollow"; | 308 | ctx->cfg.robots = "index, nofollow"; |
306 | ctx->cfg.root_title = "Git repository browser"; | 309 | ctx->cfg.root_title = "Git repository browser"; |
307 | ctx->cfg.root_desc = "a fast webinterface for the git dscm"; | 310 | ctx->cfg.root_desc = "a fast webinterface for the git dscm"; |
@@ -202,6 +202,7 @@ struct cgit_config { | |||
202 | int noplainemail; | 202 | int noplainemail; |
203 | int noheader; | 203 | int noheader; |
204 | int renamelimit; | 204 | int renamelimit; |
205 | int remove_suffix; | ||
205 | int snapshots; | 206 | int snapshots; |
206 | int summary_branches; | 207 | int summary_branches; |
207 | int summary_log; | 208 | int summary_log; |
diff --git a/cgitrc.5.txt b/cgitrc.5.txt index ec004d4..6fb1083 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt | |||
@@ -229,6 +229,11 @@ project-list:: | |||
229 | should loaded as git repositories. This must be defined prior to | 229 | should loaded as git repositories. This must be defined prior to |
230 | scan-path. Default value: none. See also: scan-path. | 230 | scan-path. Default value: none. See also: scan-path. |
231 | 231 | ||
232 | remove-suffix:: | ||
233 | If set to "1" and scan-path is enabled, if any repositories are found | ||
234 | with a suffix of ".git", this suffix will be removed for the url and | ||
235 | name. Default value: "0". See also: scan-path. | ||
236 | |||
232 | renamelimit:: | 237 | renamelimit:: |
233 | Maximum number of files to consider when detecting renames. The value | 238 | Maximum number of files to consider when detecting renames. The value |
234 | "-1" uses the compiletime value in git (for further info, look at | 239 | "-1" uses the compiletime value in git (for further info, look at |
@@ -538,3 +543,4 @@ will generate the following html element: | |||
538 | AUTHOR | 543 | AUTHOR |
539 | ------ | 544 | ------ |
540 | Lars Hjemli <hjemli@gmail.com> | 545 | Lars Hjemli <hjemli@gmail.com> |
546 | Jason A. Donenfeld <Jason@zx2c4.com> | ||
diff --git a/scan-tree.c b/scan-tree.c index 9bf9b38..a83a78c 100644 --- a/scan-tree.c +++ b/scan-tree.c | |||
@@ -81,6 +81,9 @@ static void add_repo(const char *base, const char *path, repo_config_fn fn) | |||
81 | p[strlen(p) - 5] = '\0'; | 81 | p[strlen(p) - 5] = '\0'; |
82 | 82 | ||
83 | repo = cgit_add_repo(xstrdup(p)); | 83 | repo = cgit_add_repo(xstrdup(p)); |
84 | if (ctx.cfg.remove_suffix) | ||
85 | if ((p = strrchr(repo->url, '.')) && !strcmp(p, ".git")) | ||
86 | *p = '\0'; | ||
84 | repo->name = repo->url; | 87 | repo->name = repo->url; |
85 | repo->path = xstrdup(path); | 88 | repo->path = xstrdup(path); |
86 | p = (pwd && pwd->pw_gecos) ? strchr(pwd->pw_gecos, ',') : NULL; | 89 | p = (pwd && pwd->pw_gecos) ? strchr(pwd->pw_gecos, ',') : NULL; |