1#ifndef OBJECT_STORE_H
2#define OBJECT_STORE_H
34
struct alternate_object_database {
5struct alternate_object_database *next;
67
/* see alt_scratch_buf() */
8struct strbuf scratch;
9size_t base_len;
1011
/*
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*/
18char loose_objects_subdir_seen[256];
19struct oid_array loose_objects_cache;
2021
char path[FLEX_ARRAY];
22};
23void prepare_alt_odb(void);
24char *compute_alternate_path(const char *path, struct strbuf *err);
25typedef int alt_odb_fn(struct alternate_object_database *, void *);
26int foreach_alt_odb(alt_odb_fn, void*);
2728
/*
29* Allocate a "struct alternate_object_database" but do _not_ actually
30* add it to the list of alternates.
31*/
32struct alternate_object_database *alloc_alt_odb(const char *dir);
3334
/*
35* Add the directory to the on-disk alternates file; the new entry will also
36* take effect in the current process.
37*/
38void add_to_alternates_file(const char *dir);
3940
/*
41* Add the directory to the in-memory list of alternates (along with any
42* recursive alternates it points to), but do not modify the on-disk alternates
43* file.
44*/
45void add_to_alternates_memory(const char *dir);
4647
/*
48* Returns a scratch strbuf pre-filled with the alternate object directory,
49* including a trailing slash, which can be used to access paths in the
50* alternate. Always use this over direct access to alt->scratch, as it
51* cleans up any previous use of the scratch buffer.
52*/
53struct strbuf *alt_scratch_buf(struct alternate_object_database *alt);
5455
struct raw_object_store {
56/*
57* Path to the repository's object store.
58* Cannot be NULL after initialization.
59*/
60char *objectdir;
6162
/* Path to extra alternate object database if not NULL */
63char *alternate_db;
6465
struct alternate_object_database *alt_odb_list;
66struct alternate_object_database **alt_odb_tail;
67};
6869
struct raw_object_store *raw_object_store_new(void);
70void raw_object_store_clear(struct raw_object_store *o);
7172
#endif /* OBJECT_STORE_H */