diff options
author | Vincent Ambo <tazjin@google.com> | 2020-05-22T16·46+0100 |
---|---|---|
committer | Vincent Ambo <tazjin@google.com> | 2020-05-22T16·46+0100 |
commit | 5229c9b232de5bfa959ad6ebbb4c8192ac513352 (patch) | |
tree | 8539e7e23682cac110900f946f034ae44162cacd /third_party/git/builtin/index-pack.c | |
parent | f2b211131f2347342dde63975b09cf603149f1a3 (diff) | |
parent | 8518a7a51faaf50f830646d4c3585f51236b9349 (diff) |
merge(3p/git): Merge git upstream at v2.26.2 r/808
Diffstat (limited to 'third_party/git/builtin/index-pack.c')
-rw-r--r-- | third_party/git/builtin/index-pack.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/third_party/git/builtin/index-pack.c b/third_party/git/builtin/index-pack.c index 0d55f73b0b44..d967d188a307 100644 --- a/third_party/git/builtin/index-pack.c +++ b/third_party/git/builtin/index-pack.c @@ -14,7 +14,7 @@ #include "thread-utils.h" #include "packfile.h" #include "object-store.h" -#include "fetch-object.h" +#include "promisor-remote.h" static const char index_pack_usage[] = "git index-pack [-v] [-o <index-file>] [--keep | --keep=<msg>] [--verify] [--strict] (<pack-file> | --stdin [--fix-thin] [<pack-file>])"; @@ -757,7 +757,8 @@ static int check_collison(struct object_entry *entry) memset(&data, 0, sizeof(data)); data.entry = entry; - data.st = open_istream(&entry->idx.oid, &type, &size, NULL); + data.st = open_istream(the_repository, &entry->idx.oid, &type, &size, + NULL); if (!data.st) return -1; if (size != entry->size || type != entry->type) @@ -948,7 +949,7 @@ static void resolve_delta(struct object_entry *delta_obj, free(delta_data); if (!result->data) bad_object(delta_obj->idx.offset, _("failed to apply delta")); - hash_object_file(result->data, result->size, + hash_object_file(the_hash_algo, result->data, result->size, type_name(delta_obj->real_type), &delta_obj->idx.oid); sha1_object(result->data, NULL, result->size, delta_obj->real_type, &delta_obj->idx.oid); @@ -1003,7 +1004,9 @@ static struct base_data *find_unresolved_deltas_1(struct base_data *base, if (!compare_and_swap_type(&child->real_type, OBJ_REF_DELTA, base->obj->real_type)) - BUG("child->real_type != OBJ_REF_DELTA"); + die("REF_DELTA at offset %"PRIuMAX" already resolved (duplicate base %s?)", + (uintmax_t)child->idx.offset, + oid_to_hex(&base->obj->idx.oid)); resolve_delta(child, base, result); if (base->ref_first == base->ref_last && base->ofs_last == -1) @@ -1352,7 +1355,7 @@ static void fix_unresolved_deltas(struct hashfile *f) sorted_by_pos[i] = &ref_deltas[i]; QSORT(sorted_by_pos, nr_ref_deltas, delta_pos_compare); - if (repository_format_partial_clone) { + if (has_promisor_remote()) { /* * Prefetch the delta bases. */ @@ -1366,8 +1369,8 @@ static void fix_unresolved_deltas(struct hashfile *f) oid_array_append(&to_fetch, &d->oid); } if (to_fetch.nr) - fetch_objects(repository_format_partial_clone, - to_fetch.oid, to_fetch.nr); + promisor_remote_get_direct(the_repository, + to_fetch.oid, to_fetch.nr); oid_array_clear(&to_fetch); } @@ -1383,8 +1386,9 @@ static void fix_unresolved_deltas(struct hashfile *f) if (!base_obj->data) continue; - if (check_object_signature(&d->oid, base_obj->data, - base_obj->size, type_name(type))) + if (check_object_signature(the_repository, &d->oid, + base_obj->data, base_obj->size, + type_name(type))) die(_("local object %s is corrupt"), oid_to_hex(&d->oid)); base_obj->obj = append_obj_to_pack(f, d->oid.hash, base_obj->data, base_obj->size, type); @@ -1490,11 +1494,11 @@ static void final(const char *final_pack_name, const char *curr_pack_name, } if (!from_stdin) { - printf("%s\n", sha1_to_hex(hash)); + printf("%s\n", hash_to_hex(hash)); } else { struct strbuf buf = STRBUF_INIT; - strbuf_addf(&buf, "%s\t%s\n", report, sha1_to_hex(hash)); + strbuf_addf(&buf, "%s\t%s\n", report, hash_to_hex(hash)); write_or_die(1, buf.buf, buf.len); strbuf_release(&buf); |