List for cgit developers and users
 help / color / mirror / Atom feed
* [PATCH] Handle tags outside of refs/tags gracefully.
@ 2020-12-28 13:35 Ulrich Spörlein
  2020-12-29 11:37 ` Jason A. Donenfeld
  0 siblings, 1 reply; 9+ messages in thread
From: Ulrich Spörlein @ 2020-12-28 13:35 UTC (permalink / raw)
  To: cgit; +Cc: Ulrich Spörlein

Big conversions from Subversion to Git might keep track of several
"internal" tags under namespaces different from refs/tags. If a full
refs specification was given, don't prepend refs/tags again.

This fixes a "Bad tag reference" for the FreeBSD project URLs like so:
https://cgit.freebsd.org/src/tag/?h=refs/backups/projects/mips@202126

(fun fact: the log handler properly handles
log/?h=backups/projects/mips@202126 though it is an annotated tag under
refs/backups.

This fixes issue https://github.com/freebsd/git_conv/issues/24
---
 ui-tag.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/ui-tag.c b/ui-tag.c
index 424bbcc..cc86b31 100644
--- a/ui-tag.c
+++ b/ui-tag.c
@@ -47,7 +47,11 @@ void cgit_print_tag(char *revname)
 	if (!revname)
 		revname = ctx.qry.head;
 
-	strbuf_addf(&fullref, "refs/tags/%s", revname);
+	if (!strncmp(revname, "refs/", 5)) {
+		strbuf_addstr(&fullref, revname);
+	} else {
+		strbuf_addf(&fullref, "refs/tags/%s", revname);
+	}
 	if (get_oid(fullref.buf, &oid)) {
 		cgit_print_error_page(404, "Not found",
 			"Bad tag reference: %s", revname);
-- 
2.24.0


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

end of thread, other threads:[~2021-01-05 17:12 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-28 13:35 [PATCH] Handle tags outside of refs/tags gracefully Ulrich Spörlein
2020-12-29 11:37 ` Jason A. Donenfeld
2020-12-29 18:22   ` Ulrich Spörlein
2020-12-29 20:04     ` Jason A. Donenfeld
2020-12-29 20:33       ` Gianni Ceccarelli
2021-01-05 11:53         ` Gianni Ceccarelli
2021-01-05 13:09           ` John Keeping
2021-01-05 13:40             ` Gianni Ceccarelli
     [not found]               ` <CAJ9axoSnfttirTwaVNhZPa73KSw+PCTq_5MVyvUfT7AcDxLXPg@mail.gmail.com>
2021-01-05 17:12                 ` Gianni Ceccarelli

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