subtree(3p/cgit): merge cgit-pink into depot cgit

cgit-pink is a maintained fork of cgit that follows upstream git more
closely and already contains a lot of patches we already had applied.
Consequently, it seems sensible it becomes our future upstream, we may
even be able to upstream some of our custom, less invasive patches.

Change-Id: Ia081e4508866f32298986c7160f4890c8a7c8922
This commit is contained in:
sterni 2022-05-19 10:27:26 +02:00
commit 40803d9c6d
39 changed files with 185 additions and 1616 deletions

View file

@ -836,7 +836,7 @@ void cgit_print_docend(void)
if (ctx.cfg.footer)
html_include(ctx.cfg.footer);
else {
htmlf("<div class='footer'>generated by <a href='https://git.zx2c4.com/cgit/about/'>cgit %s</a> "
htmlf("<div class='footer'>generated by <a href='https://git.causal.agency/cgit-pink/about/'>cgit-pink %s</a> "
"(<a href='https://git-scm.com/'>git %s</a>) at ", cgit_version, git_version_string);
html_txt(show_date(time(NULL), 0, cgit_date_mode(DATE_DOTTIME)));
html("</div>\n");
@ -898,7 +898,7 @@ void cgit_add_clone_urls(void (*fn)(const char *))
static int print_this_commit_option(void)
{
struct object_id oid;
if (get_oid(ctx.qry.head, &oid))
if (!ctx.qry.head || get_oid(ctx.qry.head, &oid))
return 1;
html_option(oid_to_hex(&oid), "this commit", ctx.qry.head);
return 0;
@ -1003,7 +1003,7 @@ static void print_header(void)
html("<td class='main'>");
if (ctx.repo) {
cgit_summary_link(ctx.repo->name, ctx.repo->name, NULL, NULL);
cgit_summary_link(ctx.repo->name, NULL, NULL, NULL);
if (ctx.env.authenticated) {
html("</td><td class='form'>");
html("<form method='get'>\n");
@ -1027,7 +1027,13 @@ static void print_header(void)
if (ctx.repo) {
html_txt(ctx.repo->desc);
html("</td><td class='sub right'>");
html_txt(ctx.repo->owner);
if (ctx.repo->owner_filter) {
cgit_open_filter(ctx.repo->owner_filter);
html_txt(ctx.repo->owner);
cgit_close_filter(ctx.repo->owner_filter);
} else {
html_txt(ctx.repo->owner);
}
} else {
if (ctx.cfg.root_desc)
html_txt(ctx.cfg.root_desc);
@ -1046,29 +1052,37 @@ void cgit_print_pageheader(void)
if (ctx.repo->readme.nr) {
cgit_about_link("about", NULL, hc("about"), ctx.qry.head,
ctx.qry.oid, ctx.qry.vpath);
html(" ");
}
cgit_summary_link("summary", NULL, hc("summary"),
ctx.qry.head);
html(" ");
cgit_refs_link("refs", NULL, hc("refs"), ctx.qry.head,
ctx.qry.oid, NULL);
html(" ");
cgit_log_link("log", NULL, hc("log"), ctx.qry.head,
NULL, ctx.qry.vpath, 0, NULL, NULL,
ctx.qry.showmsg, ctx.qry.follow);
html(" ");
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);
else
cgit_tree_link("tree", NULL, hc("tree"), ctx.qry.head,
ctx.qry.oid, ctx.qry.vpath);
ctx.qry.oid, ctx.qry.vpath);
html(" ");
cgit_commit_link("commit", NULL, hc("commit"),
ctx.qry.head, ctx.qry.oid, ctx.qry.vpath);
html(" ");
cgit_diff_link("diff", NULL, hc("diff"), ctx.qry.head,
ctx.qry.oid, ctx.qry.oid2, ctx.qry.vpath);
if (ctx.repo->max_stats)
if (ctx.repo->max_stats) {
html(" ");
cgit_stats_link("stats", NULL, hc("stats"),
ctx.qry.head, ctx.qry.vpath);
}
if (ctx.repo->homepage) {
html("<a href='");
html(" <a href='");
html_attr(ctx.repo->homepage);
html("'>homepage</a>");
}
@ -1212,9 +1226,12 @@ void cgit_set_title_from_path(const char *path)
if (!path)
return;
for (last_slash = path + strlen(path); (slash = memrchr(path, '/', last_slash - path)) != NULL; last_slash = slash) {
last_slash = path + strlen(path);
for (slash = last_slash; slash > path; --slash) {
if (*slash != '/') continue;
strbuf_add(&sb, slash + 1, last_slash - slash - 1);
strbuf_addstr(&sb, " \xc2\xab ");
last_slash = slash;
}
strbuf_add(&sb, path, last_slash - path);
strbuf_addf(&sb, " - %s", ctx.page.title);