6 struct alternate_object_database
{
7 struct alternate_object_database
*next
;
9 /* see alt_scratch_buf() */
10 struct strbuf scratch
;
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
20 char loose_objects_subdir_seen
[256];
21 struct oid_array loose_objects_cache
;
24 * Path to the alternative object store. If this is a relative path,
25 * it is relative to the current working directory.
27 char path
[FLEX_ARRAY
];
29 void prepare_alt_odb(struct repository
*r
);
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*);
35 * Allocate a "struct alternate_object_database" but do _not_ actually
36 * add it to the list of alternates.
38 struct alternate_object_database
*alloc_alt_odb(const char *dir
);
41 * Add the directory to the on-disk alternates file; the new entry will also
42 * take effect in the current process.
44 void add_to_alternates_file(const char *dir
);
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
51 void add_to_alternates_memory(const char *dir
);
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.
59 struct strbuf
*alt_scratch_buf(struct alternate_object_database
*alt
);
62 struct packed_git
*next
;
64 struct pack_window
*windows
;
66 const void *index_data
;
69 uint32_t num_bad_objects
;
70 unsigned char *bad_object_sha1
;
74 int index
; /* for builtin/pack-objects.c */
75 unsigned pack_local
: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 */
87 struct multi_pack_index
;
89 struct raw_object_store
{
91 * Path to the repository's object store.
92 * Cannot be NULL after initialization.
96 /* Path to extra alternate object database if not NULL */
99 struct alternate_object_database
*alt_odb_list
;
100 struct alternate_object_database
**alt_odb_tail
;
103 * Objects that should be substituted by other objects
104 * (see git-replace(1)).
106 struct oidmap
*replace_map
;
111 * should only be accessed directly by packfile.c and midx.c
113 struct multi_pack_index
*multi_pack_index
;
118 * should only be accessed directly by packfile.c
121 struct packed_git
*packed_git
;
122 /* A most-recently-used ordered version of the packed_git list. */
123 struct list_head packed_git_mru
;
126 * A fast, rough count of the number of objects in the repository.
127 * These two fields are not meant for direct access. Use
128 * approximate_object_count() instead.
130 unsigned long approximate_object_count
;
131 unsigned approximate_object_count_valid
: 1;
134 * Whether packed_git has already been populated with this repository's
137 unsigned packed_git_initialized
: 1;
140 struct raw_object_store
*raw_object_store_new(void);
141 void raw_object_store_clear(struct raw_object_store
*o
);
144 * Put in `buf` the name of the file in the local object database that
145 * would be used to store a loose object with the specified sha1.
147 void sha1_file_name(struct repository
*r
, struct strbuf
*buf
, const unsigned char *sha1
);
149 void *map_sha1_file(struct repository
*r
, const unsigned char *sha1
, unsigned long *size
);
151 #endif /* OBJECT_STORE_H */