List for cgit developers and users
 help / color / mirror / Atom feed
* [PATCH 0/2] Custom snapshot prefix
@ 2018-03-31 13:36 john
  2018-03-31 13:36 ` [PATCH 1/2] ui-shared: pass repo object to print_snapshot_links() john
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: john @ 2018-03-31 13:36 UTC (permalink / raw)


This isn't the mechanism Konstantin asked for, but for this particular
feature I think this is a better way of achieving the same effect.

I don't see much need for a per-tag configuration option for the
snapshot prefix, so this enables it only at the repository level.
Please let me know if I've missed something here!

John Keeping (2):
  ui-shared: pass repo object to print_snapshot_links()
  Add "snapshot-prefix" repo configuration

 cgit.c       |  2 ++
 cgit.h       |  1 +
 cgitrc.5.txt |  7 +++++++
 ui-commit.c  |  3 +--
 ui-refs.c    |  2 +-
 ui-shared.c  | 16 ++++++++++++----
 ui-shared.h  |  5 +++--
 ui-tag.c     |  3 +--
 8 files changed, 28 insertions(+), 11 deletions(-)

-- 
2.14.1.555.g1b9dbff880.dirty



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/2] ui-shared: pass repo object to print_snapshot_links()
  2018-03-31 13:36 [PATCH 0/2] Custom snapshot prefix john
@ 2018-03-31 13:36 ` 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
  2 siblings, 0 replies; 7+ messages in thread
From: john @ 2018-03-31 13:36 UTC (permalink / raw)


Both call sites of cgit_print_snapshot_links() use the same values for
the snapshot mask and repository name, which are derived from the
cgit_repo structure so let's pass in the structure and access the fields
directly.

Signed-off-by: John Keeping <john at keeping.me.uk>
---
 ui-commit.c | 3 +--
 ui-shared.c | 8 ++++----
 ui-shared.h | 4 ++--
 ui-tag.c    | 3 +--
 4 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/ui-commit.c b/ui-commit.c
index abf58f6..ea17461 100644
--- a/ui-commit.c
+++ b/ui-commit.c
@@ -110,8 +110,7 @@ void cgit_print_commit(char *hex, const char *prefix)
 	}
 	if (ctx.repo->snapshots) {
 		html("<tr><th>download</th><td colspan='2' class='sha1'>");
-		cgit_print_snapshot_links(ctx.qry.repo, ctx.qry.head,
-					  hex, ctx.repo->snapshots);
+		cgit_print_snapshot_links(ctx.repo, ctx.qry.head, hex);
 		html("</td></tr>");
 	}
 	html("</table>\n");
diff --git a/ui-shared.c b/ui-shared.c
index 9d8f66b..da92594 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -1102,17 +1102,17 @@ void cgit_compose_snapshot_prefix(struct strbuf *filename, const char *base,
 	strbuf_addf(filename, "%s-%s", base, ref);
 }
 
-void cgit_print_snapshot_links(const char *repo, const char *head,
-			       const char *hex, int snapshots)
+void cgit_print_snapshot_links(const struct cgit_repo *repo, const char *head,
+			       const char *hex)
 {
 	const struct cgit_snapshot_format* f;
 	struct strbuf filename = STRBUF_INIT;
 	size_t prefixlen;
 
-	cgit_compose_snapshot_prefix(&filename, cgit_repobasename(repo), hex);
+	cgit_compose_snapshot_prefix(&filename, cgit_repobasename(repo->url), hex);
 	prefixlen = filename.len;
 	for (f = cgit_snapshot_formats; f->suffix; f++) {
-		if (!(snapshots & f->bit))
+		if (!(repo->snapshots & f->bit))
 			continue;
 		strbuf_setlen(&filename, prefixlen);
 		strbuf_addstr(&filename, f->suffix);
diff --git a/ui-shared.h b/ui-shared.h
index b760a17..b3eb8c5 100644
--- a/ui-shared.h
+++ b/ui-shared.h
@@ -76,8 +76,8 @@ extern void cgit_print_pageheader(void);
 extern void cgit_print_filemode(unsigned short mode);
 extern void cgit_compose_snapshot_prefix(struct strbuf *filename,
 					 const char *base, const char *ref);
-extern void cgit_print_snapshot_links(const char *repo, const char *head,
-				      const char *hex, int snapshots);
+extern void cgit_print_snapshot_links(const struct cgit_repo *repo,
+				      const char *head, const char *hex);
 extern void cgit_add_hidden_formfields(int incl_head, int incl_search,
 				       const char *page);
 
diff --git a/ui-tag.c b/ui-tag.c
index 909cde0..a7c44c0 100644
--- a/ui-tag.c
+++ b/ui-tag.c
@@ -34,8 +34,7 @@ static void print_tag_content(char *buf)
 static void print_download_links(char *revname)
 {
 	html("<tr><th>download</th><td class='sha1'>");
-	cgit_print_snapshot_links(ctx.qry.repo, ctx.qry.head,
-				  revname, ctx.repo->snapshots);
+	cgit_print_snapshot_links(ctx.repo, ctx.qry.head, revname);
 	html("</td></tr>");
 }
 
-- 
2.14.1.555.g1b9dbff880.dirty



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 2/2] Add "snapshot-prefix" repo configuration
  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 ` john
  2018-03-31 14:25 ` [PATCH v2 0/3] Custom snapshot prefix john
  2 siblings, 0 replies; 7+ messages in thread
From: john @ 2018-03-31 13:36 UTC (permalink / raw)


Allow using a user-specified value for the prefix in snapshot files
instead of the repository basename.  For example, files downloaded from
the linux-stable.git repository should be named linux-$VERSION and not
linux-stable-$VERSION, which can be achieved by setting:

	repo.snapshot-prefix=linux

Signed-off-by: John Keeping <john at keeping.me.uk>
---
 cgit.c       |  2 ++
 cgit.h       |  1 +
 cgitrc.5.txt |  7 +++++++
 ui-refs.c    |  2 +-
 ui-shared.c  | 10 +++++++++-
 ui-shared.h  |  1 +
 6 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/cgit.c b/cgit.c
index bd9cb3f..d2f7b9c 100644
--- a/cgit.c
+++ b/cgit.c
@@ -79,6 +79,8 @@ static void repo_config(struct cgit_repo *repo, const char *name, const char *va
 		item->util = xstrdup(value);
 	} else if (!strcmp(name, "section"))
 		repo->section = xstrdup(value);
+	else if (!strcmp(name, "snapshot-prefix"))
+		repo->snapshot_prefix = xstrdup(value);
 	else if (!strcmp(name, "readme") && value != NULL) {
 		if (repo->readme.items == ctx.cfg.readme.items)
 			memset(&repo->readme, 0, sizeof(repo->readme));
diff --git a/cgit.h b/cgit.h
index 005ae63..847cd2e 100644
--- a/cgit.h
+++ b/cgit.h
@@ -88,6 +88,7 @@ struct cgit_repo {
 	char *clone_url;
 	char *logo;
 	char *logo_link;
+	char *snapshot_prefix;
 	int snapshots;
 	int enable_commit_graph;
 	int enable_log_filecount;
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index 4da166c..a9d3d0a 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -599,6 +599,13 @@ repo.snapshots::
 	restricted by the global "snapshots" setting. Default value:
 	<snapshots>.
 
+repo.snapshot-prefix::
+	Prefix to use for snapshot links instead of the repository basename.
+	For example, the "linux-stable" repository may wish to set this to
+	"linux" so that snapshots are in the format "linux-3.15.4" instead
+	of "linux-stable-3.15.4".  Default value: <empty> meaning to use
+	the repository basename.
+
 repo.section::
 	Override the current section name for this repository. Default value:
 	none.
diff --git a/ui-refs.c b/ui-refs.c
index 75f2789..50d9d30 100644
--- a/ui-refs.c
+++ b/ui-refs.c
@@ -100,7 +100,7 @@ static void print_tag_downloads(const struct cgit_repo *repo, const char *ref)
 	if (!ref || strlen(ref) < 1)
 		return;
 
-	basename = cgit_repobasename(repo->url);
+	basename = cgit_snapshot_prefix(repo);
 	if (starts_with(ref, basename))
 		strbuf_addstr(&filename, ref);
 	else
diff --git a/ui-shared.c b/ui-shared.c
index da92594..df9bbbf 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -151,6 +151,14 @@ const char *cgit_repobasename(const char *reponame)
 	return rvbuf;
 }
 
+const char *cgit_snapshot_prefix(const struct cgit_repo *repo)
+{
+	if (repo->snapshot_prefix)
+		return repo->snapshot_prefix;
+
+	return cgit_repobasename(repo->url);
+}
+
 static void site_url(const char *page, const char *search, const char *sort, int ofs, int always_root)
 {
 	char *delim = "?";
@@ -1109,7 +1117,7 @@ void cgit_print_snapshot_links(const struct cgit_repo *repo, const char *head,
 	struct strbuf filename = STRBUF_INIT;
 	size_t prefixlen;
 
-	cgit_compose_snapshot_prefix(&filename, cgit_repobasename(repo->url), hex);
+	cgit_compose_snapshot_prefix(&filename, cgit_snapshot_prefix(repo), hex);
 	prefixlen = filename.len;
 	for (f = cgit_snapshot_formats; f->suffix; f++) {
 		if (!(repo->snapshots & f->bit))
diff --git a/ui-shared.h b/ui-shared.h
index b3eb8c5..92a1755 100644
--- a/ui-shared.h
+++ b/ui-shared.h
@@ -78,6 +78,7 @@ extern void cgit_compose_snapshot_prefix(struct strbuf *filename,
 					 const char *base, const char *ref);
 extern void cgit_print_snapshot_links(const struct cgit_repo *repo,
 				      const char *head, const char *hex);
+extern const char *cgit_snapshot_prefix(const struct cgit_repo *repo);
 extern void cgit_add_hidden_formfields(int incl_head, int incl_search,
 				       const char *page);
 
-- 
2.14.1.555.g1b9dbff880.dirty



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 0/3] Custom snapshot prefix
  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 ` john
  2018-03-31 14:25   ` [PATCH v2 1/3] ui-shared: pass repo object to print_snapshot_links() john
                     ` (2 more replies)
  2 siblings, 3 replies; 7+ messages in thread
From: john @ 2018-03-31 14:25 UTC (permalink / raw)


It turns out I should have tested whether downloads with a custom prefix
actually work... they didn't!

v2 adds a new refactoring patch in the middle and ensures that we update
the request handling logic in the final patch.

John Keeping (3):
  ui-shared: pass repo object to print_snapshot_links()
  ui-snapshot: pass repo into get_ref_from_filename()
  Add "snapshot-prefix" repo configuration

 cgit.c        |  2 ++
 cgit.h        |  1 +
 cgitrc.5.txt  |  7 +++++++
 ui-commit.c   |  3 +--
 ui-refs.c     |  2 +-
 ui-shared.c   | 16 ++++++++++++----
 ui-shared.h   |  5 +++--
 ui-snapshot.c |  9 +++++----
 ui-tag.c      |  3 +--
 9 files changed, 33 insertions(+), 15 deletions(-)

-- 
2.16.3



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 1/3] ui-shared: pass repo object to print_snapshot_links()
  2018-03-31 14:25 ` [PATCH v2 0/3] Custom snapshot prefix john
@ 2018-03-31 14:25   ` john
  2018-03-31 14:25   ` [PATCH v2 2/3] ui-snapshot: pass repo into get_ref_from_filename() john
  2018-03-31 14:25   ` [PATCH v2 3/3] Add "snapshot-prefix" repo configuration john
  2 siblings, 0 replies; 7+ messages in thread
From: john @ 2018-03-31 14:25 UTC (permalink / raw)


Both call sites of cgit_print_snapshot_links() use the same values for
the snapshot mask and repository name, which are derived from the
cgit_repo structure so let's pass in the structure and access the fields
directly.

Signed-off-by: John Keeping <john at keeping.me.uk>
---
v2: unchanged

 ui-commit.c | 3 +--
 ui-shared.c | 8 ++++----
 ui-shared.h | 4 ++--
 ui-tag.c    | 3 +--
 4 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/ui-commit.c b/ui-commit.c
index abf58f6..ea17461 100644
--- a/ui-commit.c
+++ b/ui-commit.c
@@ -110,8 +110,7 @@ void cgit_print_commit(char *hex, const char *prefix)
 	}
 	if (ctx.repo->snapshots) {
 		html("<tr><th>download</th><td colspan='2' class='sha1'>");
-		cgit_print_snapshot_links(ctx.qry.repo, ctx.qry.head,
-					  hex, ctx.repo->snapshots);
+		cgit_print_snapshot_links(ctx.repo, ctx.qry.head, hex);
 		html("</td></tr>");
 	}
 	html("</table>\n");
diff --git a/ui-shared.c b/ui-shared.c
index 9d8f66b..da92594 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -1102,17 +1102,17 @@ void cgit_compose_snapshot_prefix(struct strbuf *filename, const char *base,
 	strbuf_addf(filename, "%s-%s", base, ref);
 }
 
-void cgit_print_snapshot_links(const char *repo, const char *head,
-			       const char *hex, int snapshots)
+void cgit_print_snapshot_links(const struct cgit_repo *repo, const char *head,
+			       const char *hex)
 {
 	const struct cgit_snapshot_format* f;
 	struct strbuf filename = STRBUF_INIT;
 	size_t prefixlen;
 
-	cgit_compose_snapshot_prefix(&filename, cgit_repobasename(repo), hex);
+	cgit_compose_snapshot_prefix(&filename, cgit_repobasename(repo->url), hex);
 	prefixlen = filename.len;
 	for (f = cgit_snapshot_formats; f->suffix; f++) {
-		if (!(snapshots & f->bit))
+		if (!(repo->snapshots & f->bit))
 			continue;
 		strbuf_setlen(&filename, prefixlen);
 		strbuf_addstr(&filename, f->suffix);
diff --git a/ui-shared.h b/ui-shared.h
index b760a17..b3eb8c5 100644
--- a/ui-shared.h
+++ b/ui-shared.h
@@ -76,8 +76,8 @@ extern void cgit_print_pageheader(void);
 extern void cgit_print_filemode(unsigned short mode);
 extern void cgit_compose_snapshot_prefix(struct strbuf *filename,
 					 const char *base, const char *ref);
-extern void cgit_print_snapshot_links(const char *repo, const char *head,
-				      const char *hex, int snapshots);
+extern void cgit_print_snapshot_links(const struct cgit_repo *repo,
+				      const char *head, const char *hex);
 extern void cgit_add_hidden_formfields(int incl_head, int incl_search,
 				       const char *page);
 
diff --git a/ui-tag.c b/ui-tag.c
index 909cde0..a7c44c0 100644
--- a/ui-tag.c
+++ b/ui-tag.c
@@ -34,8 +34,7 @@ static void print_tag_content(char *buf)
 static void print_download_links(char *revname)
 {
 	html("<tr><th>download</th><td class='sha1'>");
-	cgit_print_snapshot_links(ctx.qry.repo, ctx.qry.head,
-				  revname, ctx.repo->snapshots);
+	cgit_print_snapshot_links(ctx.repo, ctx.qry.head, revname);
 	html("</td></tr>");
 }
 
-- 
2.16.3



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 2/3] ui-snapshot: pass repo into get_ref_from_filename()
  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
  2018-03-31 14:25   ` [PATCH v2 3/3] Add "snapshot-prefix" repo configuration john
  2 siblings, 0 replies; 7+ messages in thread
From: john @ 2018-03-31 14:25 UTC (permalink / raw)


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



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 3/3] Add "snapshot-prefix" repo configuration
  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   ` [PATCH v2 2/3] ui-snapshot: pass repo into get_ref_from_filename() john
@ 2018-03-31 14:25   ` john
  2 siblings, 0 replies; 7+ messages in thread
From: john @ 2018-03-31 14:25 UTC (permalink / raw)


Allow using a user-specified value for the prefix in snapshot files
instead of the repository basename.  For example, files downloaded from
the linux-stable.git repository should be named linux-$VERSION and not
linux-stable-$VERSION, which can be achieved by setting:

	repo.snapshot-prefix=linux

Signed-off-by: John Keeping <john at keeping.me.uk>
---
v2:
- also update request handling in ui-snapshot.c

 cgit.c        |  2 ++
 cgit.h        |  1 +
 cgitrc.5.txt  |  7 +++++++
 ui-refs.c     |  2 +-
 ui-shared.c   | 10 +++++++++-
 ui-shared.h   |  1 +
 ui-snapshot.c |  4 ++--
 7 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/cgit.c b/cgit.c
index bd9cb3f..d2f7b9c 100644
--- a/cgit.c
+++ b/cgit.c
@@ -79,6 +79,8 @@ static void repo_config(struct cgit_repo *repo, const char *name, const char *va
 		item->util = xstrdup(value);
 	} else if (!strcmp(name, "section"))
 		repo->section = xstrdup(value);
+	else if (!strcmp(name, "snapshot-prefix"))
+		repo->snapshot_prefix = xstrdup(value);
 	else if (!strcmp(name, "readme") && value != NULL) {
 		if (repo->readme.items == ctx.cfg.readme.items)
 			memset(&repo->readme, 0, sizeof(repo->readme));
diff --git a/cgit.h b/cgit.h
index 005ae63..847cd2e 100644
--- a/cgit.h
+++ b/cgit.h
@@ -88,6 +88,7 @@ struct cgit_repo {
 	char *clone_url;
 	char *logo;
 	char *logo_link;
+	char *snapshot_prefix;
 	int snapshots;
 	int enable_commit_graph;
 	int enable_log_filecount;
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index 4da166c..a9d3d0a 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -599,6 +599,13 @@ repo.snapshots::
 	restricted by the global "snapshots" setting. Default value:
 	<snapshots>.
 
+repo.snapshot-prefix::
+	Prefix to use for snapshot links instead of the repository basename.
+	For example, the "linux-stable" repository may wish to set this to
+	"linux" so that snapshots are in the format "linux-3.15.4" instead
+	of "linux-stable-3.15.4".  Default value: <empty> meaning to use
+	the repository basename.
+
 repo.section::
 	Override the current section name for this repository. Default value:
 	none.
diff --git a/ui-refs.c b/ui-refs.c
index 75f2789..50d9d30 100644
--- a/ui-refs.c
+++ b/ui-refs.c
@@ -100,7 +100,7 @@ static void print_tag_downloads(const struct cgit_repo *repo, const char *ref)
 	if (!ref || strlen(ref) < 1)
 		return;
 
-	basename = cgit_repobasename(repo->url);
+	basename = cgit_snapshot_prefix(repo);
 	if (starts_with(ref, basename))
 		strbuf_addstr(&filename, ref);
 	else
diff --git a/ui-shared.c b/ui-shared.c
index da92594..df9bbbf 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -151,6 +151,14 @@ const char *cgit_repobasename(const char *reponame)
 	return rvbuf;
 }
 
+const char *cgit_snapshot_prefix(const struct cgit_repo *repo)
+{
+	if (repo->snapshot_prefix)
+		return repo->snapshot_prefix;
+
+	return cgit_repobasename(repo->url);
+}
+
 static void site_url(const char *page, const char *search, const char *sort, int ofs, int always_root)
 {
 	char *delim = "?";
@@ -1109,7 +1117,7 @@ void cgit_print_snapshot_links(const struct cgit_repo *repo, const char *head,
 	struct strbuf filename = STRBUF_INIT;
 	size_t prefixlen;
 
-	cgit_compose_snapshot_prefix(&filename, cgit_repobasename(repo->url), hex);
+	cgit_compose_snapshot_prefix(&filename, cgit_snapshot_prefix(repo), hex);
 	prefixlen = filename.len;
 	for (f = cgit_snapshot_formats; f->suffix; f++) {
 		if (!(repo->snapshots & f->bit))
diff --git a/ui-shared.h b/ui-shared.h
index b3eb8c5..92a1755 100644
--- a/ui-shared.h
+++ b/ui-shared.h
@@ -78,6 +78,7 @@ extern void cgit_compose_snapshot_prefix(struct strbuf *filename,
 					 const char *base, const char *ref);
 extern void cgit_print_snapshot_links(const struct cgit_repo *repo,
 				      const char *head, const char *hex);
+extern const char *cgit_snapshot_prefix(const struct cgit_repo *repo);
 extern void cgit_add_hidden_formfields(int incl_head, int incl_search,
 				       const char *page);
 
diff --git a/ui-snapshot.c b/ui-snapshot.c
index 237a75f..b9e2a36 100644
--- a/ui-snapshot.c
+++ b/ui-snapshot.c
@@ -154,7 +154,7 @@ static const char *get_ref_from_filename(const struct cgit_repo *repo,
 	if (get_oid(snapshot.buf, &oid) == 0)
 		goto out;
 
-	reponame = cgit_repobasename(repo->url);
+	reponame = cgit_snapshot_prefix(repo);
 	if (starts_with(snapshot.buf, reponame)) {
 		const char *new_start = snapshot.buf;
 		new_start += strlen(reponame);
@@ -214,7 +214,7 @@ void cgit_print_snapshot(const char *head, const char *hex,
 		hex = head;
 
 	if (!prefix)
-		prefix = xstrdup(cgit_repobasename(ctx.repo->url));
+		prefix = xstrdup(cgit_snapshot_prefix(ctx.repo));
 
 	make_snapshot(f, hex, prefix, filename);
 	free(prefix);
-- 
2.16.3



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-03-31 14:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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   ` [PATCH v2 2/3] ui-snapshot: pass repo into get_ref_from_filename() john
2018-03-31 14:25   ` [PATCH v2 3/3] Add "snapshot-prefix" repo configuration john

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).