List for cgit developers and users
 help / color / mirror / Atom feed
From: plenz at cis.fu-berlin.de (Julius Plenz)
Subject: [PATCH 2/4] Introduce "dont-display-suffix" option
Date: Tue, 30 Oct 2012 14:07:16 +0100	[thread overview]
Message-ID: <1351602438-955878-3-git-send-email-plenz@cis.fu-berlin.de> (raw)
In-Reply-To: <1351602438-955878-1-git-send-email-plenz@cis.fu-berlin.de>

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 <plenz at cis.fu-berlin.de>
---
 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





  parent reply	other threads:[~2012-10-30 13:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-30 13:07 [PATCH 0/4] some miscellaneous features plenz
2012-10-30 13:07 ` [PATCH 1/4] tree view: imitate proper permissions plenz
2012-10-30 13:07 ` plenz [this message]
2012-11-01  4:03   ` [PATCH 2/4] Introduce "dont-display-suffix" option mathstuf
2012-11-01  4:22   ` Jason
2012-11-01 10:52     ` plenz
2012-10-30 13:07 ` [PATCH 3/4] Make number of columns in stat overview configurable plenz
2012-10-30 13:07 ` [PATCH 4/4] Introduce a fallback encoding (eg. for blobs) plenz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1351602438-955878-3-git-send-email-plenz@cis.fu-berlin.de \
    --to=cgit@lists.zx2c4.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).