summaryrefslogtreecommitdiffabout
Side-by-side diff
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
@@ -202,12 +202,14 @@ void config_cb(const char *name, const char *value)
else if (!strcmp(name, "side-by-side-diffs"))
ctx.cfg.ssdiff = atoi(value);
else if (!strcmp(name, "agefile"))
ctx.cfg.agefile = xstrdup(value);
else if (!strcmp(name, "renamelimit"))
ctx.cfg.renamelimit = atoi(value);
+ else if (!strcmp(name, "remove-suffix"))
+ ctx.cfg.remove_suffix = atoi(value);
else if (!strcmp(name, "robots"))
ctx.cfg.robots = xstrdup(value);
else if (!strcmp(name, "clone-prefix"))
ctx.cfg.clone_prefix = xstrdup(value);
else if (!strcmp(name, "local-time"))
ctx.cfg.local_time = atoi(value);
@@ -299,12 +301,13 @@ static void prepare_context(struct cgit_context *ctx)
ctx->cfg.max_repodesc_len = 80;
ctx->cfg.max_blob_size = 0;
ctx->cfg.max_stats = 0;
ctx->cfg.module_link = "./?repo=%s&page=commit&id=%s";
ctx->cfg.project_list = NULL;
ctx->cfg.renamelimit = -1;
+ ctx->cfg.remove_suffix = 0;
ctx->cfg.robots = "index, nofollow";
ctx->cfg.root_title = "Git repository browser";
ctx->cfg.root_desc = "a fast webinterface for the git dscm";
ctx->cfg.script_name = CGIT_SCRIPT_NAME;
ctx->cfg.section = "";
ctx->cfg.summary_branches = 10;
diff --git a/cgit.h b/cgit.h
index 4591f8c..ada8535 100644
--- a/cgit.h
+++ b/cgit.h
@@ -199,12 +199,13 @@ struct cgit_config {
int max_blob_size;
int max_stats;
int nocache;
int noplainemail;
int noheader;
int renamelimit;
+ int remove_suffix;
int snapshots;
int summary_branches;
int summary_log;
int summary_tags;
int ssdiff;
struct string_list mimetypes;
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index ec004d4..6fb1083 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -226,12 +226,17 @@ noheader::
project-list::
A list of subdirectories inside of scan-path, relative to it, that
should loaded as git repositories. This must be defined prior to
scan-path. Default value: none. See also: scan-path.
+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::
Maximum number of files to consider when detecting renames. The value
"-1" uses the compiletime value in git (for further info, look at
`man git-diff`). Default value: "-1".
repo.group::
@@ -535,6 +540,7 @@ will generate the following html element:
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
@@ -78,12 +78,15 @@ static void add_repo(const char *base, const char *path, repo_config_fn fn)
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) : "");