ui-snapshot: pass repo into get_ref_from_filename()

Prepare to allow a custom snapshot prefix.

Signed-off-by: John Keeping <john@keeping.me.uk>
Reviewed-by: Christian Hesse <mail@eworm.de>
这个提交包含在:
John Keeping 2018-03-31 15:18:57 +01:00 提交者 Jason A. Donenfeld
父节点 bd1b281478
当前提交 d85e8a9810

查看文件

@ -139,7 +139,8 @@ static int make_snapshot(const struct cgit_snapshot_format *format,
* pending a 'v' or a 'V' to the remaining snapshot name ("0.7.2" -> * pending a 'v' or a 'V' to the remaining snapshot name ("0.7.2" ->
* "v0.7.2") gives us something valid. * "v0.7.2") gives us something valid.
*/ */
static const char *get_ref_from_filename(const char *url, const char *filename, static const char *get_ref_from_filename(const struct cgit_repo *repo,
const char *filename,
const struct cgit_snapshot_format *format) const struct cgit_snapshot_format *format)
{ {
const char *reponame; const char *reponame;
@ -153,7 +154,7 @@ static const char *get_ref_from_filename(const char *url, const char *filename,
if (get_oid(snapshot.buf, &oid) == 0) if (get_oid(snapshot.buf, &oid) == 0)
goto out; goto out;
reponame = cgit_repobasename(url); reponame = cgit_repobasename(repo->url);
if (starts_with(snapshot.buf, reponame)) { if (starts_with(snapshot.buf, reponame)) {
const char *new_start = snapshot.buf; const char *new_start = snapshot.buf;
new_start += strlen(reponame); new_start += strlen(reponame);
@ -200,7 +201,7 @@ void cgit_print_snapshot(const char *head, const char *hex,
} }
if (!hex && dwim) { if (!hex && dwim) {
hex = get_ref_from_filename(ctx.repo->url, filename, f); hex = get_ref_from_filename(ctx.repo, filename, f);
if (hex == NULL) { if (hex == NULL) {
cgit_print_error_page(404, "Not found", "Not found"); cgit_print_error_page(404, "Not found", "Not found");
return; return;