diff options
author | Christian Hesse | 2018-06-04 18:49:28 +0200 |
---|---|---|
committer | Jason A. Donenfeld | 2018-06-27 18:13:03 +0200 |
commit | 255b78ff5291cef79978b025c9872f801de89e23 (patch) | |
tree | 7938fdb3af17e39507d282595e1591b0984cc2ec /ui-tree.c | |
parent | 54d37dc154f5308459df0a90c81dabd0245b6c17 (diff) | |
download | cgit-255b78ff5291cef79978b025c9872f801de89e23.tar.gz cgit-255b78ff5291cef79978b025c9872f801de89e23.tar.bz2 cgit-255b78ff5291cef79978b025c9872f801de89e23.zip |
git: update to v2.18.0
Update to git version v2.18.0. Required changes follow upstream commits:
* Convert find_unique_abbrev* to struct object_id
(aab9583f7b5ea5463eb3f653a0b4ecac7539dc94)
* sha1_file: convert read_sha1_file to struct object_id
(b4f5aca40e6f77cbabcbf4ff003c3cf30a1830c8)
* sha1_file: convert sha1_object_info* to object_id
(abef9020e3df87c441c9a3a95f592fce5fa49bb9)
* object-store: move packed_git and packed_git_mru to object store
(a80d72db2a73174b3f22142eb2014b33696fd795)
* treewide: rename tree to maybe_tree
(891435d55da80ca3654b19834481205be6bdfe33)
The changed data types required some of our own functions to be converted
to struct object_id:
ls_item
print_dir
print_dir_entry
print_object
single_tree_cb
walk_tree
write_tree_link
And finally we use new upstream functions that were added for
struct object_id:
hashcpy -> oidcpy
sha1_to_hex -> oid_to_hex
Signed-off-by: Christian Hesse <mail@eworm.de>
Reviewed-by: John Keeping <john@keeping.me.uk>
Diffstat (limited to 'ui-tree.c')
-rw-r--r-- | ui-tree.c | 42 |
1 files changed, 21 insertions, 21 deletions
@@ -84,30 +84,30 @@ static void print_binary_buffer(char *buf, unsigned long size) | |||
84 | html("</table>\n"); | 84 | html("</table>\n"); |
85 | } | 85 | } |
86 | 86 | ||
87 | static void print_object(const unsigned char *sha1, char *path, const char *basename, const char *rev) | 87 | static void print_object(const struct object_id *oid, char *path, const char *basename, const char *rev) |
88 | { | 88 | { |
89 | enum object_type type; | 89 | enum object_type type; |
90 | char *buf; | 90 | char *buf; |
91 | unsigned long size; | 91 | unsigned long size; |
92 | 92 | ||
93 | type = sha1_object_info(sha1, &size); | 93 | type = oid_object_info(the_repository, oid, &size); |
94 | if (type == OBJ_BAD) { | 94 | if (type == OBJ_BAD) { |
95 | cgit_print_error_page(404, "Not found", | 95 | cgit_print_error_page(404, "Not found", |
96 | "Bad object name: %s", sha1_to_hex(sha1)); | 96 | "Bad object name: %s", oid_to_hex(oid)); |
97 | return; | 97 | return; |
98 | } | 98 | } |
99 | 99 | ||
100 | buf = read_sha1_file(sha1, &type, &size); | 100 | buf = read_object_file(oid, &type, &size); |
101 | if (!buf) { | 101 | if (!buf) { |
102 | cgit_print_error_page(500, "Internal server error", | 102 | cgit_print_error_page(500, "Internal server error", |
103 | "Error reading object %s", sha1_to_hex(sha1)); | 103 | "Error reading object %s", oid_to_hex(oid)); |
104 | return; | 104 | return; |
105 | } | 105 | } |
106 | 106 | ||
107 | cgit_set_title_from_path(path); | 107 | cgit_set_title_from_path(path); |
108 | 108 | ||
109 | cgit_print_layout_start(); | 109 | cgit_print_layout_start(); |
110 | htmlf("blob: %s (", sha1_to_hex(sha1)); | 110 | htmlf("blob: %s (", oid_to_hex(oid)); |
111 | cgit_plain_link("plain", NULL, NULL, ctx.qry.head, | 111 | cgit_plain_link("plain", NULL, NULL, ctx.qry.head, |
112 | rev, path); | 112 | rev, path); |
113 | if (ctx.cfg.enable_blame) { | 113 | if (ctx.cfg.enable_blame) { |
@@ -138,7 +138,7 @@ struct single_tree_ctx { | |||
138 | size_t count; | 138 | size_t count; |
139 | }; | 139 | }; |
140 | 140 | ||
141 | static int single_tree_cb(const unsigned char *sha1, struct strbuf *base, | 141 | static int single_tree_cb(const struct object_id *oid, struct strbuf *base, |
142 | const char *pathname, unsigned mode, int stage, | 142 | const char *pathname, unsigned mode, int stage, |
143 | void *cbdata) | 143 | void *cbdata) |
144 | { | 144 | { |
@@ -153,12 +153,12 @@ static int single_tree_cb(const unsigned char *sha1, struct strbuf *base, | |||
153 | } | 153 | } |
154 | 154 | ||
155 | ctx->name = xstrdup(pathname); | 155 | ctx->name = xstrdup(pathname); |
156 | hashcpy(ctx->oid.hash, sha1); | 156 | oidcpy(&ctx->oid, oid); |
157 | strbuf_addf(ctx->path, "/%s", pathname); | 157 | strbuf_addf(ctx->path, "/%s", pathname); |
158 | return 0; | 158 | return 0; |
159 | } | 159 | } |
160 | 160 | ||
161 | static void write_tree_link(const unsigned char *sha1, char *name, | 161 | static void write_tree_link(const struct object_id *oid, char *name, |
162 | char *rev, struct strbuf *fullpath) | 162 | char *rev, struct strbuf *fullpath) |
163 | { | 163 | { |
164 | size_t initial_length = fullpath->len; | 164 | size_t initial_length = fullpath->len; |
@@ -171,7 +171,7 @@ static void write_tree_link(const unsigned char *sha1, char *name, | |||
171 | .nr = 0 | 171 | .nr = 0 |
172 | }; | 172 | }; |
173 | 173 | ||
174 | hashcpy(tree_ctx.oid.hash, sha1); | 174 | oidcpy(&tree_ctx.oid, oid); |
175 | 175 | ||
176 | while (tree_ctx.count == 1) { | 176 | while (tree_ctx.count == 1) { |
177 | cgit_tree_link(name, NULL, "ls-dir", ctx.qry.head, rev, | 177 | cgit_tree_link(name, NULL, "ls-dir", ctx.qry.head, rev, |
@@ -198,7 +198,7 @@ static void write_tree_link(const unsigned char *sha1, char *name, | |||
198 | strbuf_setlen(fullpath, initial_length); | 198 | strbuf_setlen(fullpath, initial_length); |
199 | } | 199 | } |
200 | 200 | ||
201 | static int ls_item(const unsigned char *sha1, struct strbuf *base, | 201 | static int ls_item(const struct object_id *oid, struct strbuf *base, |
202 | const char *pathname, unsigned mode, int stage, void *cbdata) | 202 | const char *pathname, unsigned mode, int stage, void *cbdata) |
203 | { | 203 | { |
204 | struct walk_tree_context *walk_tree_ctx = cbdata; | 204 | struct walk_tree_context *walk_tree_ctx = cbdata; |
@@ -213,11 +213,11 @@ static int ls_item(const unsigned char *sha1, struct strbuf *base, | |||
213 | ctx.qry.path ? "/" : "", name); | 213 | ctx.qry.path ? "/" : "", name); |
214 | 214 | ||
215 | if (!S_ISGITLINK(mode)) { | 215 | if (!S_ISGITLINK(mode)) { |
216 | type = sha1_object_info(sha1, &size); | 216 | type = oid_object_info(the_repository, oid, &size); |
217 | if (type == OBJ_BAD) { | 217 | if (type == OBJ_BAD) { |
218 | htmlf("<tr><td colspan='3'>Bad object: %s %s</td></tr>", | 218 | htmlf("<tr><td colspan='3'>Bad object: %s %s</td></tr>", |
219 | name, | 219 | name, |
220 | sha1_to_hex(sha1)); | 220 | oid_to_hex(oid)); |
221 | free(name); | 221 | free(name); |
222 | return 0; | 222 | return 0; |
223 | } | 223 | } |
@@ -227,9 +227,9 @@ static int ls_item(const unsigned char *sha1, struct strbuf *base, | |||
227 | cgit_print_filemode(mode); | 227 | cgit_print_filemode(mode); |
228 | html("</td><td>"); | 228 | html("</td><td>"); |
229 | if (S_ISGITLINK(mode)) { | 229 | if (S_ISGITLINK(mode)) { |
230 | cgit_submodule_link("ls-mod", fullpath.buf, sha1_to_hex(sha1)); | 230 | cgit_submodule_link("ls-mod", fullpath.buf, oid_to_hex(oid)); |
231 | } else if (S_ISDIR(mode)) { | 231 | } else if (S_ISDIR(mode)) { |
232 | write_tree_link(sha1, name, walk_tree_ctx->curr_rev, | 232 | write_tree_link(oid, name, walk_tree_ctx->curr_rev, |
233 | &fullpath); | 233 | &fullpath); |
234 | } else { | 234 | } else { |
235 | char *ext = strrchr(name, '.'); | 235 | char *ext = strrchr(name, '.'); |
@@ -289,7 +289,7 @@ static void ls_tree(const struct object_id *oid, char *path, struct walk_tree_co | |||
289 | tree = parse_tree_indirect(oid); | 289 | tree = parse_tree_indirect(oid); |
290 | if (!tree) { | 290 | if (!tree) { |
291 | cgit_print_error_page(404, "Not found", | 291 | cgit_print_error_page(404, "Not found", |
292 | "Not a tree object: %s", sha1_to_hex(oid->hash)); | 292 | "Not a tree object: %s", oid_to_hex(oid)); |
293 | return; | 293 | return; |
294 | } | 294 | } |
295 | 295 | ||
@@ -299,7 +299,7 @@ static void ls_tree(const struct object_id *oid, char *path, struct walk_tree_co | |||
299 | } | 299 | } |
300 | 300 | ||
301 | 301 | ||
302 | static int walk_tree(const unsigned char *sha1, struct strbuf *base, | 302 | static int walk_tree(const struct object_id *oid, struct strbuf *base, |
303 | const char *pathname, unsigned mode, int stage, void *cbdata) | 303 | const char *pathname, unsigned mode, int stage, void *cbdata) |
304 | { | 304 | { |
305 | struct walk_tree_context *walk_tree_ctx = cbdata; | 305 | struct walk_tree_context *walk_tree_ctx = cbdata; |
@@ -320,12 +320,12 @@ static int walk_tree(const unsigned char *sha1, struct strbuf *base, | |||
320 | return READ_TREE_RECURSIVE; | 320 | return READ_TREE_RECURSIVE; |
321 | } else { | 321 | } else { |
322 | walk_tree_ctx->state = 2; | 322 | walk_tree_ctx->state = 2; |
323 | print_object(sha1, buffer.buf, pathname, walk_tree_ctx->curr_rev); | 323 | print_object(oid, buffer.buf, pathname, walk_tree_ctx->curr_rev); |
324 | strbuf_release(&buffer); | 324 | strbuf_release(&buffer); |
325 | return 0; | 325 | return 0; |
326 | } | 326 | } |
327 | } | 327 | } |
328 | ls_item(sha1, base, pathname, mode, stage, walk_tree_ctx); | 328 | ls_item(oid, base, pathname, mode, stage, walk_tree_ctx); |
329 | return 0; | 329 | return 0; |
330 | } | 330 | } |
331 | 331 | ||
@@ -369,11 +369,11 @@ void cgit_print_tree(const char *rev, char *path) | |||
369 | walk_tree_ctx.curr_rev = xstrdup(rev); | 369 | walk_tree_ctx.curr_rev = xstrdup(rev); |
370 | 370 | ||
371 | if (path == NULL) { | 371 | if (path == NULL) { |
372 | ls_tree(&commit->tree->object.oid, NULL, &walk_tree_ctx); | 372 | ls_tree(&commit->maybe_tree->object.oid, NULL, &walk_tree_ctx); |
373 | goto cleanup; | 373 | goto cleanup; |
374 | } | 374 | } |
375 | 375 | ||
376 | read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx); | 376 | read_tree_recursive(commit->maybe_tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx); |
377 | if (walk_tree_ctx.state == 1) | 377 | if (walk_tree_ctx.state == 1) |
378 | ls_tail(); | 378 | ls_tail(); |
379 | else if (walk_tree_ctx.state == 2) | 379 | else if (walk_tree_ctx.state == 2) |