about summary refs log tree commit diff
path: root/cgit.c
diff options
context:
space:
mode:
authorChristian Hesse <mail@eworm.de>2022-01-10 10:18:55 +0100
committerJune McEnroe <june@causal.agency>2022-02-17 17:57:00 -0500
commit129d8a1582b586718a64bbbef393d529b84c7b16 (patch)
tree656aa5e0d6229fe6b40a52e507ad35fd6ea6f6de /cgit.c
parentBump version to 1.3.0 (diff)
downloadcgit-pink-129d8a1582b586718a64bbbef393d529b84c7b16.tar.gz
cgit-pink-129d8a1582b586718a64bbbef393d529b84c7b16.zip
Allow to give readme 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.
Diffstat (limited to '')
-rw-r--r--cgit.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/cgit.c b/cgit.c
index d18938c..dd28a79 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);