From: john at keeping.me.uk (John Keeping)
Subject: [PATCH v2 2/3] ui-snapshot: pass repo into get_ref_from_filename()
Date: Sat, 31 Mar 2018 15:25:14 +0100 [thread overview]
Message-ID: <7af8b9272c3ac00a4177ada74a9f24c91123eb47.1522506154.git.john@keeping.me.uk> (raw)
In-Reply-To: <cover.1522506154.git.john@keeping.me.uk>
Prepare to allow a custom snapshot prefix.
Signed-off-by: John Keeping <john at keeping.me.uk>
---
v2: new patch
ui-snapshot.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/ui-snapshot.c b/ui-snapshot.c
index b2d95f7..237a75f 100644
--- a/ui-snapshot.c
+++ b/ui-snapshot.c
@@ -139,7 +139,8 @@ static int make_snapshot(const struct cgit_snapshot_format *format,
* pending a 'v' or a 'V' to the remaining snapshot name ("0.7.2" ->
* "v0.7.2") gives us something valid.
*/
-static const char *get_ref_from_filename(const char *url, const char *filename,
+static const char *get_ref_from_filename(const struct cgit_repo *repo,
+ const char *filename,
const struct cgit_snapshot_format *format)
{
const char *reponame;
@@ -153,7 +154,7 @@ static const char *get_ref_from_filename(const char *url, const char *filename,
if (get_oid(snapshot.buf, &oid) == 0)
goto out;
- reponame = cgit_repobasename(url);
+ reponame = cgit_repobasename(repo->url);
if (starts_with(snapshot.buf, reponame)) {
const char *new_start = snapshot.buf;
new_start += strlen(reponame);
@@ -200,7 +201,7 @@ void cgit_print_snapshot(const char *head, const char *hex,
}
if (!hex && dwim) {
- hex = get_ref_from_filename(ctx.repo->url, filename, f);
+ hex = get_ref_from_filename(ctx.repo, filename, f);
if (hex == NULL) {
cgit_print_error_page(404, "Not found", "Not found");
return;
--
2.16.3
next prev parent reply other threads:[~2018-03-31 14:25 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-31 13:36 [PATCH 0/2] Custom snapshot prefix john
2018-03-31 13:36 ` [PATCH 1/2] ui-shared: pass repo object to print_snapshot_links() john
2018-03-31 13:36 ` [PATCH 2/2] Add "snapshot-prefix" repo configuration john
2018-03-31 14:25 ` [PATCH v2 0/3] Custom snapshot prefix john
2018-03-31 14:25 ` [PATCH v2 1/3] ui-shared: pass repo object to print_snapshot_links() john
2018-03-31 14:25 ` john [this message]
2018-03-31 14:25 ` [PATCH v2 3/3] Add "snapshot-prefix" repo configuration john
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=7af8b9272c3ac00a4177ada74a9f24c91123eb47.1522506154.git.john@keeping.me.uk \
--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).