From: Junio C Hamano Date: Tue, 5 Aug 2025 18:53:55 +0000 (-0700) Subject: Merge branch 'ps/object-file-wo-the-repository' X-Git-Tag: v2.51.0-rc1~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4ce0caa7cc27d50ee1bedf1dff03f13be4c54c1f;p=thirdparty%2Fgit.git Merge branch 'ps/object-file-wo-the-repository' Reduce implicit assumption and dependence on the_repository in the object-file subsystem. * ps/object-file-wo-the-repository: object-file: get rid of `the_repository` in index-related functions object-file: get rid of `the_repository` in `force_object_loose()` object-file: get rid of `the_repository` in `read_loose_object()` object-file: get rid of `the_repository` in loose object iterators object-file: remove declaration for `for_each_file_in_obj_subdir()` object-file: inline `for_each_loose_file_in_objdir_buf()` object-file: get rid of `the_repository` when writing objects odb: introduce `odb_write_object()` loose: write loose objects map via their source object-file: get rid of `the_repository` in `finalize_object_file()` object-file: get rid of `the_repository` in `loose_object_info()` object-file: get rid of `the_repository` when freshening objects object-file: inline `check_and_freshen()` functions object-file: get rid of `the_repository` in `has_loose_object()` object-file: stop using `the_hash_algo` object-file: fix -Wsign-compare warnings --- 4ce0caa7cc27d50ee1bedf1dff03f13be4c54c1f diff --cc builtin/pack-objects.c index 1f084a1b8d,7ff79d6b37..53a2256250 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@@ -1706,11 -1700,19 +1706,19 @@@ static int want_object_in_pack_mtime(co uint32_t found_mtime) { int want; + struct odb_source *source; struct list_head *pos; - struct multi_pack_index *m; - if (!exclude && local && has_loose_object_nonlocal(oid)) - return 0; + if (!exclude && local) { + /* + * Note that we start iterating at `sources->next` so that we + * skip the local object source. + */ + struct odb_source *source = the_repository->objects->sources->next; + for (; source; source = source->next) + if (has_loose_object(source, oid)) + return 0; + } /* * If we already know the pack object lives in, start checks from that @@@ -4366,10 -4340,10 +4382,10 @@@ static int add_loose_object(const struc * add_object_entry will weed out duplicates, so we just add every * loose object we find. */ -static void add_unreachable_loose_objects(void) +static void add_unreachable_loose_objects(struct rev_info *revs) { - for_each_loose_file_in_objdir(repo_get_object_directory(the_repository), + for_each_loose_file_in_source(the_repository->objects->sources, - add_loose_object, NULL, NULL, NULL); + add_loose_object, NULL, NULL, revs); } static int has_sha1_pack_kept_or_nonlocal(const struct object_id *oid) diff --cc builtin/prune.c index d1c0ee1419,bf5d3bb152..55635a891f --- a/builtin/prune.c +++ b/builtin/prune.c @@@ -198,7 -200,7 +198,7 @@@ int cmd_prune(int argc revs.exclude_promisor_objects = 1; } - for_each_loose_file_in_objdir(repo_get_object_directory(repo), - for_each_loose_file_in_source(the_repository->objects->sources, ++ for_each_loose_file_in_source(repo->objects->sources, prune_object, prune_cruft, prune_subdir, &revs); prune_packed_objects(show_only ? PRUNE_PACKED_DRY_RUN : 0);