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