From mboxrd@z Thu Jan 1 00:00:00 1970 From: richard.maw at gmail.com (Richard Maw) Date: Mon, 1 Aug 2016 22:35:34 +0100 Subject: [PATCH v3 02/21] Fix archive generation In-Reply-To: <20160801213553.16807-1-richard.maw@gmail.com> References: <20160801213553.16807-1-richard.maw@gmail.com> Message-ID: <20160801213553.16807-3-richard.maw@gmail.com> The get_ref_from_filename function is expected to return a sha1. It didn't actually do this, instead returning the ref that would under normal circumstances resolve to that. Since we're going to resolve refs in a way that is namespace aware we need to return the sha1 rather than the ref, since the archive is created by libgit code that is not namespace aware, and it would try to resolve the ref again. This previously worked fine because it would resolve the ref the same way both times. Signed-off-by: Richard Maw --- ui-snapshot.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui-snapshot.c b/ui-snapshot.c index f68e877..c6c3656 100644 --- a/ui-snapshot.c +++ b/ui-snapshot.c @@ -174,10 +174,10 @@ static const char *get_ref_from_filename(const char *url, const char *filename, goto out; result = 0; - strbuf_release(&snapshot); out: - return result ? strbuf_detach(&snapshot, NULL) : NULL; + strbuf_release(&snapshot); + return result ? xstrdup(sha1_to_hex(sha1)) : NULL; } void cgit_print_snapshot(const char *head, const char *hex, -- 2.9.0