From: list at eworm.de (Christian Hesse)
Subject: [PATCH 08/10] ui-snapshot: replace 'unsigned char sha1[20]' with 'struct object_id oid'
Date: Tue, 4 Oct 2016 09:52:01 +0200 [thread overview]
Message-ID: <20161004075203.22115-8-list@eworm.de> (raw)
In-Reply-To: <20161004075203.22115-1-list@eworm.de>
From: Christian Hesse <mail at eworm.de>
Upstream git is replacing 'unsigned char sha1[20]' with 'struct object_id
oid'. We have some code that can be changed independent from upstream. So
here we go...
Signed-off-by: Christian Hesse <mail at eworm.de>
---
ui-snapshot.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/ui-snapshot.c b/ui-snapshot.c
index f68e877..08c6e80 100644
--- a/ui-snapshot.c
+++ b/ui-snapshot.c
@@ -109,19 +109,19 @@ static int make_snapshot(const struct cgit_snapshot_format *format,
const char *hex, const char *prefix,
const char *filename)
{
- unsigned char sha1[20];
+ struct object_id oid;
- if (get_sha1(hex, sha1)) {
+ if (get_oid(hex, &oid)) {
cgit_print_error_page(404, "Not found",
"Bad object id: %s", hex);
return 1;
}
- if (!lookup_commit_reference(sha1)) {
+ if (!lookup_commit_reference(oid.hash)) {
cgit_print_error_page(400, "Bad request",
"Not a commit reference: %s", hex);
return 1;
}
- ctx.page.etag = sha1_to_hex(sha1);
+ ctx.page.etag = oid_to_hex(&oid);
ctx.page.mimetype = xstrdup(format->mimetype);
ctx.page.filename = xstrdup(filename);
cgit_print_http_headers();
@@ -143,14 +143,14 @@ static const char *get_ref_from_filename(const char *url, const char *filename,
const struct cgit_snapshot_format *format)
{
const char *reponame;
- unsigned char sha1[20];
+ struct object_id oid;
struct strbuf snapshot = STRBUF_INIT;
int result = 1;
strbuf_addstr(&snapshot, filename);
strbuf_setlen(&snapshot, snapshot.len - strlen(format->suffix));
- if (get_sha1(snapshot.buf, sha1) == 0)
+ if (get_oid(snapshot.buf, &oid) == 0)
goto out;
reponame = cgit_repobasename(url);
@@ -162,15 +162,15 @@ static const char *get_ref_from_filename(const char *url, const char *filename,
strbuf_splice(&snapshot, 0, new_start - snapshot.buf, "", 0);
}
- if (get_sha1(snapshot.buf, sha1) == 0)
+ if (get_oid(snapshot.buf, &oid) == 0)
goto out;
strbuf_insert(&snapshot, 0, "v", 1);
- if (get_sha1(snapshot.buf, sha1) == 0)
+ if (get_oid(snapshot.buf, &oid) == 0)
goto out;
strbuf_splice(&snapshot, 0, 1, "V", 1);
- if (get_sha1(snapshot.buf, sha1) == 0)
+ if (get_oid(snapshot.buf, &oid) == 0)
goto out;
result = 0;
--
2.10.0
next prev parent reply other threads:[~2016-10-04 7:52 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20161004095050.29c7859b@leda.localdomain>
2016-10-04 7:51 ` [PATCH 01/10] cgit: " list
2016-10-04 7:51 ` [PATCH 02/10] ui-blob: " list
2016-10-04 8:07 ` Jason
2016-10-04 8:19 ` list
2016-10-04 18:34 ` john
2016-10-04 19:24 ` Jason
2016-10-04 19:48 ` list
2016-10-04 7:51 ` [PATCH 03/10] ui-commit: " list
2016-10-04 7:51 ` [PATCH 04/10] ui-log: replace get_sha1() with get_oid() list
2016-10-04 7:51 ` [PATCH 05/10] ui-patch: replace 'unsigned char sha1[20]' with 'struct object_id oid' list
2016-10-04 7:51 ` [PATCH 06/10] ui-plain: " list
2016-10-04 7:52 ` [PATCH 07/10] ui-shared: " list
2016-10-04 7:52 ` list [this message]
2016-10-04 7:52 ` [PATCH 09/10] ui-tag: " list
2016-10-04 7:52 ` [PATCH 10/10] ui-tree: " list
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161004075203.22115-8-list@eworm.de \
--to=cgit@lists.zx2c4.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).