Skip to content

Commit ddb28da

Browse files
pks-tgitster
authored andcommitted
object-store: move struct packed_git into "packfile.h"
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d61ff9c commit ddb28da

File tree

3 files changed

+60
-59
lines changed

3 files changed

+60
-59
lines changed

object-store.h

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -92,65 +92,8 @@ struct oidtree *odb_loose_cache(struct object_directory *odb,
9292
/* Empty the loose object cache for the specified object directory. */
9393
void odb_clear_loose_cache(struct object_directory *odb);
9494

95-
struct packed_git {
96-
struct hashmap_entry packmap_ent;
97-
struct packed_git *next;
98-
struct list_head mru;
99-
struct pack_window *windows;
100-
off_t pack_size;
101-
const void *index_data;
102-
size_t index_size;
103-
uint32_t num_objects;
104-
size_t crc_offset;
105-
struct oidset bad_objects;
106-
int index_version;
107-
time_t mtime;
108-
int pack_fd;
109-
int index; /* for builtin/pack-objects.c */
110-
unsigned pack_local:1,
111-
pack_keep:1,
112-
pack_keep_in_core:1,
113-
freshened:1,
114-
do_not_close:1,
115-
pack_promisor:1,
116-
multi_pack_index:1,
117-
is_cruft:1;
118-
unsigned char hash[GIT_MAX_RAWSZ];
119-
struct revindex_entry *revindex;
120-
const uint32_t *revindex_data;
121-
const uint32_t *revindex_map;
122-
size_t revindex_size;
123-
/*
124-
* mtimes_map points at the beginning of the memory mapped region of
125-
* this pack's corresponding .mtimes file, and mtimes_size is the size
126-
* of that .mtimes file
127-
*/
128-
const uint32_t *mtimes_map;
129-
size_t mtimes_size;
130-
131-
/* repo denotes the repository this packfile belongs to */
132-
struct repository *repo;
133-
134-
/* something like ".git/objects/pack/xxxxx.pack" */
135-
char pack_name[FLEX_ARRAY]; /* more */
136-
};
137-
95+
struct packed_git;
13896
struct multi_pack_index;
139-
140-
static inline int pack_map_entry_cmp(const void *cmp_data UNUSED,
141-
const struct hashmap_entry *entry,
142-
const struct hashmap_entry *entry2,
143-
const void *keydata)
144-
{
145-
const char *key = keydata;
146-
const struct packed_git *pg1, *pg2;
147-
148-
pg1 = container_of(entry, const struct packed_git, packmap_ent);
149-
pg2 = container_of(entry2, const struct packed_git, packmap_ent);
150-
151-
return strcmp(pg1->pack_name, key ? key : pg2->pack_name);
152-
}
153-
15497
struct cached_object_entry;
15598

15699
struct raw_object_store {

pack-objects.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "object-store.h"
55
#include "thread-utils.h"
66
#include "pack.h"
7+
#include "packfile.h"
78

89
struct repository;
910

packfile.h

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,70 @@
11
#ifndef PACKFILE_H
22
#define PACKFILE_H
33

4+
#include "list.h"
45
#include "object.h"
56
#include "oidset.h"
67

78
/* in object-store.h */
8-
struct packed_git;
99
struct object_info;
1010

11+
struct packed_git {
12+
struct hashmap_entry packmap_ent;
13+
struct packed_git *next;
14+
struct list_head mru;
15+
struct pack_window *windows;
16+
off_t pack_size;
17+
const void *index_data;
18+
size_t index_size;
19+
uint32_t num_objects;
20+
size_t crc_offset;
21+
struct oidset bad_objects;
22+
int index_version;
23+
time_t mtime;
24+
int pack_fd;
25+
int index; /* for builtin/pack-objects.c */
26+
unsigned pack_local:1,
27+
pack_keep:1,
28+
pack_keep_in_core:1,
29+
freshened:1,
30+
do_not_close:1,
31+
pack_promisor:1,
32+
multi_pack_index:1,
33+
is_cruft:1;
34+
unsigned char hash[GIT_MAX_RAWSZ];
35+
struct revindex_entry *revindex;
36+
const uint32_t *revindex_data;
37+
const uint32_t *revindex_map;
38+
size_t revindex_size;
39+
/*
40+
* mtimes_map points at the beginning of the memory mapped region of
41+
* this pack's corresponding .mtimes file, and mtimes_size is the size
42+
* of that .mtimes file
43+
*/
44+
const uint32_t *mtimes_map;
45+
size_t mtimes_size;
46+
47+
/* repo denotes the repository this packfile belongs to */
48+
struct repository *repo;
49+
50+
/* something like ".git/objects/pack/xxxxx.pack" */
51+
char pack_name[FLEX_ARRAY]; /* more */
52+
};
53+
54+
static inline int pack_map_entry_cmp(const void *cmp_data UNUSED,
55+
const struct hashmap_entry *entry,
56+
const struct hashmap_entry *entry2,
57+
const void *keydata)
58+
{
59+
const char *key = keydata;
60+
const struct packed_git *pg1, *pg2;
61+
62+
pg1 = container_of(entry, const struct packed_git, packmap_ent);
63+
pg2 = container_of(entry2, const struct packed_git, packmap_ent);
64+
65+
return strcmp(pg1->pack_name, key ? key : pg2->pack_name);
66+
}
67+
1168
struct pack_window {
1269
struct pack_window *next;
1370
unsigned char *base;

0 commit comments

Comments
 (0)