cgit

commit c422b9b3d5938a4d386533604d4c0dbedfcb2b6d

Author: John Keeping <john@keeping.me.uk>

tag: reference with "h" instead of "id"

When clicking on "log" from a tag we end up showing the log of whatever
branch we used to reach the tag.  If the tag doesn't point onto a branch
then the tagged commit won't appear in this output.

By linking to tags with the head parameter instead of the "id" parameter
the log link will show the log of the tag.  This is clearly desirable
when the tag has been reached from the refs UI and changing the
behaviour for tag decorations makes them match branch decorations where
log -> decoration -> log shows the log of the decoration.

Reported-by: Ferry Huberts <mailings@hupie.com>
Signed-off-by: John Keeping <john@keeping.me.uk>

 ui-log.c | 4 ++--
 ui-refs.c | 2 +-
 ui-shared.c | 8 ++++----
 ui-shared.h | 3 +--


diff --git a/ui-log.c b/ui-log.c
index 657ff3cb76a835ae090452669c05ec49d904fc23..1b605910a0362349920ad09f260fc923aed790c1 100644
--- a/ui-log.c
+++ b/ui-log.c
@@ -71,11 +71,11 @@ 				      ctx.qry.showmsg);
 		}
 		else if (starts_with(deco->name, "tag: refs/tags/")) {
 			strncpy(buf, deco->name + 15, sizeof(buf) - 1);
-			cgit_tag_link(buf, NULL, "tag-deco", ctx.qry.head, buf);
+			cgit_tag_link(buf, NULL, "tag-deco", buf);
 		}
 		else if (starts_with(deco->name, "refs/tags/")) {
 			strncpy(buf, deco->name + 10, sizeof(buf) - 1);
-			cgit_tag_link(buf, NULL, "tag-deco", ctx.qry.head, buf);
+			cgit_tag_link(buf, NULL, "tag-deco", buf);
 		}
 		else if (starts_with(deco->name, "refs/remotes/")) {
 			if (!ctx.repo->enable_remote_branches)




diff --git a/ui-refs.c b/ui-refs.c
index d2ba48d83d04a7bf0a7d08a012348d3b82ecbe49..ac8a6d446e14765afabfcffe0f41f6fb32256b68 100644
--- a/ui-refs.c
+++ b/ui-refs.c
@@ -140,7 +140,7 @@ 			return 1;
 	}
 
 	html("<tr><td>");
-	cgit_tag_link(name, NULL, NULL, ctx.qry.head, name);
+	cgit_tag_link(name, NULL, NULL, name);
 	html("</td><td>");
 	if (ctx.repo->snapshots && (obj->type == OBJ_COMMIT))
 		print_tag_downloads(ctx.repo, name);




diff --git a/ui-shared.c b/ui-shared.c
index 32f23f9d98355d5233035ecf5a7cae379df5ddc4..d8cc4d7a3d43beaee1a423a22ea9a33d8a5487e5 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -273,9 +273,9 @@ 	reporevlink(NULL, name, title, class, head, NULL, NULL);
 }
 
 void cgit_tag_link(const char *name, const char *title, const char *class,
-		   const char *head, const char *rev)
+		   const char *tag)
 {
-	reporevlink("tag", name, title, class, head, rev, NULL);
+	reporevlink("tag", name, title, class, tag, NULL, NULL);
 }
 
 void cgit_tree_link(const char *name, const char *title, const char *class,
@@ -443,8 +443,8 @@ 				ctx.qry.ofs);
 	else if (!strcmp(ctx.qry.page, "summary"))
 		cgit_summary_link(name, title, class, ctx.qry.head);
 	else if (!strcmp(ctx.qry.page, "tag"))
-		cgit_tag_link(name, title, class, ctx.qry.head,
-			      ctx.qry.has_sha1 ? ctx.qry.sha1 : NULL);
+		cgit_tag_link(name, title, class, ctx.qry.has_sha1 ?
+			       ctx.qry.sha1 : ctx.qry.head);
 	else if (!strcmp(ctx.qry.page, "tree"))
 		cgit_tree_link(name, title, class, ctx.qry.head,
 			       ctx.qry.has_sha1 ? ctx.qry.sha1 : NULL,




diff --git a/ui-shared.h b/ui-shared.h
index f8cf22001ab63d1a1bbda2e3feefbd4426251cc3..021fe4e6a6d1fbd5598553e9759241923e419a53 100644
--- a/ui-shared.h
+++ b/ui-shared.h
@@ -18,8 +18,7 @@ 			    const char *class, const char *pattern, const char *sort, int ofs);
 extern void cgit_summary_link(const char *name, const char *title,
 			      const char *class, const char *head);
 extern void cgit_tag_link(const char *name, const char *title,
-			  const char *class, const char *head,
-			  const char *rev);
+			  const char *class, const char *tag);
 extern void cgit_tree_link(const char *name, const char *title,
 			   const char *class, const char *head,
 			   const char *rev, const char *path);