From 73474fa40571ef6ab13a1e0d065a21df92c21009 Mon Sep 17 00:00:00 2001 From: Patrick Date: Sun, 11 Jan 2026 17:35:46 +0100 Subject: fix About page and readme selection --- cmd.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'cmd.c') diff --git a/cmd.c b/cmd.c index e75c313..cf9d03c 100644 --- a/cmd.c +++ b/cmd.c @@ -41,6 +41,8 @@ static void about_fn(void) { if (ctx.repo) { size_t path_info_len = ctx.env.path_info ? strlen(ctx.env.path_info) : 0; + struct object_id oid; + if (!ctx.qry.path && ctx.qry.url[strlen(ctx.qry.url) - 1] != '/' && (!path_info_len || ctx.env.path_info[path_info_len - 1] != '/')) { @@ -49,10 +51,12 @@ static void about_fn(void) cgit_redirect(redirect, true); free(currenturl); free(redirect); - } else if (ctx.repo->readme.nr) - cgit_print_repo_readme(ctx.qry.path); - else if (ctx.repo->homepage) + } else if (!get_oid(ctx.qry.head, &oid)) { + cgit_print_repo_readme(ctx.qry.path, &oid); + } + else if (ctx.repo->homepage) { cgit_redirect(ctx.repo->homepage, false); + } else { char *currenturl = cgit_currenturl(); char *redirect = fmtalloc("%s../", currenturl); @@ -205,7 +209,11 @@ struct cgit_cmd *cgit_get_cmd(void) if (!strcmp(ctx.qry.page, cmds[i].name)) return &cmds[i]; - char *redirect = fmtalloc("/git/%s/tree/%s%s%s", ctx.qry.repo, ctx.qry.page, ctx.qry.path ? "/" : "", ctx.qry.path ? ctx.qry.path : ""); + char *redirect; + if (ctx.qry.path) + redirect = fmtalloc("/git/%s/tree/%s/%s", ctx.qry.repo, ctx.qry.page, ctx.qry.path); + else + redirect = fmtalloc("/git/%s/tree/%s", ctx.qry.repo, ctx.qry.page); cgit_redirect(redirect, false); free(redirect); -- cgit v1.2.3