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>
@@ -49,7 +49,7 @@ unsigned long line = 0;
char *detail = emit_suspect_detail(suspect); html("<span class='sha1'>"); - cgit_commit_link(find_unique_abbrev(oid->hash, DEFAULT_ABBREV), detail, + cgit_commit_link(find_unique_abbrev(oid, DEFAULT_ABBREV), detail, NULL, ctx.qry.head, oid_to_hex(oid), suspect->path); html("</span>"); free(detail);@@ -98,7 +98,7 @@ int match_baselen;
int state; }; -static void print_object(const unsigned char *sha1, const char *path, +static void print_object(const struct object_id *oid, const char *path, const char *basename, const char *rev) { enum object_type type;@@ -110,17 +110,17 @@ struct blame_scoreboard sb;
struct blame_origin *o; struct blame_entry *ent = NULL; - type = sha1_object_info(sha1, &size); + type = oid_object_info(the_repository, oid, &size); if (type == OBJ_BAD) { cgit_print_error_page(404, "Not found", "Bad object name: %s", - sha1_to_hex(sha1)); + oid_to_hex(oid)); return; } - buf = read_sha1_file(sha1, &type, &size); + buf = read_object_file(oid, &type, &size); if (!buf) { cgit_print_error_page(500, "Internal server error", - "Error reading object %s", sha1_to_hex(sha1)); + "Error reading object %s", oid_to_hex(oid)); return; }@@ -144,7 +144,7 @@
cgit_set_title_from_path(path); cgit_print_layout_start(); - htmlf("blob: %s (", sha1_to_hex(sha1)); + htmlf("blob: %s (", oid_to_hex(oid)); cgit_plain_link("plain", NULL, NULL, ctx.qry.head, rev, path); html(") ("); cgit_tree_link("tree", NULL, NULL, ctx.qry.head, rev, path);@@ -218,7 +218,7 @@ cleanup:
free(buf); } -static int walk_tree(const unsigned char *sha1, struct strbuf *base, +static int walk_tree(const struct object_id *oid, struct strbuf *base, const char *pathname, unsigned mode, int stage, void *cbdata) {@@ -229,7 +229,7 @@ if (S_ISREG(mode)) {
struct strbuf buffer = STRBUF_INIT; strbuf_addbuf(&buffer, base); strbuf_addstr(&buffer, pathname); - print_object(sha1, buffer.buf, pathname, + print_object(oid, buffer.buf, pathname, walk_tree_ctx->curr_rev); strbuf_release(&buffer); walk_tree_ctx->state = 1;@@ -289,7 +289,7 @@ walk_tree_ctx.curr_rev = xstrdup(rev);
walk_tree_ctx.match_baselen = (path_items.match) ? basedir_len(path_items.match) : -1; - read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree, + read_tree_recursive(commit->maybe_tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx); if (!walk_tree_ctx.state) cgit_print_error_page(404, "Not found", "Not found");
@@ -18,7 +18,7 @@ unsigned int found_path:1;
unsigned int file_only:1; }; -static int walk_tree(const unsigned char *sha1, struct strbuf *base, +static int walk_tree(const struct object_id *oid, struct strbuf *base, const char *pathname, unsigned mode, int stage, void *cbdata) { struct walk_tree_context *walk_tree_ctx = cbdata;@@ -28,7 +28,7 @@ return READ_TREE_RECURSIVE;
if (strncmp(base->buf, walk_tree_ctx->match_path, base->len) || strcmp(walk_tree_ctx->match_path + base->len, pathname)) return READ_TREE_RECURSIVE; - hashcpy(walk_tree_ctx->matched_oid->hash, sha1); + oidcpy(walk_tree_ctx->matched_oid, oid); walk_tree_ctx->found_path = 1; return 0; }@@ -54,9 +54,9 @@ };
if (get_oid(ref, &oid)) goto done; - if (sha1_object_info(oid.hash, &size) != OBJ_COMMIT) + if (oid_object_info(the_repository, &oid, &size) != OBJ_COMMIT) goto done; - read_tree_recursive(lookup_commit_reference(&oid)->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx); + read_tree_recursive(lookup_commit_reference(&oid)->maybe_tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx); done: free(path_items.match);@@ -87,17 +87,17 @@ };
if (get_oid(head, &oid)) return -1; - type = sha1_object_info(oid.hash, &size); + type = oid_object_info(the_repository, &oid, &size); if (type == OBJ_COMMIT) { commit = lookup_commit_reference(&oid); - read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx); + read_tree_recursive(commit->maybe_tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx); if (!walk_tree_ctx.found_path) return -1; - type = sha1_object_info(oid.hash, &size); + type = oid_object_info(the_repository, &oid, &size); } if (type == OBJ_BAD) return -1; - buf = read_sha1_file(oid.hash, &type, &size); + buf = read_object_file(&oid, &type, &size); if (!buf) return -1; buf[size] = '\0';@@ -142,12 +142,12 @@ return;
} } - type = sha1_object_info(oid.hash, &size); + type = oid_object_info(the_repository, &oid, &size); if ((!hex) && type == OBJ_COMMIT && path) { commit = lookup_commit_reference(&oid); - read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx); - type = sha1_object_info(oid.hash, &size); + read_tree_recursive(commit->maybe_tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx); + type = oid_object_info(the_repository, &oid, &size); } if (type == OBJ_BAD) {@@ -156,7 +156,7 @@ "Bad object name: %s", hex);
return; } - buf = read_sha1_file(oid.hash, &type, &size); + buf = read_object_file(&oid, &type, &size); if (!buf) { cgit_print_error_page(500, "Internal server error", "Error reading object %s", hex);
@@ -12,6 +12,7 @@ #include "ui-clone.h"
#include "html.h" #include "ui-shared.h" #include "packfile.h" +#include "object-store.h" static int print_ref_info(const char *refname, const struct object_id *oid, int flags, void *cb_data)@@ -38,8 +39,8 @@
ctx.page.mimetype = "text/plain"; ctx.page.filename = "objects/info/packs"; cgit_print_http_headers(); - prepare_packed_git(); - for (pack = packed_git; pack; pack = pack->next) { + reprepare_packed_git(the_repository); + for (pack = get_packed_git(the_repository); pack; pack = pack->next) { if (pack->pack_local) { offset = strrchr(pack->pack_name, '/'); if (offset && offset[1] != '\0')
@@ -78,7 +78,7 @@ cgit_patch_link("patch", NULL, NULL, NULL, tmp, prefix);
html(")</td></tr>\n"); html("<tr><th>tree</th><td colspan='2' class='sha1'>"); tmp = xstrdup(hex); - cgit_tree_link(oid_to_hex(&commit->tree->object.oid), NULL, NULL, + cgit_tree_link(oid_to_hex(&commit->maybe_tree->object.oid), NULL, NULL, ctx.qry.head, tmp, NULL); if (prefix) { html(" /");
@@ -258,8 +258,8 @@ if (mode2 == 0)
htmlf("<br/>deleted file mode %.6o", mode1); if (!subproject) { - abbrev1 = xstrdup(find_unique_abbrev(oid1->hash, DEFAULT_ABBREV)); - abbrev2 = xstrdup(find_unique_abbrev(oid2->hash, DEFAULT_ABBREV)); + abbrev1 = xstrdup(find_unique_abbrev(oid1, DEFAULT_ABBREV)); + abbrev2 = xstrdup(find_unique_abbrev(oid2, DEFAULT_ABBREV)); htmlf("<br/>index %s..%s", abbrev1, abbrev2); free(abbrev1); free(abbrev2);@@ -413,7 +413,7 @@ cgit_print_error_page(404, "Not found",
"Bad commit: %s", oid_to_hex(new_rev_oid)); return; } - new_tree_oid = &commit->tree->object.oid; + new_tree_oid = &commit->maybe_tree->object.oid; if (old_rev) { if (get_oid(old_rev, old_rev_oid)) {@@ -434,7 +434,7 @@ cgit_print_error_page(404, "Not found",
"Bad commit: %s", oid_to_hex(old_rev_oid)); return; } - old_tree_oid = &commit2->tree->object.oid; + old_tree_oid = &commit2->maybe_tree->object.oid; } else { old_tree_oid = NULL; }
@@ -153,8 +153,8 @@ add_lines = 0;
rem_lines = 0; revs->diffopt.flags.recursive = 1; - diff_tree_oid(&parent->tree->object.oid, - &commit->tree->object.oid, + diff_tree_oid(&parent->maybe_tree->object.oid, + &commit->maybe_tree->object.oid, "", &revs->diffopt); diffcore_std(&revs->diffopt);
@@ -16,19 +16,19 @@ int match_baselen;
int match; }; -static int print_object(const unsigned char *sha1, const char *path) +static int print_object(const struct object_id *oid, const char *path) { enum object_type type; char *buf, *mimetype; unsigned long size; - type = sha1_object_info(sha1, &size); + type = oid_object_info(the_repository, oid, &size); if (type == OBJ_BAD) { cgit_print_error_page(404, "Not found", "Not found"); return 0; } - buf = read_sha1_file(sha1, &type, &size); + buf = read_object_file(oid, &type, &size); if (!buf) { cgit_print_error_page(404, "Not found", "Not found"); return 0;@@ -57,7 +57,7 @@ }
} ctx.page.filename = path; ctx.page.size = size; - ctx.page.etag = sha1_to_hex(sha1); + ctx.page.etag = oid_to_hex(oid); cgit_print_http_headers(); html_raw(buf, size); free(mimetype);@@ -73,7 +73,7 @@ else
return fmtalloc("%.*s/", baselen, base); } -static void print_dir(const unsigned char *sha1, const char *base, +static void print_dir(const struct object_id *oid, const char *base, int baselen, const char *path) { char *fullpath, *slash;@@ -81,7 +81,7 @@ size_t len;
fullpath = buildpath(base, baselen, path); slash = (fullpath[0] == '/' ? "" : "/"); - ctx.page.etag = sha1_to_hex(sha1); + ctx.page.etag = oid_to_hex(oid); cgit_print_http_headers(); htmlf("<html><head><title>%s", slash); html_txt(fullpath);@@ -106,7 +106,7 @@ }
free(fullpath); } -static void print_dir_entry(const unsigned char *sha1, const char *base, +static void print_dir_entry(const struct object_id *oid, const char *base, int baselen, const char *path, unsigned mode) { char *fullpath;@@ -116,7 +116,7 @@ if (!S_ISDIR(mode) && !S_ISGITLINK(mode))
fullpath[strlen(fullpath) - 1] = 0; html(" <li>"); if (S_ISGITLINK(mode)) { - cgit_submodule_link(NULL, fullpath, sha1_to_hex(sha1)); + cgit_submodule_link(NULL, fullpath, oid_to_hex(oid)); } else cgit_plain_link(path, NULL, NULL, ctx.qry.head, ctx.qry.sha1, fullpath);@@ -129,22 +129,22 @@ {
html(" </ul>\n</body></html>\n"); } -static int walk_tree(const unsigned char *sha1, struct strbuf *base, +static int walk_tree(const struct object_id *oid, struct strbuf *base, const char *pathname, unsigned mode, int stage, void *cbdata) { struct walk_tree_context *walk_tree_ctx = cbdata; if (base->len == walk_tree_ctx->match_baselen) { if (S_ISREG(mode) || S_ISLNK(mode)) { - if (print_object(sha1, pathname)) + if (print_object(oid, pathname)) walk_tree_ctx->match = 1; } else if (S_ISDIR(mode)) { - print_dir(sha1, base->buf, base->len, pathname); + print_dir(oid, base->buf, base->len, pathname); walk_tree_ctx->match = 2; return READ_TREE_RECURSIVE; } } else if (base->len < INT_MAX && (int)base->len > walk_tree_ctx->match_baselen) { - print_dir_entry(sha1, base->buf, base->len, pathname, mode); + print_dir_entry(oid, base->buf, base->len, pathname, mode); walk_tree_ctx->match = 2; } else if (S_ISDIR(mode)) { return READ_TREE_RECURSIVE;@@ -193,12 +193,12 @@ }
if (!path_items.match) { path_items.match = ""; walk_tree_ctx.match_baselen = -1; - print_dir(commit->tree->object.oid.hash, "", 0, ""); + print_dir(&commit->maybe_tree->object.oid, "", 0, ""); walk_tree_ctx.match = 2; } else walk_tree_ctx.match_baselen = basedir_len(path_items.match); - read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx); + read_tree_recursive(commit->maybe_tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx); if (!walk_tree_ctx.match) cgit_print_error_page(404, "Not found", "Not found"); else if (walk_tree_ctx.match == 2)
@@ -174,7 +174,7 @@ "No signature for %s", archive);
return 0; } - buf = read_sha1_file(note->hash, &type, &size); + buf = read_object_file(note, &type, &size); if (!buf) { cgit_print_error_page(404, "Not found", "Not found"); return 0;
@@ -84,30 +84,30 @@ }
html("</table>\n"); } -static void print_object(const unsigned char *sha1, char *path, const char *basename, const char *rev) +static void print_object(const struct object_id *oid, char *path, const char *basename, const char *rev) { enum object_type type; char *buf; unsigned long size; - type = sha1_object_info(sha1, &size); + type = oid_object_info(the_repository, oid, &size); if (type == OBJ_BAD) { cgit_print_error_page(404, "Not found", - "Bad object name: %s", sha1_to_hex(sha1)); + "Bad object name: %s", oid_to_hex(oid)); return; } - buf = read_sha1_file(sha1, &type, &size); + buf = read_object_file(oid, &type, &size); if (!buf) { cgit_print_error_page(500, "Internal server error", - "Error reading object %s", sha1_to_hex(sha1)); + "Error reading object %s", oid_to_hex(oid)); return; } cgit_set_title_from_path(path); cgit_print_layout_start(); - htmlf("blob: %s (", sha1_to_hex(sha1)); + htmlf("blob: %s (", oid_to_hex(oid)); cgit_plain_link("plain", NULL, NULL, ctx.qry.head, rev, path); if (ctx.cfg.enable_blame) {@@ -138,7 +138,7 @@ char *name;
size_t count; }; -static int single_tree_cb(const unsigned char *sha1, struct strbuf *base, +static int single_tree_cb(const struct object_id *oid, struct strbuf *base, const char *pathname, unsigned mode, int stage, void *cbdata) {@@ -153,12 +153,12 @@ return -1;
} ctx->name = xstrdup(pathname); - hashcpy(ctx->oid.hash, sha1); + oidcpy(&ctx->oid, oid); strbuf_addf(ctx->path, "/%s", pathname); return 0; } -static void write_tree_link(const unsigned char *sha1, char *name, +static void write_tree_link(const struct object_id *oid, char *name, char *rev, struct strbuf *fullpath) { size_t initial_length = fullpath->len;@@ -171,7 +171,7 @@ struct pathspec paths = {
.nr = 0 }; - hashcpy(tree_ctx.oid.hash, sha1); + oidcpy(&tree_ctx.oid, oid); while (tree_ctx.count == 1) { cgit_tree_link(name, NULL, "ls-dir", ctx.qry.head, rev,@@ -198,7 +198,7 @@
strbuf_setlen(fullpath, initial_length); } -static int ls_item(const unsigned char *sha1, struct strbuf *base, +static int ls_item(const struct object_id *oid, struct strbuf *base, const char *pathname, unsigned mode, int stage, void *cbdata) { struct walk_tree_context *walk_tree_ctx = cbdata;@@ -213,11 +213,11 @@ strbuf_addf(&fullpath, "%s%s%s", ctx.qry.path ? ctx.qry.path : "",
ctx.qry.path ? "/" : "", name); if (!S_ISGITLINK(mode)) { - type = sha1_object_info(sha1, &size); + type = oid_object_info(the_repository, oid, &size); if (type == OBJ_BAD) { htmlf("<tr><td colspan='3'>Bad object: %s %s</td></tr>", name, - sha1_to_hex(sha1)); + oid_to_hex(oid)); free(name); return 0; }@@ -227,9 +227,9 @@ html("<tr><td class='ls-mode'>");
cgit_print_filemode(mode); html("</td><td>"); if (S_ISGITLINK(mode)) { - cgit_submodule_link("ls-mod", fullpath.buf, sha1_to_hex(sha1)); + cgit_submodule_link("ls-mod", fullpath.buf, oid_to_hex(oid)); } else if (S_ISDIR(mode)) { - write_tree_link(sha1, name, walk_tree_ctx->curr_rev, + write_tree_link(oid, name, walk_tree_ctx->curr_rev, &fullpath); } else { char *ext = strrchr(name, '.');@@ -289,7 +289,7 @@
tree = parse_tree_indirect(oid); if (!tree) { cgit_print_error_page(404, "Not found", - "Not a tree object: %s", sha1_to_hex(oid->hash)); + "Not a tree object: %s", oid_to_hex(oid)); return; }@@ -299,7 +299,7 @@ ls_tail();
} -static int walk_tree(const unsigned char *sha1, struct strbuf *base, +static int walk_tree(const struct object_id *oid, struct strbuf *base, const char *pathname, unsigned mode, int stage, void *cbdata) { struct walk_tree_context *walk_tree_ctx = cbdata;@@ -320,12 +320,12 @@ ls_head();
return READ_TREE_RECURSIVE; } else { walk_tree_ctx->state = 2; - print_object(sha1, buffer.buf, pathname, walk_tree_ctx->curr_rev); + print_object(oid, buffer.buf, pathname, walk_tree_ctx->curr_rev); strbuf_release(&buffer); return 0; } } - ls_item(sha1, base, pathname, mode, stage, walk_tree_ctx); + ls_item(oid, base, pathname, mode, stage, walk_tree_ctx); return 0; }@@ -369,11 +369,11 @@
walk_tree_ctx.curr_rev = xstrdup(rev); if (path == NULL) { - ls_tree(&commit->tree->object.oid, NULL, &walk_tree_ctx); + ls_tree(&commit->maybe_tree->object.oid, NULL, &walk_tree_ctx); goto cleanup; } - read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx); + read_tree_recursive(commit->maybe_tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx); if (walk_tree_ctx.state == 1) ls_tail(); else if (walk_tree_ctx.state == 2)