aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Hesse <mail@eworm.de>2022-01-10 10:15:33 +0100
committerChristian Hesse <mail@eworm.de>2022-01-10 10:26:37 +0100
commit6e56427e0e5e23bfc9fa4964d34ef5f4eccffb7d (patch)
treeb176682fc996157745e4bd7b7e94028256bf1eb2
parentgit: update to v2.32.0 (diff)
downloadcgit-ch/about-head.tar.xz
cgit-ch/about-head.zip
about: allow to give head from querych/about-head
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>
-rw-r--r--cgit.c8
-rw-r--r--cgitrc.5.txt10
2 files changed, 10 insertions, 8 deletions
diff --git a/cgit.c b/cgit.c
index 08d81a1..c06379c 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);
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index 33a6a8c..d9eb3b0 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -579,11 +579,11 @@ repo.readme::
verbatim as the "About" page for this repo. You may also specify a
git refspec by head or by hash by prepending the refspec followed by
a colon. For example, "master:docs/readme.mkd". If the value begins
- with a colon, i.e. ":docs/readme.rst", the default branch of the
- repository will be used. Sharing any file will expose that entire
- directory tree to the "/about/PATH" endpoints, so be sure that there
- are no non-public files located in the same directory as the readme
- file. Default value: <readme>.
+ with a colon, i.e. ":docs/readme.rst", the head giving in query or
+ the default branch of the repository will be used. Sharing any file
+ will expose that entire directory tree to the "/about/PATH" endpoints,
+ so be sure that there are no non-public files located in the same
+ directory as the readme file. Default value: <readme>.
repo.section::
Override the current section name for this repository. Default value: