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

Reply via email to