]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'ps/object-file-wo-the-repository'
authorJunio C Hamano <gitster@pobox.com>
Tue, 5 Aug 2025 18:53:55 +0000 (11:53 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 5 Aug 2025 18:53:55 +0000 (11:53 -0700)
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

25 files changed:
1  2 
apply.c
builtin/cat-file.c
builtin/checkout.c
builtin/count-objects.c
builtin/fast-import.c
builtin/fsck.c
builtin/gc.c
builtin/index-pack.c
builtin/merge-file.c
builtin/mktag.c
builtin/notes.c
builtin/pack-objects.c
builtin/prune.c
builtin/receive-pack.c
builtin/replace.c
builtin/tag.c
builtin/unpack-objects.c
commit.c
http.c
merge-ort.c
midx-write.c
notes.c
odb.h
reachable.c
read-cache.c

diff --cc apply.c
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
diff --cc builtin/fsck.c
Simple merge
diff --cc builtin/gc.c
Simple merge
Simple merge
Simple merge
diff --cc builtin/mktag.c
Simple merge
diff --cc builtin/notes.c
Simple merge
index 1f084a1b8dfa0ce018faf1859856ef55c5230289,7ff79d6b376852ef4cfb7c8dfcea4b83f02e1aee..53a225625039eae43a0d5aef6538f13b2a40d6de
@@@ -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 d1c0ee1419931c8bff4f8cf4745a0870c882594b,bf5d3bb152cf0ef9cf12a30649a6c40c00b99311..55635a891f37d697f30d28a0074c33f8469ae870
@@@ -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);
Simple merge
Simple merge
diff --cc builtin/tag.c
Simple merge
Simple merge
diff --cc commit.c
Simple merge
diff --cc http.c
Simple merge
diff --cc merge-ort.c
Simple merge
diff --cc midx-write.c
Simple merge
diff --cc notes.c
Simple merge
diff --cc odb.h
Simple merge
diff --cc reachable.c
Simple merge
diff --cc read-cache.c
Simple merge