]>
Commit | Line | Data |
---|---|---|
90c62155 SB |
1 | #ifndef OBJECT_STORE_H |
2 | #define OBJECT_STORE_H | |
3 | ||
d88f9fdf SB |
4 | #include "oidmap.h" |
5 | ||
031dc927 | 6 | struct alternate_object_database { |
0d4a1321 SB |
7 | struct alternate_object_database *next; |
8 | ||
9 | /* see alt_scratch_buf() */ | |
10 | struct strbuf scratch; | |
11 | size_t base_len; | |
12 | ||
13 | /* | |
14 | * Used to store the results of readdir(3) calls when searching | |
15 | * for unique abbreviated hashes. This cache is never | |
16 | * invalidated, thus it's racy and not necessarily accurate. | |
17 | * That's fine for its purpose; don't use it for tasks requiring | |
18 | * greater accuracy! | |
19 | */ | |
20 | char loose_objects_subdir_seen[256]; | |
21 | struct oid_array loose_objects_cache; | |
22 | ||
77f012e8 SB |
23 | /* |
24 | * Path to the alternative object store. If this is a relative path, | |
25 | * it is relative to the current working directory. | |
26 | */ | |
0d4a1321 | 27 | char path[FLEX_ARRAY]; |
031dc927 | 28 | }; |
13068bf0 | 29 | void prepare_alt_odb(struct repository *r); |
0d4a1321 SB |
30 | char *compute_alternate_path(const char *path, struct strbuf *err); |
31 | typedef int alt_odb_fn(struct alternate_object_database *, void *); | |
32 | int foreach_alt_odb(alt_odb_fn, void*); | |
33 | ||
34 | /* | |
35 | * Allocate a "struct alternate_object_database" but do _not_ actually | |
36 | * add it to the list of alternates. | |
37 | */ | |
38 | struct alternate_object_database *alloc_alt_odb(const char *dir); | |
39 | ||
40 | /* | |
41 | * Add the directory to the on-disk alternates file; the new entry will also | |
42 | * take effect in the current process. | |
43 | */ | |
44 | void add_to_alternates_file(const char *dir); | |
45 | ||
46 | /* | |
47 | * Add the directory to the in-memory list of alternates (along with any | |
48 | * recursive alternates it points to), but do not modify the on-disk alternates | |
49 | * file. | |
50 | */ | |
51 | void add_to_alternates_memory(const char *dir); | |
52 | ||
53 | /* | |
54 | * Returns a scratch strbuf pre-filled with the alternate object directory, | |
55 | * including a trailing slash, which can be used to access paths in the | |
56 | * alternate. Always use this over direct access to alt->scratch, as it | |
57 | * cleans up any previous use of the scratch buffer. | |
58 | */ | |
59 | struct strbuf *alt_scratch_buf(struct alternate_object_database *alt); | |
60 | ||
a80d72db SB |
61 | struct packed_git { |
62 | struct packed_git *next; | |
63 | struct list_head mru; | |
64 | struct pack_window *windows; | |
65 | off_t pack_size; | |
66 | const void *index_data; | |
67 | size_t index_size; | |
68 | uint32_t num_objects; | |
69 | uint32_t num_bad_objects; | |
70 | unsigned char *bad_object_sha1; | |
71 | int index_version; | |
72 | time_t mtime; | |
73 | int pack_fd; | |
43fa44fa | 74 | int index; /* for builtin/pack-objects.c */ |
a80d72db SB |
75 | unsigned pack_local:1, |
76 | pack_keep:1, | |
ed7e5fc3 | 77 | pack_keep_in_core:1, |
a80d72db SB |
78 | freshened:1, |
79 | do_not_close:1, | |
80 | pack_promisor:1; | |
81 | unsigned char sha1[20]; | |
82 | struct revindex_entry *revindex; | |
83 | /* something like ".git/objects/pack/xxxxx.pack" */ | |
84 | char pack_name[FLEX_ARRAY]; /* more */ | |
85 | }; | |
86 | ||
90c62155 SB |
87 | struct raw_object_store { |
88 | /* | |
89 | * Path to the repository's object store. | |
90 | * Cannot be NULL after initialization. | |
91 | */ | |
92 | char *objectdir; | |
93 | ||
94 | /* Path to extra alternate object database if not NULL */ | |
95 | char *alternate_db; | |
031dc927 SB |
96 | |
97 | struct alternate_object_database *alt_odb_list; | |
98 | struct alternate_object_database **alt_odb_tail; | |
a80d72db | 99 | |
d88f9fdf SB |
100 | /* |
101 | * Objects that should be substituted by other objects | |
102 | * (see git-replace(1)). | |
103 | */ | |
c1274495 | 104 | struct oidmap *replace_map; |
d88f9fdf | 105 | |
a80d72db SB |
106 | /* |
107 | * private data | |
108 | * | |
109 | * should only be accessed directly by packfile.c | |
110 | */ | |
111 | ||
112 | struct packed_git *packed_git; | |
113 | /* A most-recently-used ordered version of the packed_git list. */ | |
114 | struct list_head packed_git_mru; | |
5508f693 | 115 | |
9a00580d SB |
116 | /* |
117 | * A fast, rough count of the number of objects in the repository. | |
118 | * These two fields are not meant for direct access. Use | |
119 | * approximate_object_count() instead. | |
120 | */ | |
121 | unsigned long approximate_object_count; | |
122 | unsigned approximate_object_count_valid : 1; | |
123 | ||
5508f693 SB |
124 | /* |
125 | * Whether packed_git has already been populated with this repository's | |
126 | * packs. | |
127 | */ | |
128 | unsigned packed_git_initialized : 1; | |
90c62155 SB |
129 | }; |
130 | ||
131 | struct raw_object_store *raw_object_store_new(void); | |
132 | void raw_object_store_clear(struct raw_object_store *o); | |
133 | ||
cf78ae4f SB |
134 | /* |
135 | * Put in `buf` the name of the file in the local object database that | |
136 | * would be used to store a loose object with the specified sha1. | |
137 | */ | |
a68377b5 | 138 | void sha1_file_name(struct repository *r, struct strbuf *buf, const unsigned char *sha1); |
cf78ae4f | 139 | |
bd27f50c | 140 | void *map_sha1_file(struct repository *r, const unsigned char *sha1, unsigned long *size); |
e35454fa | 141 | |
90c62155 | 142 | #endif /* OBJECT_STORE_H */ |