aboutsummaryrefslogtreecommitdiff
path: root/cgit.c
diff options
context:
space:
mode:
authorChristian Hesse <mail@eworm.de>2022-01-10 10:15:33 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2022-12-19 16:13:58 +0100
commita0f6669bdb74e58b0ddb3f4283209cd5e58c0eb9 (patch)
treed194a8164a9116662eb0f467481470666bf4a17a /cgit.c
parentce2062d9e29bf165ba8a70bfc92ff3ab08338d53 (diff)
downloadcgit-a0f6669bdb74e58b0ddb3f4283209cd5e58c0eb9.tar.gz
cgit-a0f6669bdb74e58b0ddb3f4283209cd5e58c0eb9.tar.bz2
cgit-a0f6669bdb74e58b0ddb3f4283209cd5e58c0eb9.zip
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 <mail@eworm.de>
Diffstat (limited to 'cgit.c')
-rw-r--r--cgit.c8
1 files changed, 5 insertions, 3 deletions
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);