all repos — cgit @ d85e8a9810cbfbe5cfe80509a7b47cb39483e6ac

a hyperfast web frontend for git written in c

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 john@keeping.me.uk
Sat, 31 Mar 2018 15:18:57 +0100
commit

d85e8a9810cbfbe5cfe80509a7b47cb39483e6ac

parent

bd1b281478c8d8ab45f723ac5818d58da4a64dd1

1 files changed, 4 insertions(+), 3 deletions(-)

jump to
M ui-snapshot.cui-snapshot.c

@@ -139,7 +139,8 @@ * more. If this still isn't a valid commit object name, we check if pre-

* pending a 'v' or a 'V' to the remaining snapshot name ("0.7.2" -> * "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 char *reponame;

@@ -153,7 +154,7 @@

if (get_oid(snapshot.buf, &oid) == 0) goto out; - reponame = cgit_repobasename(url); + reponame = cgit_repobasename(repo->url); if (starts_with(snapshot.buf, reponame)) { const char *new_start = snapshot.buf; new_start += strlen(reponame);

@@ -200,7 +201,7 @@ return;

} 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) { cgit_print_error_page(404, "Not found", "Not found"); return;