diff --git a/builtin/clone.c b/builtin/clone.c index f9a2ecbe9cc944793203d722b42573e779575c5a..90922a2984eedeca8cf22e725f80815ad8606d20 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -171,7 +171,7 @@ static int add_one_reference(struct string_list_item *item, void *cb_data) } else { struct strbuf sb = STRBUF_INIT; strbuf_addf(&sb, "%s/objects", ref_git); - add_to_alternates_file(sb.buf); + add_to_alternates_file(the_repository, sb.buf); strbuf_release(&sb); } @@ -212,12 +212,12 @@ static void copy_alternates(struct strbuf *src, const char *src_repo) if (!line.len || line.buf[0] == '#') continue; if (is_absolute_path(line.buf)) { - add_to_alternates_file(line.buf); + add_to_alternates_file(the_repository, line.buf); continue; } abs_path = mkpathdup("%s/objects/%s", src_repo, line.buf); if (!normalize_path_copy(abs_path, abs_path)) - add_to_alternates_file(abs_path); + add_to_alternates_file(the_repository, abs_path); else warning("skipping invalid relative alternate: %s/%s", src_repo, line.buf); @@ -350,7 +350,7 @@ static void clone_local(const char *src_repo, const char *dest_repo) struct strbuf alt = STRBUF_INIT; get_common_dir(&alt, src_repo); strbuf_addstr(&alt, "/objects"); - add_to_alternates_file(alt.buf); + add_to_alternates_file(the_repository, alt.buf); strbuf_release(&alt); } else { struct strbuf src = STRBUF_INIT; diff --git a/builtin/count-objects.c b/builtin/count-objects.c index 1e89148ed742a861903a15a1fca4bb95a925ac56..8fd50670d1e31f6a3dbec122138167be995b096d 100644 --- a/builtin/count-objects.c +++ b/builtin/count-objects.c @@ -159,7 +159,7 @@ int cmd_count_objects(int argc, printf("prune-packable: %lu\n", packed_loose); printf("garbage: %lu\n", garbage); printf("size-garbage: %s\n", garbage_buf.buf); - foreach_alt_odb(print_alternate, NULL); + foreach_alt_odb(the_repository, print_alternate, NULL); strbuf_release(&loose_buf); strbuf_release(&pack_buf); strbuf_release(&garbage_buf); diff --git a/builtin/hash-object.c b/builtin/hash-object.c index a25f0403f444af8917c5971d2bf56100bf3a5126..0108663502ce6d1bf90fc3076b051ea4ee44743c 100644 --- a/builtin/hash-object.c +++ b/builtin/hash-object.c @@ -32,8 +32,8 @@ static int hash_literally(struct object_id *oid, int fd, const char *type, unsig if (strbuf_read(&buf, fd, 4096) < 0) ret = -1; else - ret = write_object_file_literally(buf.buf, buf.len, type, oid, - flags); + ret = write_object_file_literally(the_repository, buf.buf, + buf.len, type, oid, flags); close(fd); strbuf_release(&buf); return ret; diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 58a9b1612626e0fca9c403b5ed9744d80757227e..7a57dd69b20dd602488ed2dcb982defcb5165cf9 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -1616,7 +1616,7 @@ static int want_object_in_pack(const struct object_id *oid, struct list_head *pos; struct multi_pack_index *m; - if (!exclude && local && has_loose_object_nonlocal(oid)) + if (!exclude && local && has_loose_object_nonlocal(the_repository, oid)) return 0; /* @@ -3608,7 +3608,7 @@ static void add_cruft_object_entry(const struct object_id *oid, enum object_type } else { if (!want_object_in_pack(oid, 0, &pack, &offset)) return; - if (!pack && type == OBJ_BLOB && !has_loose_object(oid)) { + if (!pack && type == OBJ_BLOB && !has_loose_object(the_repository, oid)) { /* * If a traversed tree has a missing blob then we want * to avoid adding that missing object to our pack. @@ -4074,7 +4074,7 @@ static void loosen_unused_packed_objects(void) if (!packlist_find(&to_pack, &oid) && !has_sha1_pack_kept_or_nonlocal(&oid) && !loosened_object_can_be_discarded(&oid, p->mtime)) { - if (force_object_loose(&oid, p->mtime)) + if (force_object_loose(the_repository, &oid, p->mtime)) die(_("unable to force loose object")); loosened_objects_nr++; } diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c index 129305700c7576a1da283209ee6f09a66d082529..f917d6a246bf9ca5d7358ff18968f525c9bf2605 100644 --- a/builtin/receive-pack.c +++ b/builtin/receive-pack.c @@ -357,7 +357,7 @@ static void write_head_info(void) refs_for_each_fullref_in(get_main_ref_store(the_repository), "", exclude_patterns, show_ref_cb, &seen); - for_each_alternate_ref(show_one_alternate_ref, &seen); + for_each_alternate_ref(the_repository, show_one_alternate_ref, &seen); oidset_clear(&seen); strvec_clear(&excludes_vector); @@ -2252,7 +2252,7 @@ static const char *unpack(int err_fd, struct shallow_info *si) * processes that do the heavy lifting, but we may need to see these * objects ourselves to set up shallow information. */ - tmp_objdir_add_as_alternate(tmp_objdir); + tmp_objdir_add_as_alternate(the_repository, tmp_objdir); if (ntohl(hdr.hdr_entries) < unpack_limit) { strvec_push(&child.args, "unpack-objects"); diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index f9b970f8a64a54f198c56ef272b8f20b9999c59f..7aefdfba8cbec8d00dc23f36b279ba428b7c4bb3 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -1668,7 +1668,7 @@ static void prepare_possible_alternates(const char *sm_name, die(_("Value '%s' for submodule.alternateErrorStrategy is not recognized"), error_strategy); if (!strcmp(sm_alternate, "superproject")) - foreach_alt_odb(add_possible_reference_from_superproject, &sas); + foreach_alt_odb(the_repository, add_possible_reference_from_superproject, &sas); else if (!strcmp(sm_alternate, "no")) ; /* do nothing */ else diff --git a/diagnose.c b/diagnose.c index bd485effea22ce400c4300a1e085b45204a3b42e..51b243da9ec07c4317e471e63094df07ca3737ed 100644 --- a/diagnose.c +++ b/diagnose.c @@ -229,7 +229,7 @@ int create_diagnostics_archive(struct repository *r, strbuf_reset(&buf); strbuf_addstr(&buf, "--add-virtual-file=packs-local.txt:"); dir_file_stats(r->objects->odb, &buf); - foreach_alt_odb(dir_file_stats, &buf); + foreach_alt_odb(r, dir_file_stats, &buf); strvec_push(&archiver_args, buf.buf); strbuf_reset(&buf); diff --git a/fetch-pack.c b/fetch-pack.c index 1ed5e11dd56857e8ef3229951e304d6b41cf131c..7e21b341631b9086055636ff2688d8b4d8a386cc 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -115,7 +115,7 @@ static void for_each_cached_alternate(struct fetch_negotiator *negotiator, size_t i; if (!initialized) { - for_each_alternate_ref(cache_one_alternate, &cache); + for_each_alternate_ref(the_repository, cache_one_alternate, &cache); initialized = 1; } diff --git a/object-file.c b/object-file.c index 00c3a4b910f84c9a300a0923190f83ff459ad015..5fb602be9bc0563150e16e9fe2b76c8e3282d935 100644 --- a/object-file.c +++ b/object-file.c @@ -720,7 +720,7 @@ static void read_info_alternates(struct repository *r, free(path); } -void add_to_alternates_file(const char *reference) +void add_to_alternates_file(struct repository *r, const char *reference) { struct lock_file lock = LOCK_INIT; char *alts = git_pathdup("objects/info/alternates"); @@ -756,26 +756,26 @@ void add_to_alternates_file(const char *reference) fprintf_or_die(out, "%s\n", reference); if (commit_lock_file(&lock)) die_errno(_("unable to move new alternates file into place")); - if (the_repository->objects->loaded_alternates) - link_alt_odb_entries(the_repository, reference, - '\n', NULL, 0); + if (r->objects->loaded_alternates) + link_alt_odb_entries(r, reference, '\n', NULL, 0); } free(alts); } -void add_to_alternates_memory(const char *reference) +void add_to_alternates_memory(struct repository *r, const char *reference) { /* * Make sure alternates are initialized, or else our entry may be * overwritten when they are. */ - prepare_alt_odb(the_repository); + prepare_alt_odb(r); - link_alt_odb_entries(the_repository, reference, - '\n', NULL, 0); + link_alt_odb_entries(r, reference, '\n', NULL, 0); } -struct object_directory *set_temporary_primary_odb(const char *dir, int will_destroy) +struct object_directory *set_temporary_primary_odb(struct repository *r, + const char *dir, + int will_destroy) { struct object_directory *new_odb; @@ -783,7 +783,7 @@ struct object_directory *set_temporary_primary_odb(const char *dir, int will_des * Make sure alternates are initialized, or else our entry may be * overwritten when they are. */ - prepare_alt_odb(the_repository); + prepare_alt_odb(r); /* * Make a new primary odb and link the old primary ODB in as an @@ -798,14 +798,15 @@ struct object_directory *set_temporary_primary_odb(const char *dir, int will_des */ new_odb->disable_ref_updates = 1; new_odb->will_destroy = will_destroy; - new_odb->next = the_repository->objects->odb; - the_repository->objects->odb = new_odb; + new_odb->next = r->objects->odb; + r->objects->odb = new_odb; return new_odb->next; } -void restore_primary_odb(struct object_directory *restore_odb, const char *old_path) +void restore_primary_odb(struct repository *r, struct object_directory *restore_odb, + const char *old_path) { - struct object_directory *cur_odb = the_repository->objects->odb; + struct object_directory *cur_odb = r->objects->odb; if (strcmp(old_path, cur_odb->path)) BUG("expected %s as primary object store; found %s", @@ -814,7 +815,7 @@ void restore_primary_odb(struct object_directory *restore_odb, const char *old_p if (cur_odb->next != restore_odb) BUG("we expect the old primary object store to be the first alternate"); - the_repository->objects->odb = restore_odb; + r->objects->odb = restore_odb; free_object_directory(cur_odb); } @@ -999,26 +1000,27 @@ static int refs_from_alternate_cb(struct object_directory *e, return 0; } -void for_each_alternate_ref(alternate_ref_fn fn, void *data) +void for_each_alternate_ref(struct repository *r, alternate_ref_fn fn, + void *data) { struct alternate_refs_data cb; cb.fn = fn; cb.data = data; - foreach_alt_odb(refs_from_alternate_cb, &cb); + foreach_alt_odb(r, refs_from_alternate_cb, &cb); } -int foreach_alt_odb(alt_odb_fn fn, void *cb) +int foreach_alt_odb(struct repository *r, alt_odb_fn fn, void *cb) { struct object_directory *ent; - int r = 0; + int ret = 0; - prepare_alt_odb(the_repository); - for (ent = the_repository->objects->odb->next; ent; ent = ent->next) { - r = fn(ent, cb); - if (r) + prepare_alt_odb(r); + for (ent = r->objects->odb->next; ent; ent = ent->next) { + ret = fn(ent, cb); + if (ret) break; } - return r; + return ret; } void prepare_alt_odb(struct repository *r) @@ -1069,37 +1071,40 @@ static int check_and_freshen_odb(struct object_directory *odb, return check_and_freshen_file(path.buf, freshen); } -static int check_and_freshen_local(const struct object_id *oid, int freshen) +static int check_and_freshen_local(struct repository *r, const struct object_id *oid, + int freshen) { - return check_and_freshen_odb(the_repository->objects->odb, oid, freshen); + return check_and_freshen_odb(r->objects->odb, oid, freshen); } -static int check_and_freshen_nonlocal(const struct object_id *oid, int freshen) +static int check_and_freshen_nonlocal(struct repository *r, const struct object_id *oid, + int freshen) { struct object_directory *odb; - prepare_alt_odb(the_repository); - for (odb = the_repository->objects->odb->next; odb; odb = odb->next) { + prepare_alt_odb(r); + for (odb = r->objects->odb->next; odb; odb = odb->next) { if (check_and_freshen_odb(odb, oid, freshen)) return 1; } return 0; } -static int check_and_freshen(const struct object_id *oid, int freshen) +static int check_and_freshen(struct repository *r, const struct object_id *oid, + int freshen) { - return check_and_freshen_local(oid, freshen) || - check_and_freshen_nonlocal(oid, freshen); + return check_and_freshen_local(r, oid, freshen) || + check_and_freshen_nonlocal(r, oid, freshen); } -int has_loose_object_nonlocal(const struct object_id *oid) +int has_loose_object_nonlocal(struct repository *r, const struct object_id *oid) { - return check_and_freshen_nonlocal(oid, 0); + return check_and_freshen_nonlocal(r, oid, 0); } -int has_loose_object(const struct object_id *oid) +int has_loose_object(struct repository *r, const struct object_id *oid) { - return check_and_freshen(oid, 0); + return check_and_freshen(r, oid, 0); } static void mmap_limit_check(size_t length) @@ -1754,10 +1759,10 @@ static int oid_object_info_convert(struct repository *r, void *content; int ret; - if (repo_oid_to_algop(r, input_oid, the_hash_algo, &oid)) { + if (repo_oid_to_algop(r, input_oid, r->hash_algo, &oid)) { if (do_die) die(_("missing mapping of %s to %s"), - oid_to_hex(input_oid), the_hash_algo->name); + oid_to_hex(input_oid), r->hash_algo->name); return -1; } @@ -1794,7 +1799,7 @@ static int oid_object_info_convert(struct repository *r, return -1; if (type != OBJ_BLOB) { ret = convert_object_file(&outbuf, - the_hash_algo, input_algo, + r->hash_algo, input_algo, content, size, type, !do_die); free(content); if (ret == -1) @@ -1939,7 +1944,7 @@ void *read_object_with_reference(struct repository *r, } ref_length = strlen(ref_type); - if (ref_length + the_hash_algo->hexsz > isize || + if (ref_length + r->hash_algo->hexsz > isize || memcmp(buffer, ref_type, ref_length) || get_oid_hex((char *) buffer + ref_length, &actual_oid)) { free(buffer); @@ -2362,9 +2367,9 @@ static int write_loose_object(const struct object_id *oid, char *hdr, FOF_SKIP_COLLISION_CHECK); } -static int freshen_loose_object(const struct object_id *oid) +static int freshen_loose_object(struct repository *r, const struct object_id *oid) { - return check_and_freshen(oid, 1); + return check_and_freshen(r, oid, 1); } static int freshen_packed_object(const struct object_id *oid) @@ -2460,7 +2465,7 @@ int stream_loose_object(struct input_stream *in_stream, size_t len, die(_("deflateEnd on stream object failed (%d)"), ret); close_loose_object(fd, tmp_file.buf); - if (freshen_packed_object(oid) || freshen_loose_object(oid)) { + if (freshen_packed_object(oid) || freshen_loose_object(the_repository, oid)) { unlink_or_warn(tmp_file.buf); goto cleanup; } @@ -2522,7 +2527,7 @@ int write_object_file_flags(const void *buf, unsigned long len, * it out into .git/objects/??/?{38} file. */ write_object_file_prepare(algo, buf, len, type, oid, hdr, &hdrlen); - if (freshen_packed_object(oid) || freshen_loose_object(oid)) + if (freshen_packed_object(oid) || freshen_loose_object(the_repository, oid)) return 0; if (write_loose_object(oid, hdr, hdrlen, buf, len, 0, flags)) return -1; @@ -2531,14 +2536,13 @@ int write_object_file_flags(const void *buf, unsigned long len, return 0; } -int write_object_file_literally(const void *buf, unsigned long len, - const char *type, struct object_id *oid, - unsigned flags) +int write_object_file_literally(struct repository *r, const void *buf, + unsigned long len, const char *type, + struct object_id *oid, unsigned flags) { char *header; - struct repository *repo = the_repository; - const struct git_hash_algo *algo = repo->hash_algo; - const struct git_hash_algo *compat = repo->compat_hash_algo; + const struct git_hash_algo *algo = r->hash_algo; + const struct git_hash_algo *compat = r->compat_hash_algo; struct object_id compat_oid; int hdrlen, status = 0; int compat_type = -1; @@ -2561,26 +2565,26 @@ int write_object_file_literally(const void *buf, unsigned long len, /* type string, SP, %lu of the length plus NUL must fit this */ hdrlen = strlen(type) + MAX_HEADER_LEN; header = xmalloc(hdrlen); - write_object_file_prepare_literally(the_hash_algo, buf, len, type, + write_object_file_prepare_literally(algo, buf, len, type, oid, header, &hdrlen); if (!(flags & HASH_WRITE_OBJECT)) goto cleanup; - if (freshen_packed_object(oid) || freshen_loose_object(oid)) + if (freshen_packed_object(oid) || freshen_loose_object(r, oid)) goto cleanup; status = write_loose_object(oid, header, hdrlen, buf, len, 0, 0); if (compat_type != -1) - return repo_add_loose_object_map(repo, oid, &compat_oid); + return repo_add_loose_object_map(r, oid, &compat_oid); cleanup: free(header); return status; } -int force_object_loose(const struct object_id *oid, time_t mtime) +int force_object_loose(struct repository *r, const struct object_id *oid, + time_t mtime) { - struct repository *repo = the_repository; - const struct git_hash_algo *compat = repo->compat_hash_algo; + const struct git_hash_algo *compat = r->compat_hash_algo; void *buf; unsigned long len; struct object_info oi = OBJECT_INFO_INIT; @@ -2590,22 +2594,22 @@ int force_object_loose(const struct object_id *oid, time_t mtime) int hdrlen; int ret; - if (has_loose_object(oid)) + if (has_loose_object(r, oid)) return 0; oi.typep = &type; oi.sizep = &len; oi.contentp = &buf; - if (oid_object_info_extended(the_repository, oid, &oi, 0)) + if (oid_object_info_extended(r, oid, &oi, 0)) return error(_("cannot read object for %s"), oid_to_hex(oid)); if (compat) { - if (repo_oid_to_algop(repo, oid, compat, &compat_oid)) + if (repo_oid_to_algop(r, oid, compat, &compat_oid)) return error(_("cannot map object %s to %s"), oid_to_hex(oid), compat->name); } hdrlen = format_object_header(hdr, sizeof(hdr), type, len); ret = write_loose_object(oid, hdr, hdrlen, buf, len, mtime, 0); if (!ret && compat) - ret = repo_add_loose_object_map(the_repository, oid, &compat_oid); + ret = repo_add_loose_object_map(r, oid, &compat_oid); free(buf); return ret; diff --git a/object-store-ll.h b/object-store-ll.h index cd3bd5bd99f78cd01d914ac86fa94f0fb36853a3..1edaf057113dbdbe23f8c4405d40ee7eda3f3404 100644 --- a/object-store-ll.h +++ b/object-store-ll.h @@ -60,33 +60,36 @@ int has_alt_odb(struct repository *r); char *compute_alternate_path(const char *path, struct strbuf *err); struct object_directory *find_odb(struct repository *r, const char *obj_dir); typedef int alt_odb_fn(struct object_directory *, void *); -int foreach_alt_odb(alt_odb_fn, void*); +int foreach_alt_odb(struct repository *r, alt_odb_fn, void*); typedef void alternate_ref_fn(const struct object_id *oid, void *); -void for_each_alternate_ref(alternate_ref_fn, void *); +void for_each_alternate_ref(struct repository *r, alternate_ref_fn, void *); /* * Add the directory to the on-disk alternates file; the new entry will also * take effect in the current process. */ -void add_to_alternates_file(const char *dir); +void add_to_alternates_file(struct repository *r, const char *dir); /* * Add the directory to the in-memory list of alternates (along with any * recursive alternates it points to), but do not modify the on-disk alternates * file. */ -void add_to_alternates_memory(const char *dir); +void add_to_alternates_memory(struct repository *r, const char *dir); /* * Replace the current writable object directory with the specified temporary * object directory; returns the former primary object directory. */ -struct object_directory *set_temporary_primary_odb(const char *dir, int will_destroy); +struct object_directory *set_temporary_primary_odb(struct repository *r, + const char *dir, + int will_destroy); /* * Restore a previous ODB replaced by set_temporary_main_odb. */ -void restore_primary_odb(struct object_directory *restore_odb, const char *old_path); +void restore_primary_odb(struct repository *r, struct object_directory *restore_odb, + const char *old_path); /* * Populate and return the loose object cache array corresponding to the @@ -282,9 +285,9 @@ static inline int write_object_file(const void *buf, unsigned long len, return write_object_file_flags(buf, len, type, oid, NULL, 0); } -int write_object_file_literally(const void *buf, unsigned long len, - const char *type, struct object_id *oid, - unsigned flags); +int write_object_file_literally(struct repository *r, const void *buf, + unsigned long len, const char *type, + struct object_id *oid, unsigned flags); int stream_loose_object(struct input_stream *in_stream, size_t len, struct object_id *oid); @@ -299,7 +302,8 @@ int stream_loose_object(struct input_stream *in_stream, size_t len, int pretend_object_file(void *, unsigned long, enum object_type, struct object_id *oid); -int force_object_loose(const struct object_id *oid, time_t mtime); +int force_object_loose(struct repository *r, const struct object_id *oid, + time_t mtime); struct object_info { /* Request */ @@ -410,9 +414,9 @@ int repo_has_object_file_with_flags(struct repository *r, * with the specified name. This function does not respect replace * references. */ -int has_loose_object_nonlocal(const struct object_id *); +int has_loose_object_nonlocal(struct repository *r, const struct object_id *); -int has_loose_object(const struct object_id *); +int has_loose_object(struct repository *r, const struct object_id *); /** * format_object_header() is a thin wrapper around s xsnprintf() that diff --git a/revision.c b/revision.c index 474fa1e767c8d8f90ce39190ccf8b49cdaa51f54..3f1d920f5567a4c3b95ffa00087e7f1407585f58 100644 --- a/revision.c +++ b/revision.c @@ -1910,7 +1910,7 @@ static void add_alternate_refs_to_pending(struct rev_info *revs, struct add_alternate_refs_data data; data.revs = revs; data.flags = flags; - for_each_alternate_ref(add_one_alternate_ref, &data); + for_each_alternate_ref(the_repository, add_one_alternate_ref, &data); } static int add_parents_only(struct rev_info *revs, const char *arg_, int flags, diff --git a/submodule.c b/submodule.c index b361076c5b97a068863a725ae24fc5bbdc472121..3d7b29ad54f593cba8402d39dae93da0d9765f19 100644 --- a/submodule.c +++ b/submodule.c @@ -189,7 +189,8 @@ int register_all_submodule_odb_as_alternates(void) int ret = added_submodule_odb_paths.nr; for (i = 0; i < added_submodule_odb_paths.nr; i++) - add_to_alternates_memory(added_submodule_odb_paths.items[i].string); + add_to_alternates_memory(the_repository, + added_submodule_odb_paths.items[i].string); if (ret) { string_list_clear(&added_submodule_odb_paths, 0); trace2_data_intmax("submodule", the_repository, diff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c index 1cc05f043ac204fcea0d3304e93e8e2bde5b6b70..20e2ca7eed16268dfbf6476dcdf71d7b80855d69 100644 --- a/t/helper/test-ref-store.c +++ b/t/helper/test-ref-store.c @@ -80,7 +80,7 @@ static const char **get_store(const char **argv, struct ref_store **refs) ret = strbuf_git_path_submodule(&sb, gitdir, "objects/"); if (ret) die("strbuf_git_path_submodule failed: %d", ret); - add_to_alternates_memory(sb.buf); + add_to_alternates_memory(the_repository, sb.buf); strbuf_release(&sb); *refs = repo_get_submodule_ref_store(the_repository, gitdir); diff --git a/tmp-objdir.c b/tmp-objdir.c index 0ea078a5c5f4eb1ff465aa64ae962a0ccd44fb8b..7823cae0f046815cc2212dbedcda8f3029c7fe16 100644 --- a/tmp-objdir.c +++ b/tmp-objdir.c @@ -47,7 +47,7 @@ int tmp_objdir_destroy(struct tmp_objdir *t) the_tmp_objdir = NULL; if (t->prev_odb) - restore_primary_odb(t->prev_odb, t->path.buf); + restore_primary_odb(t->repo, t->prev_odb, t->path.buf); err = remove_dir_recursively(&t->path, 0); @@ -276,7 +276,7 @@ int tmp_objdir_migrate(struct tmp_objdir *t) if (t->prev_odb) { if (t->repo->objects->odb->will_destroy) BUG("migrating an ODB that was marked for destruction"); - restore_primary_odb(t->prev_odb, t->path.buf); + restore_primary_odb(t->repo, t->prev_odb, t->path.buf); t->prev_odb = NULL; } @@ -299,16 +299,17 @@ const char **tmp_objdir_env(const struct tmp_objdir *t) return t->env.v; } -void tmp_objdir_add_as_alternate(const struct tmp_objdir *t) +void tmp_objdir_add_as_alternate(struct repository *r, const struct tmp_objdir *t) { - add_to_alternates_memory(t->path.buf); + add_to_alternates_memory(r, t->path.buf); } void tmp_objdir_replace_primary_odb(struct tmp_objdir *t, int will_destroy) { if (t->prev_odb) BUG("the primary object database is already replaced"); - t->prev_odb = set_temporary_primary_odb(t->path.buf, will_destroy); + t->prev_odb = set_temporary_primary_odb(t->repo, t->path.buf, + will_destroy); t->will_destroy = will_destroy; } @@ -317,13 +318,13 @@ struct tmp_objdir *tmp_objdir_unapply_primary_odb(void) if (!the_tmp_objdir || !the_tmp_objdir->prev_odb) return NULL; - restore_primary_odb(the_tmp_objdir->prev_odb, the_tmp_objdir->path.buf); + restore_primary_odb(the_tmp_objdir->repo, the_tmp_objdir->prev_odb, the_tmp_objdir->path.buf); the_tmp_objdir->prev_odb = NULL; return the_tmp_objdir; } -void tmp_objdir_reapply_primary_odb(struct tmp_objdir *t, const char *old_cwd, - const char *new_cwd) +void tmp_objdir_reapply_primary_odb(struct tmp_objdir *t, + const char *old_cwd, const char *new_cwd) { char *path; diff --git a/tmp-objdir.h b/tmp-objdir.h index fceda14979648f50bb28b6c527889b12d334b098..85688488bbafe5b3b9b996508c112ed88d46a819 100644 --- a/tmp-objdir.h +++ b/tmp-objdir.h @@ -59,7 +59,7 @@ void tmp_objdir_discard_objects(struct tmp_objdir *); * Add the temporary object directory as an alternate object store in the * current process. */ -void tmp_objdir_add_as_alternate(const struct tmp_objdir *); +void tmp_objdir_add_as_alternate(struct repository *r, const struct tmp_objdir *); /* * Replaces the writable object store in the current process with the temporary