summaryrefslogtreecommitdiffabout
authorJason 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)
commit2e4a941626c240bc7858aa7564882c01f657f4e8 (patch) (side-by-side diff)
tree505c17fab5afcb99cfddf2c4aad0b95c8670f001
parent3516502aa0df95ecc241caa30161741f59e4e600 (diff)
downloadcgit-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>
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--cgit.c3
-rw-r--r--cgit.h1
-rw-r--r--cgitrc.5.txt6
-rw-r--r--scan-tree.c3
4 files changed, 13 insertions, 0 deletions
diff --git a/cgit.c b/cgit.c
index 2364d1c..f9a42bb 100644
--- a/cgit.c
+++ b/cgit.c
@@ -207,2 +207,4 @@ void config_cb(const char *name, const char *value)
ctx.cfg.renamelimit = atoi(value);
+ else if (!strcmp(name, "remove-suffix"))
+ ctx.cfg.remove_suffix = atoi(value);
else if (!strcmp(name, "robots"))
@@ -304,2 +306,3 @@ static void prepare_context(struct cgit_context *ctx)
ctx->cfg.renamelimit = -1;
+ ctx->cfg.remove_suffix = 0;
ctx->cfg.robots = "index, nofollow";
diff --git a/cgit.h b/cgit.h
index 4591f8c..ada8535 100644
--- a/cgit.h
+++ b/cgit.h
@@ -204,2 +204,3 @@ struct cgit_config {
int renamelimit;
+ int remove_suffix;
int snapshots;
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index ec004d4..6fb1083 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -231,2 +231,7 @@ project-list::
+remove-suffix::
+ If set to "1" and scan-path is enabled, if any repositories are found
+ with a suffix of ".git", this suffix will be removed for the url and
+ name. Default value: "0". See also: scan-path.
+
renamelimit::
@@ -540 +545,2 @@ AUTHOR
Lars Hjemli <hjemli@gmail.com>
+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
@@ -83,2 +83,5 @@ static void add_repo(const char *base, const char *path, repo_config_fn fn)
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;