summaryrefslogtreecommitdiff
path: root/object-file.c
diff options
context:
space:
mode:
Diffstat (limited to 'object-file.c')
-rw-r--r--object-file.c80
1 files changed, 40 insertions, 40 deletions
diff --git a/object-file.c b/object-file.c
index 1ac04c2891..6bad1d3dd1 100644
--- a/object-file.c
+++ b/object-file.c
@@ -55,12 +55,12 @@ static void fill_loose_path(struct strbuf *buf, const struct object_id *oid)
}
}
-const char *odb_loose_path(struct object_directory *odb,
+const char *odb_loose_path(struct odb_source *source,
struct strbuf *buf,
const struct object_id *oid)
{
strbuf_reset(buf);
- strbuf_addstr(buf, odb->path);
+ strbuf_addstr(buf, source->path);
strbuf_addch(buf, '/');
fill_loose_path(buf, oid);
return buf->buf;
@@ -88,27 +88,27 @@ int check_and_freshen_file(const char *fn, int freshen)
return 1;
}
-static int check_and_freshen_odb(struct object_directory *odb,
+static int check_and_freshen_odb(struct odb_source *source,
const struct object_id *oid,
int freshen)
{
static struct strbuf path = STRBUF_INIT;
- odb_loose_path(odb, &path, oid);
+ odb_loose_path(source, &path, oid);
return check_and_freshen_file(path.buf, freshen);
}
static int check_and_freshen_local(const struct object_id *oid, int freshen)
{
- return check_and_freshen_odb(the_repository->objects->odb, oid, freshen);
+ return check_and_freshen_odb(the_repository->objects->sources, oid, freshen);
}
static int check_and_freshen_nonlocal(const struct object_id *oid, int freshen)
{
- struct object_directory *odb;
+ struct odb_source *source;
prepare_alt_odb(the_repository);
- for (odb = the_repository->objects->odb->next; odb; odb = odb->next) {
- if (check_and_freshen_odb(odb, oid, freshen))
+ for (source = the_repository->objects->sources->next; source; source = source->next) {
+ if (check_and_freshen_odb(source, oid, freshen))
return 1;
}
return 0;
@@ -202,12 +202,12 @@ int stream_object_signature(struct repository *r, const struct object_id *oid)
static int stat_loose_object(struct repository *r, const struct object_id *oid,
struct stat *st, const char **path)
{
- struct object_directory *odb;
+ struct odb_source *source;
static struct strbuf buf = STRBUF_INIT;
prepare_alt_odb(r);
- for (odb = r->objects->odb; odb; odb = odb->next) {
- *path = odb_loose_path(odb, &buf, oid);
+ for (source = r->objects->sources; source; source = source->next) {
+ *path = odb_loose_path(source, &buf, oid);
if (!lstat(*path, st))
return 0;
}
@@ -223,13 +223,13 @@ static int open_loose_object(struct repository *r,
const struct object_id *oid, const char **path)
{
int fd;
- struct object_directory *odb;
+ struct odb_source *source;
int most_interesting_errno = ENOENT;
static struct strbuf buf = STRBUF_INIT;
prepare_alt_odb(r);
- for (odb = r->objects->odb; odb; odb = odb->next) {
- *path = odb_loose_path(odb, &buf, oid);
+ for (source = r->objects->sources; source; source = source->next) {
+ *path = odb_loose_path(source, &buf, oid);
fd = git_open(*path);
if (fd >= 0)
return fd;
@@ -244,11 +244,11 @@ static int open_loose_object(struct repository *r,
static int quick_has_loose(struct repository *r,
const struct object_id *oid)
{
- struct object_directory *odb;
+ struct odb_source *source;
prepare_alt_odb(r);
- for (odb = r->objects->odb; odb; odb = odb->next) {
- if (oidtree_contains(odb_loose_cache(odb, oid), oid))
+ for (source = r->objects->sources; source; source = source->next) {
+ if (oidtree_contains(odb_loose_cache(source, oid), oid))
return 1;
}
return 0;
@@ -694,7 +694,7 @@ void hash_object_file(const struct git_hash_algo *algo, const void *buf,
/* Finalize a file on disk, and close it. */
static void close_loose_object(int fd, const char *filename)
{
- if (the_repository->objects->odb->will_destroy)
+ if (the_repository->objects->sources->will_destroy)
goto out;
if (batch_fsync_enabled(FSYNC_COMPONENT_LOOSE_OBJECT))
@@ -876,7 +876,7 @@ static int write_loose_object(const struct object_id *oid, char *hdr,
if (batch_fsync_enabled(FSYNC_COMPONENT_LOOSE_OBJECT))
prepare_loose_object_bulk_checkin();
- odb_loose_path(the_repository->objects->odb, &filename, oid);
+ odb_loose_path(the_repository->objects->sources, &filename, oid);
fd = start_loose_object_common(&tmp_file, filename.buf, flags,
&stream, compressed, sizeof(compressed),
@@ -1023,7 +1023,7 @@ int stream_loose_object(struct input_stream *in_stream, size_t len,
goto cleanup;
}
- odb_loose_path(the_repository->objects->odb, &filename, oid);
+ odb_loose_path(the_repository->objects->sources, &filename, oid);
/* We finally know the object path, and create the missing dir. */
dirlen = directory_size(filename.buf);
@@ -1437,11 +1437,11 @@ int for_each_loose_file_in_objdir(const char *path,
int for_each_loose_object(each_loose_object_fn cb, void *data,
enum for_each_object_flags flags)
{
- struct object_directory *odb;
+ struct odb_source *source;
prepare_alt_odb(the_repository);
- for (odb = the_repository->objects->odb; odb; odb = odb->next) {
- int r = for_each_loose_file_in_objdir(odb->path, cb, NULL,
+ for (source = the_repository->objects->sources; source; source = source->next) {
+ int r = for_each_loose_file_in_objdir(source->path, cb, NULL,
NULL, data);
if (r)
return r;
@@ -1461,43 +1461,43 @@ static int append_loose_object(const struct object_id *oid,
return 0;
}
-struct oidtree *odb_loose_cache(struct object_directory *odb,
- const struct object_id *oid)
+struct oidtree *odb_loose_cache(struct odb_source *source,
+ const struct object_id *oid)
{
int subdir_nr = oid->hash[0];
struct strbuf buf = STRBUF_INIT;
- size_t word_bits = bitsizeof(odb->loose_objects_subdir_seen[0]);
+ size_t word_bits = bitsizeof(source->loose_objects_subdir_seen[0]);
size_t word_index = subdir_nr / word_bits;
size_t mask = (size_t)1u << (subdir_nr % word_bits);
uint32_t *bitmap;
if (subdir_nr < 0 ||
- subdir_nr >= bitsizeof(odb->loose_objects_subdir_seen))
+ subdir_nr >= bitsizeof(source->loose_objects_subdir_seen))
BUG("subdir_nr out of range");
- bitmap = &odb->loose_objects_subdir_seen[word_index];
+ bitmap = &source->loose_objects_subdir_seen[word_index];
if (*bitmap & mask)
- return odb->loose_objects_cache;
- if (!odb->loose_objects_cache) {
- ALLOC_ARRAY(odb->loose_objects_cache, 1);
- oidtree_init(odb->loose_objects_cache);
+ return source->loose_objects_cache;
+ if (!source->loose_objects_cache) {
+ ALLOC_ARRAY(source->loose_objects_cache, 1);
+ oidtree_init(source->loose_objects_cache);
}
- strbuf_addstr(&buf, odb->path);
+ strbuf_addstr(&buf, source->path);
for_each_file_in_obj_subdir(subdir_nr, &buf,
append_loose_object,
NULL, NULL,
- odb->loose_objects_cache);
+ source->loose_objects_cache);
*bitmap |= mask;
strbuf_release(&buf);
- return odb->loose_objects_cache;
+ return source->loose_objects_cache;
}
-void odb_clear_loose_cache(struct object_directory *odb)
+void odb_clear_loose_cache(struct odb_source *source)
{
- oidtree_clear(odb->loose_objects_cache);
- FREE_AND_NULL(odb->loose_objects_cache);
- memset(&odb->loose_objects_subdir_seen, 0,
- sizeof(odb->loose_objects_subdir_seen));
+ oidtree_clear(source->loose_objects_cache);
+ FREE_AND_NULL(source->loose_objects_cache);
+ memset(&source->loose_objects_subdir_seen, 0,
+ sizeof(source->loose_objects_subdir_seen));
}
static int check_stream_oid(git_zstream *stream,