diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Keep snapshot members from starting at a slash
A name that was all suffix, such as .tar, settled on a ref called v
with an empty prefix, and an empty snapshot-prefix did the same for a
snapshot asked for by id, so every member of the archive started at /.
Diffstat (limited to '')
| -rw-r--r-- | source/ui-snapshot.c | 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 file changed, 9 insertions, 1 deletion
diff --git a/source/ui-snapshot.c b/source/ui-snapshot.c index 8762407..3c00f66 100644 --- a/source/ui-snapshot.c +++ b/source/ui-snapshot.c @@ -29,7 +29,9 @@ static int write_archive_format(const char *format_arg, const char *hex, const c strvec_push(&argv, "snapshot"); strvec_push(&argv, format_arg); - if (prefix) { + // An empty prefix means none, since the slash added below would root + // every member of the archive at /. + if (prefix && *prefix) { struct strbuf buf = STRBUF_INIT; strbuf_addstr(&buf, prefix); @@ -370,6 +372,12 @@ void cgit_print_snapshot(const char *head, const char *hex, const char *filename cgit_print_error_page(404, "Not Found", "Not found"); return; } + // A name that is all suffix names no revision, though the lookup below + // would settle on a ref called v. + if (!hex && dwim && strlen(filename) == strlen(f->suffix)) { + cgit_print_error_page(404, "Not Found", "Not found"); + return; + } if (!hex && dwim) { hex = ref_from_filename(ctx.repo, filename, f); if (!hex) { |
