This will make the scan-path run return a repository name without .git suffix (as remove-suffix would do), but leaves this suffix in the URL parameter.
Signed-off-by: Julius Plenz <[email protected]> --- cgit.c | 2 ++ cgit.h | 1 + scan-tree.c | 11 ++++++++--- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/cgit.c b/cgit.c index b9b3a66..f1105fb 100644 --- a/cgit.c +++ b/cgit.c @@ -247,6 +247,8 @@ 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, "dont-display-suffix")) + ctx.cfg.dont_display_suffix = atoi(value); else if (!strcmp(name, "robots")) ctx.cfg.robots = xstrdup(value); else if (!strcmp(name, "clone-prefix")) diff --git a/cgit.h b/cgit.h index 6ee6769..5692224 100644 --- a/cgit.h +++ b/cgit.h @@ -221,6 +221,7 @@ struct cgit_config { int noheader; int renamelimit; int remove_suffix; + int dont_display_suffix; int scan_hidden_path; int section_from_path; int snapshots; diff --git a/scan-tree.c b/scan-tree.c index 378d795..e33927e 100644 --- a/scan-tree.c +++ b/scan-tree.c @@ -100,10 +100,15 @@ static void add_repo(const char *base, const char *path, repo_config_fn fn) rel[strlen(rel) - 5] = '\0'; repo = cgit_add_repo(rel); - if (ctx.cfg.remove_suffix) - if ((p = strrchr(repo->url, '.')) && !strcmp(p, ".git")) + if ((p = strrchr(repo->url, '.')) && !strcmp(p, ".git")) { + if (ctx.cfg.remove_suffix) *p = '\0'; - repo->name = repo->url; + else if (ctx.cfg.dont_display_suffix) { + repo->name = xstrdup(repo->url); + repo->name[strlen(repo->name) - 4] = '\0'; + } + } else + repo->name = repo->url; repo->path = xstrdup(path); while (!owner) { if ((pwd = getpwuid(st.st_uid)) == NULL) { -- 1.7.12.3-zedat _______________________________________________ cgit mailing list [email protected] http://hjemli.net/mailman/listinfo/cgit
