From: sebastian at breakpoint.cc (Sebastian Andrzej Siewior)
Subject: [PATCH 4/4] repolist: add a git link on front page
Date: Sat, 18 Jan 2014 21:25:00 +0100 [thread overview]
Message-ID: <1390076700-16626-5-git-send-email-sebastian@breakpoint.cc> (raw)
In-Reply-To: <1390076700-16626-1-git-send-email-sebastian@breakpoint.cc>
If links are enabled there will be an additinal "git" links next to
"summary log tree" _if_ the config has clone-prefix set or the
repository has clone_url set. In case the clone-prefix contains multiple
enties then only the first one will be considered.
The intention is to present the git:// link for a given repo early to the user.
Signed-off-by: Sebastian Andrzej Siewior <sebastian at breakpoint.cc>
---
ui-repolist.c | 1 +
ui-shared.c | 35 +++++++++++++++++++++++++++++++++++
ui-shared.h | 1 +
3 files changed, 37 insertions(+)
diff --git a/ui-repolist.c b/ui-repolist.c
index 477a949..b6d56ed 100644
--- a/ui-repolist.c
+++ b/ui-repolist.c
@@ -323,6 +323,7 @@ void cgit_print_repolist()
cgit_log_link("log", NULL, "button", NULL, NULL, NULL,
0, NULL, NULL, ctx.qry.showmsg);
cgit_tree_link("tree", NULL, "button", NULL, NULL, NULL);
+ cgit_git_link();
html("</td>");
}
html("</tr>\n");
diff --git a/ui-shared.c b/ui-shared.c
index 1ede2b0..5f80de9 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -284,6 +284,41 @@ void cgit_tree_link(const char *name, const char *title, const char *class,
reporevlink("tree", name, title, class, head, rev, path);
}
+void cgit_git_link(void)
+{
+ char *url = NULL;
+
+ if (ctx.repo->clone_url)
+ url = strdup(ctx.repo->clone_url);
+ else if (ctx.cfg.clone_prefix) {
+ char *second;
+ char *p;
+ int len;
+
+ p = ctx.cfg.clone_prefix;
+ while (*p == ' ')
+ p++;
+ second = strchr(p, ' ');
+ if (second)
+ *second = '\0';
+ len = snprintf(NULL, 0, "%s/%s", p, ctx.repo->url);
+ if (len < 0)
+ return;
+ len++;
+ url = xmalloc(len);
+ snprintf(url, len, "%s/%s", p, ctx.repo->url);
+ if (second)
+ *second = ' ';
+ }
+ if (!url)
+ return;
+ html("<a class='button'");
+ html(" href='");
+ html_url_path(url);
+ html("'>git</a>");
+ free(url);
+}
+
void cgit_plain_link(const char *name, const char *title, const char *class,
const char *head, const char *rev, const char *path)
{
diff --git a/ui-shared.h b/ui-shared.h
index 3e7a91b..2d5d9cd 100644
--- a/ui-shared.h
+++ b/ui-shared.h
@@ -21,6 +21,7 @@ extern void cgit_tag_link(const char *name, const char *title,
extern void cgit_tree_link(const char *name, const char *title,
const char *class, const char *head,
const char *rev, const char *path);
+extern void cgit_git_link(void);
extern void cgit_plain_link(const char *name, const char *title,
const char *class, const char *head,
const char *rev, const char *path);
--
1.8.5.2
next prev parent reply other threads:[~2014-01-18 20:25 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-18 20:24 my out-of-tree patches for cgit sebastian
2014-01-18 20:24 ` [PATCH 1/4] snapshots: Don't allow sneaked in snapshots requests sebastian
2014-02-01 14:54 ` sebastian
2014-02-02 14:49 ` cgit
2014-01-18 20:24 ` [PATCH 2/4] cache: use sendfile() instead of a pair of read() + write() sebastian
2014-01-18 21:32 ` jamie.couture
2014-01-19 14:12 ` Jason
2014-01-19 14:13 ` Jason
2014-01-19 15:17 ` Jason
2014-01-18 20:24 ` [PATCH 3/4] summary: Add tag head line in the dowload section sebastian
2014-01-19 14:17 ` Jason
2014-02-02 14:43 ` cgit
2014-01-18 20:25 ` sebastian [this message]
2014-01-19 14:19 ` [PATCH 4/4] repolist: add a git link on front page Jason
2014-02-01 14:53 ` sebastian
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=1390076700-16626-5-git-send-email-sebastian@breakpoint.cc \
--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).