From ea9f614e02559f0166c9e74441f3edf4fe897fe2 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 10 Jan 2022 10:15:33 +0100 Subject: about: allow to give head from query Reading the README from repository used to be limited to default branch or a branch given in configuration. Let's allow a branch from query if not specified explicitly. Signed-off-by: Christian Hesse --- cgit.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'cgit.c') diff --git a/cgit.c b/cgit.c index 4b2d86c..2de6d7f 100644 --- a/cgit.c +++ b/cgit.c @@ -507,9 +507,11 @@ static inline void parse_readme(const char *readme, char **filename, char **ref, /* Check if the readme is tracked in the git repo. */ colon = strchr(readme, ':'); if (colon && strlen(colon) > 1) { - /* If it starts with a colon, we want to use - * the default branch */ - if (colon == readme && repo->defbranch) + /* If it starts with a colon, we want to use head given + * from query or the default branch */ + if (colon == readme && ctx.qry.head) + *ref = xstrdup(ctx.qry.head); + else if (colon == readme && repo->defbranch) *ref = xstrdup(repo->defbranch); else *ref = xstrndup(readme, colon - readme); -- cgit v1.2.3-70-g09d2