]> git.ipfire.org Git - thirdparty/git.git/commitdiff
object-store: move `struct packed_git` into "packfile.h"
authorPatrick Steinhardt <ps@pks.im>
Tue, 29 Apr 2025 07:52:15 +0000 (09:52 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 29 Apr 2025 17:08:11 +0000 (10:08 -0700)
The "object-store.h" header contains the definition of `struct
packed_git`. As this structure hosts all kind of information about a
specific packfile it is arguably a bit out of place in a generic place
like "object-store.h".

Move the structure as well as `pack_map_entry_cmp()` into "packfile.h".

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
object-store.h
pack-objects.h
packfile.h

index 46961dc954257b5da5e883329d10b8f59e25e0f2..e04469a85fba4a4216c694cdd58ddea82b9ad074 100644 (file)
@@ -92,65 +92,8 @@ struct oidtree *odb_loose_cache(struct object_directory *odb,
 /* Empty the loose object cache for the specified object directory. */
 void odb_clear_loose_cache(struct object_directory *odb);
 
-struct packed_git {
-       struct hashmap_entry packmap_ent;
-       struct packed_git *next;
-       struct list_head mru;
-       struct pack_window *windows;
-       off_t pack_size;
-       const void *index_data;
-       size_t index_size;
-       uint32_t num_objects;
-       size_t crc_offset;
-       struct oidset bad_objects;
-       int index_version;
-       time_t mtime;
-       int pack_fd;
-       int index;              /* for builtin/pack-objects.c */
-       unsigned pack_local:1,
-                pack_keep:1,
-                pack_keep_in_core:1,
-                freshened:1,
-                do_not_close:1,
-                pack_promisor:1,
-                multi_pack_index:1,
-                is_cruft:1;
-       unsigned char hash[GIT_MAX_RAWSZ];
-       struct revindex_entry *revindex;
-       const uint32_t *revindex_data;
-       const uint32_t *revindex_map;
-       size_t revindex_size;
-       /*
-        * mtimes_map points at the beginning of the memory mapped region of
-        * this pack's corresponding .mtimes file, and mtimes_size is the size
-        * of that .mtimes file
-        */
-       const uint32_t *mtimes_map;
-       size_t mtimes_size;
-
-       /* repo denotes the repository this packfile belongs to */
-       struct repository *repo;
-
-       /* something like ".git/objects/pack/xxxxx.pack" */
-       char pack_name[FLEX_ARRAY]; /* more */
-};
-
+struct packed_git;
 struct multi_pack_index;
-
-static inline int pack_map_entry_cmp(const void *cmp_data UNUSED,
-                                    const struct hashmap_entry *entry,
-                                    const struct hashmap_entry *entry2,
-                                    const void *keydata)
-{
-       const char *key = keydata;
-       const struct packed_git *pg1, *pg2;
-
-       pg1 = container_of(entry, const struct packed_git, packmap_ent);
-       pg2 = container_of(entry2, const struct packed_git, packmap_ent);
-
-       return strcmp(pg1->pack_name, key ? key : pg2->pack_name);
-}
-
 struct cached_object_entry;
 
 struct raw_object_store {
index d1c4ae7f9b61895b981170c7d2e335dc8fb011d1..475a2d67ce30ebf01acd4ebc640f3f2788c6d088 100644 (file)
@@ -4,6 +4,7 @@
 #include "object-store.h"
 #include "thread-utils.h"
 #include "pack.h"
+#include "packfile.h"
 
 struct repository;
 
index 25097213d06d61432a43f141babc87ca85774971..05499382397576af820e4537f6b9b5af894f5942 100644 (file)
@@ -1,13 +1,70 @@
 #ifndef PACKFILE_H
 #define PACKFILE_H
 
+#include "list.h"
 #include "object.h"
 #include "oidset.h"
 
 /* in object-store.h */
-struct packed_git;
 struct object_info;
 
+struct packed_git {
+       struct hashmap_entry packmap_ent;
+       struct packed_git *next;
+       struct list_head mru;
+       struct pack_window *windows;
+       off_t pack_size;
+       const void *index_data;
+       size_t index_size;
+       uint32_t num_objects;
+       size_t crc_offset;
+       struct oidset bad_objects;
+       int index_version;
+       time_t mtime;
+       int pack_fd;
+       int index;              /* for builtin/pack-objects.c */
+       unsigned pack_local:1,
+                pack_keep:1,
+                pack_keep_in_core:1,
+                freshened:1,
+                do_not_close:1,
+                pack_promisor:1,
+                multi_pack_index:1,
+                is_cruft:1;
+       unsigned char hash[GIT_MAX_RAWSZ];
+       struct revindex_entry *revindex;
+       const uint32_t *revindex_data;
+       const uint32_t *revindex_map;
+       size_t revindex_size;
+       /*
+        * mtimes_map points at the beginning of the memory mapped region of
+        * this pack's corresponding .mtimes file, and mtimes_size is the size
+        * of that .mtimes file
+        */
+       const uint32_t *mtimes_map;
+       size_t mtimes_size;
+
+       /* repo denotes the repository this packfile belongs to */
+       struct repository *repo;
+
+       /* something like ".git/objects/pack/xxxxx.pack" */
+       char pack_name[FLEX_ARRAY]; /* more */
+};
+
+static inline int pack_map_entry_cmp(const void *cmp_data UNUSED,
+                                    const struct hashmap_entry *entry,
+                                    const struct hashmap_entry *entry2,
+                                    const void *keydata)
+{
+       const char *key = keydata;
+       const struct packed_git *pg1, *pg2;
+
+       pg1 = container_of(entry, const struct packed_git, packmap_ent);
+       pg2 = container_of(entry2, const struct packed_git, packmap_ent);
+
+       return strcmp(pg1->pack_name, key ? key : pg2->pack_name);
+}
+
 struct pack_window {
        struct pack_window *next;
        unsigned char *base;