diff options
| author | Christian Hesse | 2016-09-29 22:12:11 +0200 |
|---|---|---|
| committer | Christian Hesse | 2016-10-04 09:47:18 +0200 |
| commit | 406f593895a2cc9f8944e87c94b7b6a94deee470 (patch) | |
| tree | 6c03019e230614fdaee8263a18f98c03eac36256 | |
| parent | 6bef566f99c7f85cbab9692e22b183ae99f33c1d (diff) | |
| download | cgit-406f593895a2cc9f8944e87c94b7b6a94deee470.tar.gz cgit-406f593895a2cc9f8944e87c94b7b6a94deee470.tar.bz2 cgit-406f593895a2cc9f8944e87c94b7b6a94deee470.zip | |
ui-snapshot: replace 'unsigned char sha1[20]' with 'struct object_id oid'
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...
| -rw-r--r-- | ui-snapshot.c | 18 |
1 files 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, | |||
| 109 | const char *hex, const char *prefix, | 109 | const char *hex, const char *prefix, |
| 110 | const char *filename) | 110 | const char *filename) |
| 111 | { | 111 | { |
| 112 | unsigned char sha1[20]; | 112 | struct object_id oid; |
| 113 | 113 | ||
| 114 | if (get_sha1(hex, sha1)) { | 114 | if (get_oid(hex, &oid)) { |
| 115 | cgit_print_error_page(404, "Not found", | 115 | cgit_print_error_page(404, "Not found", |
| 116 | "Bad object id: %s", hex); | 116 | "Bad object id: %s", hex); |
| 117 | return 1; | 117 | return 1; |
| 118 | } | 118 | } |
| 119 | if (!lookup_commit_reference(sha1)) { | 119 | if (!lookup_commit_reference(oid.hash)) { |
| 120 | cgit_print_error_page(400, "Bad request", | 120 | cgit_print_error_page(400, "Bad request", |
| 121 | "Not a commit reference: %s", hex); | 121 | "Not a commit reference: %s", hex); |
| 122 | return 1; | 122 | return 1; |
| 123 | } | 123 | } |
| 124 | ctx.page.etag = sha1_to_hex(sha1); | 124 | ctx.page.etag = oid_to_hex(&oid); |
| 125 | ctx.page.mimetype = xstrdup(format->mimetype); | 125 | ctx.page.mimetype = xstrdup(format->mimetype); |
| 126 | ctx.page.filename = xstrdup(filename); | 126 | ctx.page.filename = xstrdup(filename); |
| 127 | cgit_print_http_headers(); | 127 | cgit_print_http_headers(); |
| @@ -143,14 +143,14 @@ static const char *get_ref_from_filename(const char *url, const char *filename, | |||
| 143 | const struct cgit_snapshot_format *format) | 143 | const struct cgit_snapshot_format *format) |
| 144 | { | 144 | { |
| 145 | const char *reponame; | 145 | const char *reponame; |
| 146 | unsigned char sha1[20]; | 146 | struct object_id oid; |
| 147 | struct strbuf snapshot = STRBUF_INIT; | 147 | struct strbuf snapshot = STRBUF_INIT; |
| 148 | int result = 1; | 148 | int result = 1; |
| 149 | 149 | ||
| 150 | strbuf_addstr(&snapshot, filename); | 150 | strbuf_addstr(&snapshot, filename); |
| 151 | strbuf_setlen(&snapshot, snapshot.len - strlen(format->suffix)); | 151 | strbuf_setlen(&snapshot, snapshot.len - strlen(format->suffix)); |
| 152 | 152 | ||
| 153 | if (get_sha1(snapshot.buf, sha1) == 0) | 153 | if (get_oid(snapshot.buf, &oid) == 0) |
| 154 | goto out; | 154 | goto out; |
| 155 | 155 | ||
| 156 | reponame = cgit_repobasename(url); | 156 | reponame = cgit_repobasename(url); |
| @@ -162,15 +162,15 @@ static const char *get_ref_from_filename(const char *url, const char *filename, | |||
| 162 | strbuf_splice(&snapshot, 0, new_start - snapshot.buf, "", 0); | 162 | strbuf_splice(&snapshot, 0, new_start - snapshot.buf, "", 0); |
| 163 | } | 163 | } |
| 164 | 164 | ||
| 165 | if (get_sha1(snapshot.buf, sha1) == 0) | 165 | if (get_oid(snapshot.buf, &oid) == 0) |
| 166 | goto out; | 166 | goto out; |
| 167 | 167 | ||
| 168 | strbuf_insert(&snapshot, 0, "v", 1); | 168 | strbuf_insert(&snapshot, 0, "v", 1); |
| 169 | if (get_sha1(snapshot.buf, sha1) == 0) | 169 | if (get_oid(snapshot.buf, &oid) == 0) |
| 170 | goto out; | 170 | goto out; |
| 171 | 171 | ||
| 172 | strbuf_splice(&snapshot, 0, 1, "V", 1); | 172 | strbuf_splice(&snapshot, 0, 1, "V", 1); |
| 173 | if (get_sha1(snapshot.buf, sha1) == 0) | 173 | if (get_oid(snapshot.buf, &oid) == 0) |
| 174 | goto out; | 174 | goto out; |
| 175 | 175 | ||
| 176 | result = 0; | 176 | result = 0; |
