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) (side-by-side diff) | |
tree | 505c17fab5afcb99cfddf2c4aad0b95c8670f001 /scan-tree.c | |
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-- | scan-tree.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/scan-tree.c b/scan-tree.c index 9bf9b38..a83a78c 100644 --- a/scan-tree.c +++ b/scan-tree.c @@ -72,24 +72,27 @@ static void add_repo(const char *base, const char *path, repo_config_fn fn) path, strerror(errno), errno); return; } if (base == path) p = fmt("%s", path); else p = fmt("%s", path + strlen(base) + 1); if (!strcmp(p + strlen(p) - 5, "/.git")) p[strlen(p) - 5] = '\0'; repo = cgit_add_repo(xstrdup(p)); + if (ctx.cfg.remove_suffix) + if ((p = strrchr(repo->url, '.')) && !strcmp(p, ".git")) + *p = '\0'; repo->name = repo->url; repo->path = xstrdup(path); p = (pwd && pwd->pw_gecos) ? strchr(pwd->pw_gecos, ',') : NULL; if (p) *p = '\0'; repo->owner = (pwd ? xstrdup(pwd->pw_gecos ? pwd->pw_gecos : pwd->pw_name) : ""); p = fmt("%s/description", path); if (!stat(p, &st)) readfile(p, &repo->desc, &size); p = fmt("%s/README.html", path); |