diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2013-05-25 21:19:10 (JST) |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2013-05-26 03:33:28 (JST) |
commit | 3cb5d86dc68bab4883bf5a7cbc90f3e266237355 (patch) | |
tree | f7e3e798447d45179b4169a053f67e0ea3048c14 | |
parent | 03eb76dfad2887127581f5f1b4e2edbe8c4ca5fe (diff) | |
download | cgit-3cb5d86dc68bab4883bf5a7cbc90f3e266237355.zip cgit-3cb5d86dc68bab4883bf5a7cbc90f3e266237355.tar.gz |
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>
-rw-r--r-- | cgitrc.5.txt | 4 | ||||
-rw-r--r-- | ui-summary.c | 7 |
2 files changed, 9 insertions, 2 deletions
diff --git a/cgitrc.5.txt b/cgitrc.5.txt index 9b803b3..8a0a9c9 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt | |||
@@ -505,7 +505,9 @@ repo.readme:: | |||
505 | A path (relative to <repo.path>) which specifies a file to include | 505 | A path (relative to <repo.path>) which specifies a file to include |
506 | verbatim as the "About" page for this repo. You may also specify a | 506 | verbatim as the "About" page for this repo. You may also specify a |
507 | git refspec by head or by hash by prepending the refspec followed by | 507 | git refspec by head or by hash by prepending the refspec followed by |
508 | a colon. For example, "master:docs/readme.mkd" Default value: <readme>. | 508 | a colon. For example, "master:docs/readme.mkd". If the value begins |
509 | with a colon, i.e. ":docs/readme.rst", the default branch of the | ||
510 | repository will be used. Default value: <readme>. | ||
509 | 511 | ||
510 | repo.snapshots:: | 512 | repo.snapshots:: |
511 | A mask of allowed snapshot-formats for this repo, restricted by the | 513 | A mask of allowed snapshot-formats for this repo, restricted by the |
diff --git a/ui-summary.c b/ui-summary.c index f965b32..abf914e 100644 --- a/ui-summary.c +++ b/ui-summary.c | |||
@@ -108,7 +108,12 @@ void cgit_print_repo_readme(char *path) | |||
108 | colon = strchr(ctx.repo->readme, ':'); | 108 | colon = strchr(ctx.repo->readme, ':'); |
109 | if (colon && strlen(colon) > 1) { | 109 | if (colon && strlen(colon) > 1) { |
110 | *colon = '\0'; | 110 | *colon = '\0'; |
111 | ref = ctx.repo->readme; | 111 | /* If it starts with a colon, we want to use |
112 | * the default branch */ | ||
113 | if (colon == ctx.repo->readme && ctx.repo->defbranch) | ||
114 | ref = ctx.repo->defbranch; | ||
115 | else | ||
116 | ref = ctx.repo->readme; | ||
112 | ctx.repo->readme = colon + 1; | 117 | ctx.repo->readme = colon + 1; |
113 | if (!(*ctx.repo->readme)) | 118 | if (!(*ctx.repo->readme)) |
114 | return; | 119 | return; |