mirror of
https://git.zx2c4.com/cgit
synced 2024-11-28 19:36:21 +00:00
ui-summary: Use default branch for readme if : prefix
If the readme value begins with ":", and has no specified branch before it, use the repository's default branch. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
03eb76dfad
commit
3cb5d86dc6
@ -505,7 +505,9 @@ repo.readme::
|
|||||||
A path (relative to <repo.path>) which specifies a file to include
|
A path (relative to <repo.path>) which specifies a file to include
|
||||||
verbatim as the "About" page for this repo. You may also specify a
|
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
|
git refspec by head or by hash by prepending the refspec followed by
|
||||||
a colon. For example, "master:docs/readme.mkd" Default value: <readme>.
|
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. Default value: <readme>.
|
||||||
|
|
||||||
repo.snapshots::
|
repo.snapshots::
|
||||||
A mask of allowed snapshot-formats for this repo, restricted by the
|
A mask of allowed snapshot-formats for this repo, restricted by the
|
||||||
|
@ -108,7 +108,12 @@ void cgit_print_repo_readme(char *path)
|
|||||||
colon = strchr(ctx.repo->readme, ':');
|
colon = strchr(ctx.repo->readme, ':');
|
||||||
if (colon && strlen(colon) > 1) {
|
if (colon && strlen(colon) > 1) {
|
||||||
*colon = '\0';
|
*colon = '\0';
|
||||||
ref = ctx.repo->readme;
|
/* If it starts with a colon, we want to use
|
||||||
|
* the default branch */
|
||||||
|
if (colon == ctx.repo->readme && ctx.repo->defbranch)
|
||||||
|
ref = ctx.repo->defbranch;
|
||||||
|
else
|
||||||
|
ref = ctx.repo->readme;
|
||||||
ctx.repo->readme = colon + 1;
|
ctx.repo->readme = colon + 1;
|
||||||
if (!(*ctx.repo->readme))
|
if (!(*ctx.repo->readme))
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user