[PATCH 5/6] Add graph page tab if enable-commit-graph is set to "separate"
Kian Kasad
kian at kasad.com
Fri Aug 5 04:59:38 UTC 2022
If "enable-commit-graph" is set to "separate", a tab is added in the
navigation bar for the graph page. It sits next to the "log" link.
---
ui-shared.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
diff --git a/ui-shared.c b/ui-shared.c
index acd8ab5..a0c326e 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -401,6 +401,49 @@ void cgit_log_link(const char *name, const char *title, const char *class,
html("</a>");
}
+void cgit_graph_link(const char *name, const char *title, const char *class,
+ const char *head, const char *rev, const char *path,
+ int ofs, const char *grep, const char *pattern, int showmsg,
+ int follow)
+{
+ char *delim;
+
+ delim = repolink(title, class, "graph", head, path);
+ if (rev && ctx.qry.head && strcmp(rev, ctx.qry.head)) {
+ html(delim);
+ html("id=");
+ html_url_arg(rev);
+ delim = "&";
+ }
+ if (grep && pattern) {
+ html(delim);
+ html("qt=");
+ html_url_arg(grep);
+ delim = "&";
+ html(delim);
+ html("q=");
+ html_url_arg(pattern);
+ }
+ if (ofs > 0) {
+ html(delim);
+ html("ofs=");
+ htmlf("%d", ofs);
+ delim = "&";
+ }
+ if (showmsg) {
+ html(delim);
+ html("showmsg=1");
+ delim = "&";
+ }
+ if (follow) {
+ html(delim);
+ html("follow=1");
+ }
+ html("'>");
+ html_txt(name);
+ html("</a>");
+}
+
void cgit_commit_link(const char *name, const char *title, const char *class,
const char *head, const char *rev, const char *path)
{
@@ -1043,6 +1086,10 @@ void cgit_print_pageheader(void)
cgit_log_link("log", NULL, hc("log"), ctx.qry.head,
NULL, ctx.qry.vpath, 0, NULL, NULL,
ctx.qry.showmsg, ctx.qry.follow);
+ if (ctx.repo->enable_commit_graph == 2)
+ cgit_graph_link("graph", NULL, hc("graph"), ctx.qry.head,
+ NULL, ctx.qry.vpath, 0, NULL, NULL,
+ ctx.qry.showmsg, ctx.qry.follow);
if (ctx.qry.page && !strcmp(ctx.qry.page, "blame"))
cgit_blame_link("blame", NULL, hc("blame"), ctx.qry.head,
ctx.qry.oid, ctx.qry.vpath);
--
2.37.1
More information about the CGit
mailing list