-rw-r--r-- | ui-snapshot.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/ui-snapshot.c b/ui-snapshot.c index 966a140..7a597ff 100644 --- a/ui-snapshot.c +++ b/ui-snapshot.c @@ -69,33 +69,39 @@ static int make_snapshot(const struct cgit_snapshot_format *format, const char *filename) { struct archiver_args args; struct commit *commit; unsigned char sha1[20]; if(get_sha1(hex, sha1)) { cgit_print_error(fmt("Bad object id: %s", hex)); return 1; } commit = lookup_commit_reference(sha1); if(!commit) { cgit_print_error(fmt("Not a commit reference: %s", hex)); return 1; } memset(&args, 0, sizeof(args)); - args.base = fmt("%s/", prefix); + if (prefix) { + args.base = fmt("%s/", prefix); + args.baselen = strlen(prefix) + 1; + } else { + args.base = ""; + args.baselen = 0; + } args.tree = commit->tree; args.time = commit->date; ctx.page.mimetype = xstrdup(format->mimetype); ctx.page.filename = xstrdup(filename); cgit_print_http_headers(&ctx); format->write_func(&args); return 0; } void cgit_print_snapshot(const char *head, const char *hex, const char *prefix, const char *filename, int snapshots) { const struct cgit_snapshot_format* f; int sl, fnl; fnl = strlen(filename); |