]> git.ipfire.org Git - thirdparty/git.git/blame - object-store.h
t7700: have closing quote of a test at the beginning of line
[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
77f012e8
SB
21 /*
22 * Path to the alternative object store. If this is a relative path,
23 * it is relative to the current working directory.
24 */
0d4a1321 25 char path[FLEX_ARRAY];
031dc927 26};
13068bf0 27void prepare_alt_odb(struct repository *r);
0d4a1321
SB
28char *compute_alternate_path(const char *path, struct strbuf *err);
29typedef int alt_odb_fn(struct alternate_object_database *, void *);
30int foreach_alt_odb(alt_odb_fn, void*);
31
32/*
33 * Allocate a "struct alternate_object_database" but do _not_ actually
34 * add it to the list of alternates.
35 */
36struct alternate_object_database *alloc_alt_odb(const char *dir);
37
38/*
39 * Add the directory to the on-disk alternates file; the new entry will also
40 * take effect in the current process.
41 */
42void add_to_alternates_file(const char *dir);
43
44/*
45 * Add the directory to the in-memory list of alternates (along with any
46 * recursive alternates it points to), but do not modify the on-disk alternates
47 * file.
48 */
49void add_to_alternates_memory(const char *dir);
50
51/*
52 * Returns a scratch strbuf pre-filled with the alternate object directory,
53 * including a trailing slash, which can be used to access paths in the
54 * alternate. Always use this over direct access to alt->scratch, as it
55 * cleans up any previous use of the scratch buffer.
56 */
57struct strbuf *alt_scratch_buf(struct alternate_object_database *alt);
58
a80d72db
SB
59struct packed_git {
60 struct packed_git *next;
61 struct list_head mru;
62 struct pack_window *windows;
63 off_t pack_size;
64 const void *index_data;
65 size_t index_size;
66 uint32_t num_objects;
67 uint32_t num_bad_objects;
68 unsigned char *bad_object_sha1;
69 int index_version;
70 time_t mtime;
71 int pack_fd;
72 unsigned pack_local:1,
73 pack_keep:1,
74 freshened:1,
75 do_not_close:1,
76 pack_promisor:1;
77 unsigned char sha1[20];
78 struct revindex_entry *revindex;
79 /* something like ".git/objects/pack/xxxxx.pack" */
80 char pack_name[FLEX_ARRAY]; /* more */
81};
82
90c62155
SB
83struct raw_object_store {
84 /*
85 * Path to the repository's object store.
86 * Cannot be NULL after initialization.
87 */
88 char *objectdir;
89
90 /* Path to extra alternate object database if not NULL */
91 char *alternate_db;
031dc927
SB
92
93 struct alternate_object_database *alt_odb_list;
94 struct alternate_object_database **alt_odb_tail;
a80d72db
SB
95
96 /*
97 * private data
98 *
99 * should only be accessed directly by packfile.c
100 */
101
102 struct packed_git *packed_git;
103 /* A most-recently-used ordered version of the packed_git list. */
104 struct list_head packed_git_mru;
5508f693 105
9a00580d
SB
106 /*
107 * A fast, rough count of the number of objects in the repository.
108 * These two fields are not meant for direct access. Use
109 * approximate_object_count() instead.
110 */
111 unsigned long approximate_object_count;
112 unsigned approximate_object_count_valid : 1;
113
5508f693
SB
114 /*
115 * Whether packed_git has already been populated with this repository's
116 * packs.
117 */
118 unsigned packed_git_initialized : 1;
90c62155
SB
119};
120
121struct raw_object_store *raw_object_store_new(void);
122void raw_object_store_clear(struct raw_object_store *o);
123
cf78ae4f
SB
124/*
125 * Put in `buf` the name of the file in the local object database that
126 * would be used to store a loose object with the specified sha1.
127 */
a68377b5 128void sha1_file_name(struct repository *r, struct strbuf *buf, const unsigned char *sha1);
cf78ae4f 129
bd27f50c 130void *map_sha1_file(struct repository *r, const unsigned char *sha1, unsigned long *size);
e35454fa 131
90c62155 132#endif /* OBJECT_STORE_H */