Merge branch 'ps/object-store'

Code clean-up around object access API.

* ps/object-store:
  odb: rename `read_object_with_reference()`
  odb: rename `pretend_object_file()`
  odb: rename `has_object()`
  odb: rename `repo_read_object_file()`
  odb: rename `oid_object_info()`
  odb: trivial refactorings to get rid of `the_repository`
  odb: get rid of `the_repository` when handling submodule sources
  odb: get rid of `the_repository` when handling the primary source
  odb: get rid of `the_repository` in `for_each()` functions
  odb: get rid of `the_repository` when handling alternates
  odb: get rid of `the_repository` in `odb_mkstemp()`
  odb: get rid of `the_repository` in `assert_oid_type()`
  odb: get rid of `the_repository` in `find_odb()`
  odb: introduce parent pointers
  object-store: rename files to "odb.{c,h}"
  object-store: rename `object_directory` to `odb_source`
  object-store: rename `raw_object_store` to `object_database`
maint
Junio C Hamano 2025-07-15 15:18:17 -07:00
commit 51b50c55a9
140 changed files with 1453 additions and 1297 deletions

View File

@ -4301,11 +4301,11 @@ Now, for the meat:

-----------------------------------------------------------------------------
case 0:
buf = read_object_with_reference(sha1, argv[1], &size, NULL);
buf = odb_read_object_peeled(r->objects, sha1, argv[1], &size, NULL);
-----------------------------------------------------------------------------

This is how you read a blob (actually, not only a blob, but any type of
object). To know how the function `read_object_with_reference()` actually
object). To know how the function `odb_read_object_peeled()` actually
works, find the source code for it (something like `git grep
read_object_with | grep ":[a-z]"` in the Git repository), and read
the source.

View File

@ -1083,8 +1083,8 @@ LIB_OBJS += notes.o
LIB_OBJS += object-file-convert.o
LIB_OBJS += object-file.o
LIB_OBJS += object-name.o
LIB_OBJS += object-store.o
LIB_OBJS += object.o
LIB_OBJS += odb.o
LIB_OBJS += oid-array.o
LIB_OBJS += oidmap.o
LIB_OBJS += oidset.o

14
apply.c
View File

@ -14,7 +14,7 @@
#include "abspath.h"
#include "base85.h"
#include "config.h"
#include "object-store.h"
#include "odb.h"
#include "delta.h"
#include "diff.h"
#include "dir.h"
@ -3204,14 +3204,14 @@ static int apply_binary(struct apply_state *state,
return 0; /* deletion patch */
}

if (has_object(the_repository, &oid, 0)) {
if (odb_has_object(the_repository->objects, &oid, 0)) {
/* We already have the postimage */
enum object_type type;
unsigned long size;
char *result;

result = repo_read_object_file(the_repository, &oid, &type,
&size);
result = odb_read_object(the_repository->objects, &oid,
&type, &size);
if (!result)
return error(_("the necessary postimage %s for "
"'%s' cannot be read"),
@ -3273,8 +3273,8 @@ static int read_blob_object(struct strbuf *buf, const struct object_id *oid, uns
unsigned long sz;
char *result;

result = repo_read_object_file(the_repository, oid, &type,
&sz);
result = odb_read_object(the_repository->objects, oid,
&type, &sz);
if (!result)
return -1;
/* XXX read_sha1_file NUL-terminates */
@ -3503,7 +3503,7 @@ static int resolve_to(struct image *image, const struct object_id *result_id)

image_clear(image);

data = repo_read_object_file(the_repository, result_id, &type, &size);
data = odb_read_object(the_repository->objects, result_id, &type, &size);
if (!data || type != OBJ_BLOB)
die("unable to read blob object %s", oid_to_hex(result_id));
strbuf_attach(&image->buf, data, size, size + 1);

View File

@ -11,7 +11,7 @@
#include "hex.h"
#include "tar.h"
#include "archive.h"
#include "object-store.h"
#include "odb.h"
#include "strbuf.h"
#include "streaming.h"
#include "run-command.h"

View File

@ -12,7 +12,7 @@
#include "hex.h"
#include "streaming.h"
#include "utf8.h"
#include "object-store.h"
#include "odb.h"
#include "strbuf.h"
#include "userdiff.h"
#include "write-or-die.h"

View File

@ -14,7 +14,7 @@
#include "pretty.h"
#include "setup.h"
#include "refs.h"
#include "object-store.h"
#include "odb.h"
#include "commit.h"
#include "tree.h"
#include "tree-walk.h"
@ -98,7 +98,7 @@ static void *object_file_to_archive(const struct archiver_args *args,
(args->tree ? &args->tree->object.oid : NULL), oid);

path += args->baselen;
buffer = repo_read_object_file(the_repository, oid, type, sizep);
buffer = odb_read_object(the_repository->objects, oid, type, sizep);
if (buffer && S_ISREG(mode)) {
struct strbuf buf = STRBUF_INIT;
size_t size = 0;
@ -215,7 +215,7 @@ static int write_archive_entry(const struct object_id *oid, const char *base,

/* Stream it? */
if (S_ISREG(mode) && !args->convert &&
oid_object_info(args->repo, oid, &size) == OBJ_BLOB &&
odb_read_object_info(args->repo->objects, oid, &size) == OBJ_BLOB &&
size > repo_settings_get_big_file_threshold(the_repository))
return write_entry(args, oid, path.buf, path.len, mode, NULL, size);


4
attr.c
View File

@ -22,7 +22,7 @@
#include "read-cache-ll.h"
#include "refs.h"
#include "revision.h"
#include "object-store.h"
#include "odb.h"
#include "setup.h"
#include "thread-utils.h"
#include "tree-walk.h"
@ -779,7 +779,7 @@ static struct attr_stack *read_attr_from_blob(struct index_state *istate,
if (get_tree_entry(istate->repo, tree_oid, path, &oid, &mode))
return NULL;

buf = repo_read_object_file(istate->repo, &oid, &type, &sz);
buf = odb_read_object(istate->repo->objects, &oid, &type, &sz);
if (!buf || type != OBJ_BLOB) {
free(buf);
return NULL;

View File

@ -20,7 +20,7 @@
#include "commit-slab.h"
#include "commit-reach.h"
#include "object-name.h"
#include "object-store.h"
#include "odb.h"
#include "path.h"
#include "dir.h"

@ -155,7 +155,7 @@ static void show_list(const char *debug, int counted, int nr,
unsigned commit_flags = commit->object.flags;
enum object_type type;
unsigned long size;
char *buf = repo_read_object_file(the_repository,
char *buf = odb_read_object(the_repository->objects,
&commit->object.oid, &type,
&size);
const char *subject_start;

16
blame.c
View File

@ -3,7 +3,7 @@

#include "git-compat-util.h"
#include "refs.h"
#include "object-store.h"
#include "odb.h"
#include "cache-tree.h"
#include "mergesort.h"
#include "commit.h"
@ -116,7 +116,7 @@ static void verify_working_tree_path(struct repository *r,
unsigned short mode;

if (!get_tree_entry(r, commit_oid, path, &blob_oid, &mode) &&
oid_object_info(r, &blob_oid, NULL) == OBJ_BLOB)
odb_read_object_info(r->objects, &blob_oid, NULL) == OBJ_BLOB)
return;
}

@ -277,7 +277,8 @@ static struct commit *fake_working_tree_commit(struct repository *r,
convert_to_git(r->index, path, buf.buf, buf.len, &buf, 0);
origin->file.ptr = buf.buf;
origin->file.size = buf.len;
pretend_object_file(the_repository, buf.buf, buf.len, OBJ_BLOB, &origin->blob_oid);
odb_pretend_object(the_repository->objects, buf.buf, buf.len,
OBJ_BLOB, &origin->blob_oid);

/*
* Read the current index, replace the path entry with
@ -1041,7 +1042,7 @@ static void fill_origin_blob(struct diff_options *opt,
&o->blob_oid, 1, &file->ptr, &file_size))
;
else
file->ptr = repo_read_object_file(the_repository,
file->ptr = odb_read_object(the_repository->objects,
&o->blob_oid, &type,
&file_size);
file->size = file_size;
@ -1245,7 +1246,7 @@ static int fill_blob_sha1_and_mode(struct repository *r,
return 0;
if (get_tree_entry(r, &origin->commit->object.oid, origin->path, &origin->blob_oid, &origin->mode))
goto error_out;
if (oid_object_info(r, &origin->blob_oid, NULL) != OBJ_BLOB)
if (odb_read_object_info(r->objects, &origin->blob_oid, NULL) != OBJ_BLOB)
goto error_out;
return 0;
error_out:
@ -2869,9 +2870,8 @@ void setup_scoreboard(struct blame_scoreboard *sb,
&sb->final_buf_size))
;
else
sb->final_buf = repo_read_object_file(the_repository,
&o->blob_oid,
&type,
sb->final_buf = odb_read_object(the_repository->objects,
&o->blob_oid, &type,
&sb->final_buf_size);

if (!sb->final_buf)

View File

@ -13,7 +13,7 @@
#include "tree.h"
#include "tree-walk.h"
#include "object.h"
#include "object-store.h"
#include "odb.h"
#include "oid-array.h"
#include "oidset.h"
#include "promisor-remote.h"
@ -67,7 +67,7 @@ static int fill_missing_blobs(const char *path UNUSED,
return 0;

for (size_t i = 0; i < list->nr; i++) {
if (!has_object(ctx->repo, &list->oid[i],
if (!odb_has_object(ctx->repo->objects, &list->oid[i],
OBJECT_INFO_FOR_PREFETCH))
oid_array_append(&ctx->current_batch, &list->oid[i]);
}

View File

@ -28,7 +28,7 @@
#include "line-log.h"
#include "progress.h"
#include "object-name.h"
#include "object-store.h"
#include "odb.h"
#include "pager.h"
#include "blame.h"
#include "refs.h"
@ -837,7 +837,7 @@ static int is_a_rev(const char *name)

if (repo_get_oid(the_repository, name, &oid))
return 0;
return OBJ_NONE < oid_object_info(the_repository, &oid, NULL);
return OBJ_NONE < odb_read_object_info(the_repository->objects, &oid, NULL);
}

static int peel_to_commit_oid(struct object_id *oid_ret, void *cbdata)
@ -848,7 +848,7 @@ static int peel_to_commit_oid(struct object_id *oid_ret, void *cbdata)
oidcpy(&oid, oid_ret);
while (1) {
struct object *obj;
int kind = oid_object_info(r, &oid, NULL);
int kind = odb_read_object_info(r->objects, &oid, NULL);
if (kind == OBJ_COMMIT) {
oidcpy(oid_ret, &oid);
return 0;

View File

@ -24,7 +24,7 @@
#include "pack-bitmap.h"
#include "object-file.h"
#include "object-name.h"
#include "object-store.h"
#include "odb.h"
#include "replace-object.h"
#include "promisor-remote.h"
#include "mailmap.h"
@ -74,7 +74,7 @@ static int filter_object(const char *path, unsigned mode,
{
enum object_type type;

*buf = repo_read_object_file(the_repository, oid, &type, size);
*buf = odb_read_object(the_repository->objects, oid, &type, size);
if (!*buf)
return error(_("cannot read object %s '%s'"),
oid_to_hex(oid), path);
@ -132,7 +132,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
switch (opt) {
case 't':
oi.typep = &type;
if (oid_object_info_extended(the_repository, &oid, &oi, flags) < 0)
if (odb_read_object_info_extended(the_repository->objects, &oid, &oi, flags) < 0)
die("git cat-file: could not get object info");
printf("%s\n", type_name(type));
ret = 0;
@ -146,7 +146,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
oi.contentp = (void**)&buf;
}

if (oid_object_info_extended(the_repository, &oid, &oi, flags) < 0)
if (odb_read_object_info_extended(the_repository->objects, &oid, &oi, flags) < 0)
die("git cat-file: could not get object info");

if (use_mailmap && (type == OBJ_COMMIT || type == OBJ_TAG)) {
@ -160,7 +160,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
goto cleanup;

case 'e':
ret = !has_object(the_repository, &oid,
ret = !odb_has_object(the_repository->objects, &oid,
HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR);
goto cleanup;

@ -180,7 +180,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
/* else fallthrough */

case 'p':
type = oid_object_info(the_repository, &oid, NULL);
type = odb_read_object_info(the_repository->objects, &oid, NULL);
if (type < 0)
die("Not a valid object name %s", obj_name);

@ -197,8 +197,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
ret = stream_blob(&oid);
goto cleanup;
}
buf = repo_read_object_file(the_repository, &oid, &type,
&size);
buf = odb_read_object(the_repository->objects, &oid,
&type, &size);
if (!buf)
die("Cannot read object %s", obj_name);

@ -217,11 +217,10 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)

if (exp_type_id == OBJ_BLOB) {
struct object_id blob_oid;
if (oid_object_info(the_repository, &oid, NULL) == OBJ_TAG) {
char *buffer = repo_read_object_file(the_repository,
&oid,
&type,
&size);
if (odb_read_object_info(the_repository->objects,
&oid, NULL) == OBJ_TAG) {
char *buffer = odb_read_object(the_repository->objects,
&oid, &type, &size);
const char *target;

if (!buffer)
@ -235,7 +234,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
} else
oidcpy(&blob_oid, &oid);

if (oid_object_info(the_repository, &blob_oid, NULL) == OBJ_BLOB) {
if (odb_read_object_info(the_repository->objects,
&blob_oid, NULL) == OBJ_BLOB) {
ret = stream_blob(&blob_oid);
goto cleanup;
}
@ -246,7 +246,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
* fall-back to the usual case.
*/
}
buf = read_object_with_reference(the_repository, &oid,
buf = odb_read_object_peeled(the_repository->objects, &oid,
exp_type_id, &size, NULL);

if (use_mailmap) {
@ -295,7 +295,7 @@ struct expand_data {

/*
* After a mark_query run, this object_info is set up to be
* passed to oid_object_info_extended. It will point to the data
* passed to odb_read_object_info_extended. It will point to the data
* elements above, so you can retrieve the response from there.
*/
struct object_info info;
@ -406,10 +406,8 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
if (!textconv_object(the_repository,
data->rest, 0100644, oid,
1, &contents, &size))
contents = repo_read_object_file(the_repository,
oid,
&type,
&size);
contents = odb_read_object(the_repository->objects,
oid, &type, &size);
if (!contents)
die("could not convert '%s' %s",
oid_to_hex(oid), data->rest);
@ -426,8 +424,8 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
unsigned long size;
void *contents;

contents = repo_read_object_file(the_repository, oid, &type,
&size);
contents = odb_read_object(the_repository->objects, oid,
&type, &size);
if (!contents)
die("object %s disappeared", oid_to_hex(oid));

@ -489,10 +487,10 @@ static void batch_object_write(const char *obj_name,
data->info.sizep = &data->size;

if (pack)
ret = packed_object_info(the_repository, pack, offset,
&data->info);
ret = packed_object_info(the_repository, pack,
offset, &data->info);
else
ret = oid_object_info_extended(the_repository,
ret = odb_read_object_info_extended(the_repository->objects,
&data->oid, &data->info,
OBJECT_INFO_LOOKUP_REPLACE);
if (ret < 0) {
@ -539,8 +537,8 @@ static void batch_object_write(const char *obj_name,
size_t s = data->size;
char *buf = NULL;

buf = repo_read_object_file(the_repository, &data->oid, &data->type,
&data->size);
buf = odb_read_object(the_repository->objects, &data->oid,
&data->type, &data->size);
if (!buf)
die(_("unable to read %s"), oid_to_hex(&data->oid));
buf = replace_idents_using_mailmap(buf, &s);
@ -881,7 +879,7 @@ static int batch_objects(struct batch_options *opt)

/*
* Expand once with our special mark_query flag, which will prime the
* object_info to be handed to oid_object_info_extended for each
* object_info to be handed to odb_read_object_info_extended for each
* object.
*/
data.mark_query = 1;

View File

@ -20,7 +20,7 @@
#include "merge-ort-wrappers.h"
#include "object-file.h"
#include "object-name.h"
#include "object-store.h"
#include "odb.h"
#include "parse-options.h"
#include "path.h"
#include "preload-index.h"

View File

@ -25,7 +25,7 @@
#include "refs.h"
#include "refspec.h"
#include "object-file.h"
#include "object-store.h"
#include "odb.h"
#include "tree.h"
#include "tree-walk.h"
#include "unpack-trees.h"
@ -171,7 +171,7 @@ static int add_one_reference(struct string_list_item *item, void *cb_data)
} else {
struct strbuf sb = STRBUF_INIT;
strbuf_addf(&sb, "%s/objects", ref_git);
add_to_alternates_file(sb.buf);
odb_add_to_alternates_file(the_repository->objects, sb.buf);
strbuf_release(&sb);
}

@ -212,12 +212,14 @@ static void copy_alternates(struct strbuf *src, const char *src_repo)
if (!line.len || line.buf[0] == '#')
continue;
if (is_absolute_path(line.buf)) {
add_to_alternates_file(line.buf);
odb_add_to_alternates_file(the_repository->objects,
line.buf);
continue;
}
abs_path = mkpathdup("%s/objects/%s", src_repo, line.buf);
if (!normalize_path_copy(abs_path, abs_path))
add_to_alternates_file(abs_path);
odb_add_to_alternates_file(the_repository->objects,
abs_path);
else
warning("skipping invalid relative alternate: %s/%s",
src_repo, line.buf);
@ -352,7 +354,7 @@ static void clone_local(const char *src_repo, const char *dest_repo)
struct strbuf alt = STRBUF_INIT;
get_common_dir(&alt, src_repo);
strbuf_addstr(&alt, "/objects");
add_to_alternates_file(alt.buf);
odb_add_to_alternates_file(the_repository->objects, alt.buf);
strbuf_release(&alt);
} else {
struct strbuf src = STRBUF_INIT;
@ -504,7 +506,7 @@ static void write_followtags(const struct ref *refs, const char *msg)
continue;
if (ends_with(ref->name, "^{}"))
continue;
if (!has_object(the_repository, &ref->old_oid, 0))
if (!odb_has_object(the_repository->objects, &ref->old_oid, 0))
continue;
refs_update_ref(get_main_ref_store(the_repository), msg,
ref->name, &ref->old_oid, NULL, 0,

View File

@ -6,7 +6,7 @@
#include "hex.h"
#include "parse-options.h"
#include "commit-graph.h"
#include "object-store.h"
#include "odb.h"
#include "progress.h"
#include "replace-object.h"
#include "strbuf.h"
@ -66,7 +66,7 @@ static int graph_verify(int argc, const char **argv, const char *prefix,
struct repository *repo UNUSED)
{
struct commit_graph *graph = NULL;
struct object_directory *odb = NULL;
struct odb_source *source = NULL;
char *graph_name;
char *chain_name;
enum { OPENED_NONE, OPENED_GRAPH, OPENED_CHAIN } opened = OPENED_NONE;
@ -101,9 +101,9 @@ static int graph_verify(int argc, const char **argv, const char *prefix,
if (opts.progress)
flags |= COMMIT_GRAPH_WRITE_PROGRESS;

odb = find_odb(the_repository, opts.obj_dir);
graph_name = get_commit_graph_filename(odb);
chain_name = get_commit_graph_chain_filename(odb);
source = odb_find_source(the_repository->objects, opts.obj_dir);
graph_name = get_commit_graph_filename(source);
chain_name = get_commit_graph_chain_filename(source);
if (open_commit_graph(graph_name, &fd, &st))
opened = OPENED_GRAPH;
else if (errno != ENOENT)
@ -120,7 +120,7 @@ static int graph_verify(int argc, const char **argv, const char *prefix,
if (opened == OPENED_NONE)
return 0;
else if (opened == OPENED_GRAPH)
graph = load_commit_graph_one_fd_st(the_repository, fd, &st, odb);
graph = load_commit_graph_one_fd_st(the_repository, fd, &st, source);
else
graph = load_commit_graph_chain_fd_st(the_repository, fd, &st,
&incomplete_chain);
@ -221,7 +221,7 @@ static int graph_write(int argc, const char **argv, const char *prefix,
struct string_list pack_indexes = STRING_LIST_INIT_DUP;
struct strbuf buf = STRBUF_INIT;
struct oidset commits = OIDSET_INIT;
struct object_directory *odb = NULL;
struct odb_source *source = NULL;
int result = 0;
enum commit_graph_write_flags flags = 0;
struct progress *progress = NULL;
@ -289,10 +289,10 @@ static int graph_write(int argc, const char **argv, const char *prefix,
git_env_bool(GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS, 0))
flags |= COMMIT_GRAPH_WRITE_BLOOM_FILTERS;

odb = find_odb(the_repository, opts.obj_dir);
source = odb_find_source(the_repository->objects, opts.obj_dir);

if (opts.reachable) {
if (write_commit_graph_reachable(odb, flags, &write_opts))
if (write_commit_graph_reachable(source, flags, &write_opts))
result = 1;
goto cleanup;
}
@ -319,7 +319,7 @@ static int graph_write(int argc, const char **argv, const char *prefix,
stop_progress(&progress);
}

if (write_commit_graph(odb,
if (write_commit_graph(source,
opts.stdin_packs ? &pack_indexes : NULL,
opts.stdin_commits ? &commits : NULL,
flags,

View File

@ -9,7 +9,7 @@
#include "gettext.h"
#include "hex.h"
#include "object-name.h"
#include "object-store.h"
#include "odb.h"

#include "commit.h"
#include "parse-options.h"
@ -48,7 +48,7 @@ static int parse_parent_arg_callback(const struct option *opt,
if (repo_get_oid_commit(the_repository, arg, &oid))
die(_("not a valid object name %s"), arg);

assert_oid_type(&oid, OBJ_COMMIT);
odb_assert_oid_type(the_repository->objects, &oid, OBJ_COMMIT);
new_parent(lookup_commit(the_repository, &oid), parents);
return 0;
}

View File

@ -80,10 +80,10 @@ static int count_cruft(const char *basename UNUSED, const char *path,
return 0;
}

static int print_alternate(struct object_directory *odb, void *data UNUSED)
static int print_alternate(struct odb_source *alternate, void *data UNUSED)
{
printf("alternate: ");
quote_c_style(odb->path, NULL, stdout, 0);
quote_c_style(alternate->path, NULL, stdout, 0);
putchar('\n');
return 0;
}
@ -159,7 +159,7 @@ int cmd_count_objects(int argc,
printf("prune-packable: %lu\n", packed_loose);
printf("garbage: %lu\n", garbage);
printf("size-garbage: %s\n", garbage_buf.buf);
foreach_alt_odb(print_alternate, NULL);
odb_for_each_alternate(the_repository->objects, print_alternate, NULL);
strbuf_release(&loose_buf);
strbuf_release(&pack_buf);
strbuf_release(&garbage_buf);

View File

@ -19,7 +19,7 @@
#include "setup.h"
#include "strvec.h"
#include "run-command.h"
#include "object-store.h"
#include "odb.h"
#include "list-objects.h"
#include "commit-slab.h"
#include "wildmatch.h"
@ -552,7 +552,8 @@ static void describe(const char *arg, int last_one)

if (cmit)
describe_commit(&oid, &sb);
else if (oid_object_info(the_repository, &oid, NULL) == OBJ_BLOB)
else if (odb_read_object_info(the_repository->objects,
&oid, NULL) == OBJ_BLOB)
describe_blob(oid, &sb);
else
die(_("%s is neither a commit nor blob"), arg);

View File

@ -30,7 +30,7 @@
#include "strbuf.h"
#include "lockfile.h"
#include "object-file.h"
#include "object-store.h"
#include "odb.h"
#include "dir.h"
#include "entry.h"
#include "setup.h"
@ -320,7 +320,7 @@ static char *get_symlink(struct repository *repo,
} else {
enum object_type type;
unsigned long size;
data = repo_read_object_file(repo, oid, &type, &size);
data = odb_read_object(repo->objects, oid, &type, &size);
if (!data)
die(_("could not read object %s for symlink %s"),
oid_to_hex(oid), path);

View File

@ -14,7 +14,7 @@
#include "refs.h"
#include "refspec.h"
#include "object-file.h"
#include "object-store.h"
#include "odb.h"
#include "commit.h"
#include "object.h"
#include "tag.h"
@ -323,7 +323,7 @@ static void export_blob(const struct object_id *oid)
object = (struct object *)lookup_blob(the_repository, oid);
eaten = 0;
} else {
buf = repo_read_object_file(the_repository, oid, &type, &size);
buf = odb_read_object(the_repository->objects, oid, &type, &size);
if (!buf)
die("could not read blob %s", oid_to_hex(oid));
if (check_object_signature(the_repository, oid, buf, size,
@ -869,8 +869,8 @@ static void handle_tag(const char *name, struct tag *tag)
return;
}

buf = repo_read_object_file(the_repository, &tag->object.oid, &type,
&size);
buf = odb_read_object(the_repository->objects, &tag->object.oid,
&type, &size);
if (!buf)
die("could not read tag %s", oid_to_hex(&tag->object.oid));
message = memmem(buf, size, "\n\n", 2);
@ -1200,7 +1200,7 @@ static void import_marks(char *input_file, int check_exists)
if (last_idnum < mark)
last_idnum = mark;

type = oid_object_info(the_repository, &oid, NULL);
type = odb_read_object_info(the_repository->objects, &oid, NULL);
if (type < 0)
die("object not found: %s", oid_to_hex(&oid));


View File

@ -24,7 +24,7 @@
#include "packfile.h"
#include "object-file.h"
#include "object-name.h"
#include "object-store.h"
#include "odb.h"
#include "mem-pool.h"
#include "commit-reach.h"
#include "khash.h"
@ -763,7 +763,8 @@ static void start_packfile(void)
struct packed_git *p;
int pack_fd;

pack_fd = odb_mkstemp(&tmp_file, "pack/tmp_pack_XXXXXX");
pack_fd = odb_mkstemp(the_repository->objects, &tmp_file,
"pack/tmp_pack_XXXXXX");
FLEX_ALLOC_STR(p, pack_name, tmp_file.buf);
strbuf_release(&tmp_file);

@ -1264,7 +1265,7 @@ static void load_tree(struct tree_entry *root)
die("Can't load tree %s", oid_to_hex(oid));
} else {
enum object_type type;
buf = repo_read_object_file(the_repository, oid, &type, &size);
buf = odb_read_object(the_repository->objects, oid, &type, &size);
if (!buf || type != OBJ_TREE)
die("Can't load tree %s", oid_to_hex(oid));
}
@ -1755,7 +1756,7 @@ static void insert_object_entry(struct mark_set **s, struct object_id *oid, uint
struct object_entry *e;
e = find_object(oid);
if (!e) {
enum object_type type = oid_object_info(the_repository,
enum object_type type = odb_read_object_info(the_repository->objects,
oid, NULL);
if (type < 0)
die("object not found: %s", oid_to_hex(oid));
@ -2415,8 +2416,8 @@ static void file_change_m(const char *p, struct branch *b)
enum object_type expected = S_ISDIR(mode) ?
OBJ_TREE: OBJ_BLOB;
enum object_type type = oe ? oe->type :
oid_object_info(the_repository, &oid,
NULL);
odb_read_object_info(the_repository->objects,
&oid, NULL);
if (type < 0)
die("%s not found: %s",
S_ISDIR(mode) ? "Tree" : "Blob",
@ -2534,9 +2535,8 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa
oidcpy(&commit_oid, &commit_oe->idx.oid);
} else if (!repo_get_oid(the_repository, p, &commit_oid)) {
unsigned long size;
char *buf = read_object_with_reference(the_repository,
&commit_oid,
OBJ_COMMIT, &size,
char *buf = odb_read_object_peeled(the_repository->objects,
&commit_oid, OBJ_COMMIT, &size,
&commit_oid);
if (!buf || size < the_hash_algo->hexsz + 6)
die("Not a valid commit: %s", p);
@ -2552,7 +2552,7 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa
die("Not a blob (actually a %s): %s",
type_name(oe->type), command_buf.buf);
} else if (!is_null_oid(&oid)) {
enum object_type type = oid_object_info(the_repository, &oid,
enum object_type type = odb_read_object_info(the_repository->objects, &oid,
NULL);
if (type < 0)
die("Blob not found: %s", command_buf.buf);
@ -2603,9 +2603,8 @@ static void parse_from_existing(struct branch *b)
unsigned long size;
char *buf;

buf = read_object_with_reference(the_repository,
&b->oid, OBJ_COMMIT, &size,
&b->oid);
buf = odb_read_object_peeled(the_repository->objects, &b->oid,
OBJ_COMMIT, &size, &b->oid);
parse_from_commit(b, buf, size);
free(buf);
}
@ -2698,9 +2697,8 @@ static struct hash_list *parse_merge(unsigned int *count)
oidcpy(&n->oid, &oe->idx.oid);
} else if (!repo_get_oid(the_repository, from, &n->oid)) {
unsigned long size;
char *buf = read_object_with_reference(the_repository,
&n->oid,
OBJ_COMMIT,
char *buf = odb_read_object_peeled(the_repository->objects,
&n->oid, OBJ_COMMIT,
&size, &n->oid);
if (!buf || size < the_hash_algo->hexsz + 6)
die("Not a valid commit: %s", from);
@ -2894,7 +2892,8 @@ static void parse_new_tag(const char *arg)
} else if (!repo_get_oid(the_repository, from, &oid)) {
struct object_entry *oe = find_object(&oid);
if (!oe) {
type = oid_object_info(the_repository, &oid, NULL);
type = odb_read_object_info(the_repository->objects,
&oid, NULL);
if (type < 0)
die("Not a valid object: %s", from);
} else
@ -3000,7 +2999,7 @@ static void cat_blob(struct object_entry *oe, struct object_id *oid)
char *buf;

if (!oe || oe->pack_id == MAX_PACK_ID) {
buf = repo_read_object_file(the_repository, oid, &type, &size);
buf = odb_read_object(the_repository->objects, oid, &type, &size);
} else {
type = oe->type;
buf = gfi_unpack_entry(oe, &size);
@ -3084,8 +3083,8 @@ static struct object_entry *dereference(struct object_entry *oe,
const unsigned hexsz = the_hash_algo->hexsz;

if (!oe) {
enum object_type type = oid_object_info(the_repository, oid,
NULL);
enum object_type type = odb_read_object_info(the_repository->objects,
oid, NULL);
if (type < 0)
die("object not found: %s", oid_to_hex(oid));
/* cache it! */
@ -3108,8 +3107,8 @@ static struct object_entry *dereference(struct object_entry *oe,
buf = gfi_unpack_entry(oe, &size);
} else {
enum object_type unused;
buf = repo_read_object_file(the_repository, oid, &unused,
&size);
buf = odb_read_object(the_repository->objects, oid,
&unused, &size);
}
if (!buf)
die("Can't load object %s", oid_to_hex(oid));

View File

@ -14,7 +14,7 @@
#include "refs.h"
#include "refspec.h"
#include "object-name.h"
#include "object-store.h"
#include "odb.h"
#include "oidset.h"
#include "oid-array.h"
#include "commit.h"
@ -366,9 +366,9 @@ static void find_non_local_tags(const struct ref *refs,
*/
if (ends_with(ref->name, "^{}")) {
if (item &&
!has_object(the_repository, &ref->old_oid, 0) &&
!odb_has_object(the_repository->objects, &ref->old_oid, 0) &&
!oidset_contains(&fetch_oids, &ref->old_oid) &&
!has_object(the_repository, &item->oid, 0) &&
!odb_has_object(the_repository->objects, &item->oid, 0) &&
!oidset_contains(&fetch_oids, &item->oid))
clear_item(item);
item = NULL;
@ -382,7 +382,7 @@ static void find_non_local_tags(const struct ref *refs,
* fetch.
*/
if (item &&
!has_object(the_repository, &item->oid, 0) &&
!odb_has_object(the_repository->objects, &item->oid, 0) &&
!oidset_contains(&fetch_oids, &item->oid))
clear_item(item);

@ -403,7 +403,7 @@ static void find_non_local_tags(const struct ref *refs,
* checked to see if it needs fetching.
*/
if (item &&
!has_object(the_repository, &item->oid, 0) &&
!odb_has_object(the_repository->objects, &item->oid, 0) &&
!oidset_contains(&fetch_oids, &item->oid))
clear_item(item);

@ -873,7 +873,7 @@ static int update_local_ref(struct ref *ref,
struct commit *current = NULL, *updated;
int fast_forward = 0;

if (!has_object(the_repository, &ref->new_oid,
if (!odb_has_object(the_repository->objects, &ref->new_oid,
HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
die(_("object %s not found"), oid_to_hex(&ref->new_oid));

@ -1287,7 +1287,8 @@ static int check_exist_and_connected(struct ref *ref_map)
* we need all direct targets to exist.
*/
for (r = rm; r; r = r->next) {
if (!has_object(the_repository, &r->old_oid, HAS_OBJECT_RECHECK_PACKED))
if (!odb_has_object(the_repository->objects, &r->old_oid,
HAS_OBJECT_RECHECK_PACKED))
return -1;
}

@ -1441,7 +1442,7 @@ static void add_negotiation_tips(struct git_transport_options *smart_options)
struct object_id oid;
if (repo_get_oid(the_repository, s, &oid))
die(_("%s is not a valid object"), s);
if (!has_object(the_repository, &oid, 0))
if (!odb_has_object(the_repository->objects, &oid, 0))
die(_("the object %s does not exist"), s);
oid_array_append(oids, &oid);
continue;
@ -2672,7 +2673,7 @@ int cmd_fetch(int argc,
commit_graph_flags |= COMMIT_GRAPH_WRITE_PROGRESS;

trace2_region_enter("fetch", "write-commit-graph", the_repository);
write_commit_graph_reachable(the_repository->objects->odb,
write_commit_graph_reachable(the_repository->objects->sources,
commit_graph_flags,
NULL);
trace2_region_leave("fetch", "write-commit-graph", the_repository);

View File

@ -17,7 +17,7 @@
#include "packfile.h"
#include "object-file.h"
#include "object-name.h"
#include "object-store.h"
#include "odb.h"
#include "path.h"
#include "read-cache-ll.h"
#include "replace-object.h"
@ -71,7 +71,8 @@ static const char *printable_type(const struct object_id *oid,
const char *ret;

if (type == OBJ_NONE)
type = oid_object_info(the_repository, oid, NULL);
type = odb_read_object_info(the_repository->objects,
oid, NULL);

ret = type_name(type);
if (!ret)
@ -160,7 +161,7 @@ static int mark_object(struct object *obj, enum object_type type,
return 0;

if (!(obj->flags & HAS_OBJ)) {
if (parent && !has_object(the_repository, &obj->oid, 1)) {
if (parent && !odb_has_object(the_repository->objects, &obj->oid, 1)) {
printf_ln(_("broken link from %7s %s\n"
" to %7s %s"),
printable_type(&parent->oid, parent->type),
@ -232,7 +233,7 @@ static void mark_unreachable_referents(const struct object_id *oid)
* (and we want to avoid parsing blobs).
*/
if (obj->type == OBJ_NONE) {
enum object_type type = oid_object_info(the_repository,
enum object_type type = odb_read_object_info(the_repository->objects,
&obj->oid, NULL);
if (type > 0)
object_as_type(obj, type, 0);
@ -956,7 +957,7 @@ int cmd_fsck(int argc,
struct repository *repo UNUSED)
{
int i;
struct object_directory *odb;
struct odb_source *source;

/* fsck knows how to handle missing promisor objects */
fetch_if_missing = 0;
@ -997,9 +998,9 @@ int cmd_fsck(int argc,
for_each_packed_object(the_repository,
mark_packed_for_connectivity, NULL, 0);
} else {
prepare_alt_odb(the_repository);
for (odb = the_repository->objects->odb; odb; odb = odb->next)
fsck_object_dir(odb->path);
odb_prepare_alternates(the_repository->objects);
for (source = the_repository->objects->sources; source; source = source->next)
fsck_object_dir(source->path);

if (check_full) {
struct packed_git *p;
@ -1108,12 +1109,12 @@ int cmd_fsck(int argc,
if (the_repository->settings.core_commit_graph) {
struct child_process commit_graph_verify = CHILD_PROCESS_INIT;

prepare_alt_odb(the_repository);
for (odb = the_repository->objects->odb; odb; odb = odb->next) {
odb_prepare_alternates(the_repository->objects);
for (source = the_repository->objects->sources; source; source = source->next) {
child_process_init(&commit_graph_verify);
commit_graph_verify.git_cmd = 1;
strvec_pushl(&commit_graph_verify.args, "commit-graph",
"verify", "--object-dir", odb->path, NULL);
"verify", "--object-dir", source->path, NULL);
if (show_progress)
strvec_push(&commit_graph_verify.args, "--progress");
else
@ -1126,12 +1127,12 @@ int cmd_fsck(int argc,
if (the_repository->settings.core_multi_pack_index) {
struct child_process midx_verify = CHILD_PROCESS_INIT;

prepare_alt_odb(the_repository);
for (odb = the_repository->objects->odb; odb; odb = odb->next) {
odb_prepare_alternates(the_repository->objects);
for (source = the_repository->objects->sources; source; source = source->next) {
child_process_init(&midx_verify);
midx_verify.git_cmd = 1;
strvec_pushl(&midx_verify.args, "multi-pack-index",
"verify", "--object-dir", odb->path, NULL);
"verify", "--object-dir", source->path, NULL);
if (show_progress)
strvec_push(&midx_verify.args, "--progress");
else

View File

@ -1047,7 +1047,7 @@ int cmd_gc(int argc,
}

if (the_repository->settings.gc_write_commit_graph == 1)
write_commit_graph_reachable(the_repository->objects->odb,
write_commit_graph_reachable(the_repository->objects->sources,
!opts.quiet && !daemonized ? COMMIT_GRAPH_WRITE_PROGRESS : 0,
NULL);

@ -1110,7 +1110,7 @@ static int dfs_on_ref(const char *refname UNUSED,

if (!peel_iterated_oid(the_repository, oid, &peeled))
oid = &peeled;
if (oid_object_info(the_repository, oid, NULL) != OBJ_COMMIT)
if (odb_read_object_info(the_repository->objects, oid, NULL) != OBJ_COMMIT)
return 0;

commit = lookup_commit(the_repository, oid);
@ -1308,7 +1308,7 @@ static int loose_object_auto_condition(struct gc_config *cfg UNUSED)
if (loose_object_auto_limit < 0)
return 1;

return for_each_loose_file_in_objdir(the_repository->objects->odb->path,
return for_each_loose_file_in_objdir(the_repository->objects->sources->path,
loose_object_count,
NULL, NULL, &count);
}
@ -1343,7 +1343,7 @@ static int pack_loose(struct maintenance_run_opts *opts)
* Do not start pack-objects process
* if there are no loose objects.
*/
if (!for_each_loose_file_in_objdir(r->objects->odb->path,
if (!for_each_loose_file_in_objdir(r->objects->sources->path,
bail_on_loose,
NULL, NULL, NULL))
return 0;
@ -1355,7 +1355,7 @@ static int pack_loose(struct maintenance_run_opts *opts)
strvec_push(&pack_proc.args, "--quiet");
else
strvec_push(&pack_proc.args, "--no-quiet");
strvec_pushf(&pack_proc.args, "%s/pack/loose", r->objects->odb->path);
strvec_pushf(&pack_proc.args, "%s/pack/loose", r->objects->sources->path);

pack_proc.in = -1;

@ -1383,7 +1383,7 @@ static int pack_loose(struct maintenance_run_opts *opts)
else if (data.batch_size > 0)
data.batch_size--; /* Decrease for equality on limit. */

for_each_loose_file_in_objdir(r->objects->odb->path,
for_each_loose_file_in_objdir(r->objects->sources->path,
write_loose_object_to_stdin,
NULL,
NULL,
@ -1661,7 +1661,7 @@ static int maintenance_run_tasks(struct maintenance_run_opts *opts,
int result = 0;
struct lock_file lk;
struct repository *r = the_repository;
char *lock_path = xstrfmt("%s/maintenance", r->objects->odb->path);
char *lock_path = xstrfmt("%s/maintenance", r->objects->sources->path);

if (hold_lock_file_for_update(&lk, lock_path, LOCK_NO_DEREF) < 0) {
/*
@ -3158,7 +3158,7 @@ static int update_background_schedule(const struct maintenance_start_opts *opts,
unsigned int i;
int result = 0;
struct lock_file lk;
char *lock_path = xstrfmt("%s/schedule", the_repository->objects->odb->path);
char *lock_path = xstrfmt("%s/schedule", the_repository->objects->sources->path);

if (hold_lock_file_for_update(&lk, lock_path, LOCK_NO_DEREF) < 0) {
if (errno == EEXIST)

View File

@ -26,7 +26,7 @@
#include "submodule-config.h"
#include "object-file.h"
#include "object-name.h"
#include "object-store.h"
#include "odb.h"
#include "packfile.h"
#include "pager.h"
#include "path.h"
@ -462,7 +462,7 @@ static int grep_submodule(struct grep_opt *opt,

/*
* NEEDSWORK: repo_read_gitmodules() might call
* add_to_alternates_memory() via config_from_gitmodules(). This
* odb_add_to_alternates_memory() via config_from_gitmodules(). This
* operation causes a race condition with concurrent object readings
* performed by the worker threads. That's why we need obj_read_lock()
* here. It should be removed once it's no longer necessary to add the
@ -505,7 +505,8 @@ static int grep_submodule(struct grep_opt *opt,
* lazily registered as alternates when needed (and except in an
* unexpected code interaction, it won't be needed).
*/
add_submodule_odb_by_path(subrepo->objects->odb->path);
odb_add_submodule_source_by_path(the_repository->objects,
subrepo->objects->sources->path);
obj_read_unlock();

memcpy(&subopt, opt, sizeof(subopt));
@ -519,11 +520,9 @@ static int grep_submodule(struct grep_opt *opt,
struct strbuf base = STRBUF_INIT;

obj_read_lock();
object_type = oid_object_info(subrepo, oid, NULL);
object_type = odb_read_object_info(subrepo->objects, oid, NULL);
obj_read_unlock();
data = read_object_with_reference(subrepo,
oid, OBJ_TREE,
&size, NULL);
data = odb_read_object_peeled(subrepo->objects, oid, OBJ_TREE, &size, NULL);
if (!data)
die(_("unable to read tree (%s)"), oid_to_hex(oid));

@ -572,7 +571,7 @@ static int grep_cache(struct grep_opt *opt,
void *data;
unsigned long size;

data = repo_read_object_file(the_repository, &ce->oid,
data = odb_read_object(the_repository->objects, &ce->oid,
&type, &size);
if (!data)
die(_("unable to read tree %s"), oid_to_hex(&ce->oid));
@ -665,7 +664,7 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,
void *data;
unsigned long size;

data = repo_read_object_file(the_repository,
data = odb_read_object(the_repository->objects,
&entry.oid, &type, &size);
if (!data)
die(_("unable to read tree (%s)"),
@ -704,9 +703,8 @@ static int grep_object(struct grep_opt *opt, const struct pathspec *pathspec,
struct strbuf base;
int hit, len;

data = read_object_with_reference(opt->repo,
&obj->oid, OBJ_TREE,
&size, NULL);
data = odb_read_object_peeled(opt->repo->objects, &obj->oid,
OBJ_TREE, &size, NULL);
if (!data)
die(_("unable to read tree (%s)"), oid_to_hex(&obj->oid));


View File

@ -11,7 +11,7 @@
#include "gettext.h"
#include "hex.h"
#include "object-file.h"
#include "object-store.h"
#include "odb.h"
#include "blob.h"
#include "quote.h"
#include "parse-options.h"

View File

@ -21,7 +21,7 @@
#include "packfile.h"
#include "pack-revindex.h"
#include "object-file.h"
#include "object-store.h"
#include "odb.h"
#include "oid-array.h"
#include "oidset.h"
#include "path.h"
@ -260,7 +260,8 @@ static unsigned check_object(struct object *obj)

if (!(obj->flags & FLAG_CHECKED)) {
unsigned long size;
int type = oid_object_info(the_repository, &obj->oid, &size);
int type = odb_read_object_info(the_repository->objects,
&obj->oid, &size);
if (type <= 0)
die(_("did not receive expected object %s"),
oid_to_hex(&obj->oid));
@ -362,7 +363,7 @@ static const char *open_pack_file(const char *pack_name)
input_fd = 0;
if (!pack_name) {
struct strbuf tmp_file = STRBUF_INIT;
output_fd = odb_mkstemp(&tmp_file,
output_fd = odb_mkstemp(the_repository->objects, &tmp_file,
"pack/tmp_pack_XXXXXX");
pack_name = strbuf_detach(&tmp_file, NULL);
} else {
@ -892,7 +893,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,

if (startup_info->have_repository) {
read_lock();
collision_test_needed = has_object(the_repository, oid,
collision_test_needed = odb_has_object(the_repository->objects, oid,
HAS_OBJECT_FETCH_PROMISOR);
read_unlock();
}
@ -908,12 +909,12 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
enum object_type has_type;
unsigned long has_size;
read_lock();
has_type = oid_object_info(the_repository, oid, &has_size);
has_type = odb_read_object_info(the_repository->objects, oid, &has_size);
if (has_type < 0)
die(_("cannot read existing object info %s"), oid_to_hex(oid));
if (has_type != type || has_size != size)
die(_("SHA1 COLLISION FOUND WITH %s !"), oid_to_hex(oid));
has_data = repo_read_object_file(the_repository, oid,
has_data = odb_read_object(the_repository->objects, oid,
&has_type, &has_size);
read_unlock();
if (!data)
@ -1501,8 +1502,8 @@ static void fix_unresolved_deltas(struct hashfile *f)
struct oid_array to_fetch = OID_ARRAY_INIT;
for (i = 0; i < nr_ref_deltas; i++) {
struct ref_delta_entry *d = sorted_by_pos[i];
if (!oid_object_info_extended(the_repository, &d->oid,
NULL,
if (!odb_read_object_info_extended(the_repository->objects,
&d->oid, NULL,
OBJECT_INFO_FOR_PREFETCH))
continue;
oid_array_append(&to_fetch, &d->oid);
@ -1520,8 +1521,8 @@ static void fix_unresolved_deltas(struct hashfile *f)

if (objects[d->obj_no].real_type != OBJ_REF_DELTA)
continue;
data = repo_read_object_file(the_repository, &d->oid, &type,
&size);
data = odb_read_object(the_repository->objects, &d->oid,
&type, &size);
if (!data)
continue;

@ -1829,7 +1830,7 @@ static void repack_local_links(void)
oidset_iter_init(&outgoing_links, &iter);
while ((oid = oidset_iter_next(&iter))) {
struct object_info info = OBJECT_INFO_INIT;
if (oid_object_info_extended(the_repository, oid, &info, 0))
if (odb_read_object_info_extended(the_repository->objects, oid, &info, 0))
/* Missing; assume it is a promisor object */
continue;
if (info.whence == OI_PACKED && info.u.packed.pack->pack_promisor)

View File

@ -15,7 +15,7 @@
#include "hex.h"
#include "refs.h"
#include "object-name.h"
#include "object-store.h"
#include "odb.h"
#include "pager.h"
#include "color.h"
#include "commit.h"
@ -733,7 +733,7 @@ static int show_tag_object(const struct object_id *oid, struct rev_info *rev)
{
unsigned long size;
enum object_type type;
char *buf = repo_read_object_file(the_repository, oid, &type, &size);
char *buf = odb_read_object(the_repository->objects, oid, &type, &size);
unsigned long offset = 0;

if (!buf)

View File

@ -25,7 +25,7 @@
#include "setup.h"
#include "sparse-index.h"
#include "submodule.h"
#include "object-store.h"
#include "odb.h"
#include "hex.h"


@ -251,7 +251,7 @@ static void expand_objectsize(struct repository *repo, struct strbuf *line,
{
if (type == OBJ_BLOB) {
unsigned long size;
if (oid_object_info(repo, oid, &size) < 0)
if (odb_read_object_info(repo->objects, oid, &size) < 0)
die(_("could not get object info about '%s'"),
oid_to_hex(oid));
if (padded)

View File

@ -10,7 +10,7 @@
#include "gettext.h"
#include "hex.h"
#include "object-name.h"
#include "object-store.h"
#include "odb.h"
#include "tree.h"
#include "path.h"
#include "quote.h"
@ -27,7 +27,7 @@ static void expand_objectsize(struct strbuf *line, const struct object_id *oid,
{
if (type == OBJ_BLOB) {
unsigned long size;
if (oid_object_info(the_repository, oid, &size) < 0)
if (odb_read_object_info(the_repository->objects, oid, &size) < 0)
die(_("could not get object info about '%s'"),
oid_to_hex(oid));
if (padded)
@ -217,7 +217,7 @@ static int show_tree_long(const struct object_id *oid, struct strbuf *base,

if (type == OBJ_BLOB) {
unsigned long size;
if (oid_object_info(the_repository, oid, &size) == OBJ_BAD)
if (odb_read_object_info(the_repository->objects, oid, &size) == OBJ_BAD)
xsnprintf(size_text, sizeof(size_text), "BAD");
else
xsnprintf(size_text, sizeof(size_text),

View File

@ -7,7 +7,7 @@
#include "hex.h"
#include "object-file.h"
#include "object-name.h"
#include "object-store.h"
#include "odb.h"
#include "config.h"
#include "gettext.h"
#include "setup.h"

View File

@ -10,7 +10,7 @@
#include "commit-reach.h"
#include "merge-ort.h"
#include "object-name.h"
#include "object-store.h"
#include "odb.h"
#include "parse-options.h"
#include "blob.h"
#include "merge-blobs.h"
@ -75,7 +75,7 @@ static void *result(struct merge_list *entry, unsigned long *size)
const char *path = entry->path;

if (!entry->stage)
return repo_read_object_file(the_repository,
return odb_read_object(the_repository->objects,
&entry->blob->object.oid, &type,
size);
base = NULL;
@ -100,7 +100,7 @@ static void *origin(struct merge_list *entry, unsigned long *size)
enum object_type type;
while (entry) {
if (entry->stage == 2)
return repo_read_object_file(the_repository,
return odb_read_object(the_repository->objects,
&entry->blob->object.oid,
&type, size);
entry = entry->link;

View File

@ -6,7 +6,7 @@
#include "strbuf.h"
#include "replace-object.h"
#include "object-file.h"
#include "object-store.h"
#include "odb.h"
#include "fsck.h"
#include "config.h"

@ -54,8 +54,8 @@ static int verify_object_in_tag(struct object_id *tagged_oid, int *tagged_type)
void *buffer;
const struct object_id *repl;

buffer = repo_read_object_file(the_repository, tagged_oid, &type,
&size);
buffer = odb_read_object(the_repository->objects, tagged_oid,
&type, &size);
if (!buffer)
die(_("could not read tagged object '%s'"),
oid_to_hex(tagged_oid));

View File

@ -12,7 +12,7 @@
#include "tree.h"
#include "parse-options.h"
#include "object-file.h"
#include "object-store.h"
#include "odb.h"

static struct treeent {
unsigned mode;
@ -124,7 +124,7 @@ static void mktree_line(char *buf, int nul_term_line, int allow_missing)

/* Check the type of object identified by oid without fetching objects */
oi.typep = &obj_type;
if (oid_object_info_extended(the_repository, &oid, &oi,
if (odb_read_object_info_extended(the_repository->objects, &oid, &oi,
OBJECT_INFO_LOOKUP_REPLACE |
OBJECT_INFO_QUICK |
OBJECT_INFO_SKIP_FETCH_OBJECT) < 0)

View File

@ -7,7 +7,7 @@
#include "midx.h"
#include "strbuf.h"
#include "trace2.h"
#include "object-store.h"
#include "odb.h"
#include "replace-object.h"
#include "repository.h"

@ -294,8 +294,8 @@ int cmd_multi_pack_index(int argc,

if (the_repository &&
the_repository->objects &&
the_repository->objects->odb)
opts.object_dir = xstrdup(the_repository->objects->odb->path);
the_repository->objects->sources)
opts.object_dir = xstrdup(the_repository->objects->sources->path);

argc = parse_options(argc, argv, prefix, options,
builtin_multi_pack_index_usage, 0);

View File

@ -16,7 +16,7 @@
#include "notes.h"
#include "object-file.h"
#include "object-name.h"
#include "object-store.h"
#include "odb.h"
#include "path.h"

#include "pretty.h"
@ -152,7 +152,7 @@ static void copy_obj_to_fd(int fd, const struct object_id *oid)
{
unsigned long size;
enum object_type type;
char *buf = repo_read_object_file(the_repository, oid, &type, &size);
char *buf = odb_read_object(the_repository->objects, oid, &type, &size);
if (buf) {
if (size)
write_or_die(fd, buf, size);
@ -319,7 +319,7 @@ static int parse_reuse_arg(const struct option *opt, const char *arg, int unset)
strbuf_init(&msg->buf, 0);
if (repo_get_oid(the_repository, arg, &object))
die(_("failed to resolve '%s' as a valid ref."), arg);
if (!(value = repo_read_object_file(the_repository, &object, &type, &len)))
if (!(value = odb_read_object(the_repository->objects, &object, &type, &len)))
die(_("failed to read object '%s'."), arg);
if (type != OBJ_BLOB) {
strbuf_release(&msg->buf);
@ -722,7 +722,7 @@ static int append_edit(int argc, const char **argv, const char *prefix,
unsigned long size;
enum object_type type;
struct strbuf buf = STRBUF_INIT;
char *prev_buf = repo_read_object_file(the_repository, note, &type, &size);
char *prev_buf = odb_read_object(the_repository->objects, note, &type, &size);

if (!prev_buf)
die(_("unable to read %s"), oid_to_hex(note));

View File

@ -32,7 +32,7 @@
#include "list.h"
#include "packfile.h"
#include "object-file.h"
#include "object-store.h"
#include "odb.h"
#include "replace-object.h"
#include "dir.h"
#include "midx.h"
@ -349,11 +349,11 @@ static void *get_delta(struct object_entry *entry)
void *buf, *base_buf, *delta_buf;
enum object_type type;

buf = repo_read_object_file(the_repository, &entry->idx.oid, &type,
&size);
buf = odb_read_object(the_repository->objects, &entry->idx.oid,
&type, &size);
if (!buf)
die(_("unable to read %s"), oid_to_hex(&entry->idx.oid));
base_buf = repo_read_object_file(the_repository,
base_buf = odb_read_object(the_repository->objects,
&DELTA(entry)->idx.oid, &type,
&base_size);
if (!base_buf)
@ -518,7 +518,7 @@ static unsigned long write_no_reuse_object(struct hashfile *f, struct object_ent
&size, NULL)) != NULL)
buf = NULL;
else {
buf = repo_read_object_file(the_repository,
buf = odb_read_object(the_repository->objects,
&entry->idx.oid, &type,
&size);
if (!buf)
@ -1907,7 +1907,7 @@ static struct pbase_tree_cache *pbase_tree_get(const struct object_id *oid)
/* Did not find one. Either we got a bogus request or
* we need to read and perhaps cache.
*/
data = repo_read_object_file(the_repository, oid, &type, &size);
data = odb_read_object(the_repository->objects, oid, &type, &size);
if (!data)
return NULL;
if (type != OBJ_TREE) {
@ -2067,7 +2067,7 @@ static void add_preferred_base(struct object_id *oid)
if (window <= num_preferred_base++)
return;

data = read_object_with_reference(the_repository, oid,
data = odb_read_object_peeled(the_repository->objects, oid,
OBJ_TREE, &size, &tree_oid);
if (!data)
return;
@ -2166,7 +2166,7 @@ static void prefetch_to_pack(uint32_t object_index_start) {
for (i = object_index_start; i < to_pack.nr_objects; i++) {
struct object_entry *entry = to_pack.objects + i;

if (!oid_object_info_extended(the_repository,
if (!odb_read_object_info_extended(the_repository->objects,
&entry->idx.oid,
NULL,
OBJECT_INFO_FOR_PREFETCH))
@ -2310,18 +2310,18 @@ static void check_object(struct object_entry *entry, uint32_t object_index)

/*
* No choice but to fall back to the recursive delta walk
* with oid_object_info() to find about the object type
* with odb_read_object_info() to find about the object type
* at this point...
*/
give_up:
unuse_pack(&w_curs);
}

if (oid_object_info_extended(the_repository, &entry->idx.oid, &oi,
if (odb_read_object_info_extended(the_repository->objects, &entry->idx.oid, &oi,
OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0) {
if (repo_has_promisor_remote(the_repository)) {
prefetch_to_pack(object_index);
if (oid_object_info_extended(the_repository, &entry->idx.oid, &oi,
if (odb_read_object_info_extended(the_repository->objects, &entry->idx.oid, &oi,
OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0)
type = -1;
} else {
@ -2396,12 +2396,13 @@ static void drop_reused_delta(struct object_entry *entry)
if (packed_object_info(the_repository, IN_PACK(entry), entry->in_pack_offset, &oi) < 0) {
/*
* We failed to get the info from this pack for some reason;
* fall back to oid_object_info, which may find another copy.
* fall back to odb_read_object_info, which may find another copy.
* And if that fails, the error will be recorded in oe_type(entry)
* and dealt with in prepare_pack().
*/
oe_set_type(entry,
oid_object_info(the_repository, &entry->idx.oid, &size));
odb_read_object_info(the_repository->objects,
&entry->idx.oid, &size));
} else {
oe_set_type(entry, type);
}
@ -2689,7 +2690,8 @@ unsigned long oe_get_size_slow(struct packing_data *pack,

if (e->type_ != OBJ_OFS_DELTA && e->type_ != OBJ_REF_DELTA) {
packing_data_lock(&to_pack);
if (oid_object_info(the_repository, &e->idx.oid, &size) < 0)
if (odb_read_object_info(the_repository->objects,
&e->idx.oid, &size) < 0)
die(_("unable to get size of %s"),
oid_to_hex(&e->idx.oid));
packing_data_unlock(&to_pack);
@ -2772,7 +2774,7 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
/* Load data if not already done */
if (!trg->data) {
packing_data_lock(&to_pack);
trg->data = repo_read_object_file(the_repository,
trg->data = odb_read_object(the_repository->objects,
&trg_entry->idx.oid, &type,
&sz);
packing_data_unlock(&to_pack);
@ -2787,7 +2789,7 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
}
if (!src->data) {
packing_data_lock(&to_pack);
src->data = repo_read_object_file(the_repository,
src->data = odb_read_object(the_repository->objects,
&src_entry->idx.oid, &type,
&sz);
packing_data_unlock(&to_pack);
@ -4197,7 +4199,7 @@ static void show_object__ma_allow_any(struct object *obj, const char *name, void
* Quietly ignore ALL missing objects. This avoids problems with
* staging them now and getting an odd error later.
*/
if (!has_object(the_repository, &obj->oid, 0))
if (!odb_has_object(the_repository->objects, &obj->oid, 0))
return;

show_object(obj, name, data);
@ -4211,7 +4213,7 @@ static void show_object__ma_allow_promisor(struct object *obj, const char *name,
* Quietly ignore EXPECTED missing objects. This avoids problems with
* staging them now and getting an odd error later.
*/
if (!has_object(the_repository, &obj->oid, 0) &&
if (!odb_has_object(the_repository->objects, &obj->oid, 0) &&
is_promisor_object(to_pack.repo, &obj->oid))
return;

@ -4294,7 +4296,7 @@ static void add_objects_in_unpacked_packs(void)
static int add_loose_object(const struct object_id *oid, const char *path,
void *data UNUSED)
{
enum object_type type = oid_object_info(the_repository, oid, NULL);
enum object_type type = odb_read_object_info(the_repository->objects, oid, NULL);

if (type < 0) {
warning(_("loose object at %s could not be examined"), path);
@ -4771,7 +4773,7 @@ static int option_parse_cruft_expiration(const struct option *opt UNUSED,
static int is_not_in_promisor_pack_obj(struct object *obj, void *data UNUSED)
{
struct object_info info = OBJECT_INFO_INIT;
if (oid_object_info_extended(the_repository, &obj->oid, &info, 0))
if (odb_read_object_info_extended(the_repository->objects, &obj->oid, &info, 0))
BUG("should_include_obj should only be called on existing objects");
return info.whence != OI_PACKED || !info.u.packed.pack->pack_promisor;
}

View File

@ -13,7 +13,7 @@
#include "hex.h"

#include "packfile.h"
#include "object-store.h"
#include "odb.h"
#include "strbuf.h"

#define BLKSIZE 512

View File

@ -16,7 +16,7 @@
#include "replace-object.h"
#include "object-file.h"
#include "object-name.h"
#include "object-store.h"
#include "odb.h"
#include "shallow.h"

static const char * const prune_usage[] = {
@ -98,7 +98,8 @@ static int prune_object(const struct object_id *oid, const char *fullpath,
if (st.st_mtime > expire)
return 0;
if (show_only || verbose) {
enum object_type type = oid_object_info(revs->repo, oid, NULL);
enum object_type type =
odb_read_object_info(revs->repo->objects, oid, NULL);
printf("%s %s\n", oid_to_hex(oid),
(type > 0) ? type_name(type) : "unknown");
}

View File

@ -33,7 +33,7 @@
#include "packfile.h"
#include "object-file.h"
#include "object-name.h"
#include "object-store.h"
#include "odb.h"
#include "path.h"
#include "protocol.h"
#include "commit-reach.h"
@ -359,7 +359,8 @@ static void write_head_info(void)

refs_for_each_fullref_in(get_main_ref_store(the_repository), "",
exclude_patterns, show_ref_cb, &seen);
for_each_alternate_ref(show_one_alternate_ref, &seen);
odb_for_each_alternate_ref(the_repository->objects,
show_one_alternate_ref, &seen);

oidset_clear(&seen);
strvec_clear(&excludes_vector);
@ -1508,7 +1509,7 @@ static const char *update(struct command *cmd, struct shallow_info *si)
}

if (!is_null_oid(new_oid) &&
!has_object(the_repository, new_oid,
!odb_has_object(the_repository->objects, new_oid,
HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {
error("unpack should have generated %s, "
"but I can't find it!", oid_to_hex(new_oid));

View File

@ -14,7 +14,7 @@
#include "rebase.h"
#include "refs.h"
#include "refspec.h"
#include "object-store.h"
#include "odb.h"
#include "strvec.h"
#include "commit-reach.h"
#include "progress.h"
@ -454,7 +454,7 @@ static int get_push_ref_states(const struct ref *remote_refs,
info->status = PUSH_STATUS_UPTODATE;
else if (is_null_oid(&ref->old_oid))
info->status = PUSH_STATUS_CREATE;
else if (has_object(the_repository, &ref->old_oid,
else if (odb_has_object(the_repository->objects, &ref->old_oid,
HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) &&
ref_newer(&ref->new_oid, &ref->old_oid))
info->status = PUSH_STATUS_FASTFORWARD;

View File

@ -17,7 +17,7 @@
#include "midx.h"
#include "packfile.h"
#include "prune-packed.h"
#include "object-store.h"
#include "odb.h"
#include "promisor-remote.h"
#include "shallow.h"
#include "pack.h"
@ -710,7 +710,7 @@ static int midx_snapshot_ref_one(const char *refname UNUSED,
if (oidset_insert(&data->seen, oid))
return 0; /* already seen */

if (oid_object_info(the_repository, oid, NULL) != OBJ_COMMIT)
if (odb_read_object_info(the_repository->objects, oid, NULL) != OBJ_COMMIT)
return 0;

fprintf(data->f->fp, "%s%s\n", data->preferred ? "+" : "",
@ -1261,7 +1261,8 @@ int cmd_repack(int argc,
if (write_bitmaps && !(pack_everything & ALL_INTO_ONE) && !write_midx)
die(_(incremental_bitmap_conflict_error));

if (write_bitmaps && po_args.local && has_alt_odb(the_repository)) {
if (write_bitmaps && po_args.local &&
odb_has_alternates(the_repository->objects)) {
/*
* When asked to do a local repack, but we have
* packfiles that are inherited from an alternate, then

View File

@ -19,7 +19,7 @@
#include "run-command.h"
#include "object-file.h"
#include "object-name.h"
#include "object-store.h"
#include "odb.h"
#include "replace-object.h"
#include "tag.h"
#include "wildmatch.h"
@ -65,8 +65,8 @@ static int show_reference(const char *refname,
if (repo_get_oid(data->repo, refname, &object))
return error(_("failed to resolve '%s' as a valid ref"), refname);

obj_type = oid_object_info(data->repo, &object, NULL);
repl_type = oid_object_info(data->repo, oid, NULL);
obj_type = odb_read_object_info(data->repo->objects, &object, NULL);
repl_type = odb_read_object_info(data->repo->objects, oid, NULL);

printf("%s (%s) -> %s (%s)\n", refname, type_name(obj_type),
oid_to_hex(oid), type_name(repl_type));
@ -185,8 +185,8 @@ static int replace_object_oid(const char *object_ref,
struct strbuf err = STRBUF_INIT;
int res = 0;

obj_type = oid_object_info(the_repository, object, NULL);
repl_type = oid_object_info(the_repository, repl, NULL);
obj_type = odb_read_object_info(the_repository->objects, object, NULL);
repl_type = odb_read_object_info(the_repository->objects, repl, NULL);
if (!force && obj_type != repl_type)
return error(_("Objects must be of the same type.\n"
"'%s' points to a replaced object of type '%s'\n"
@ -334,7 +334,7 @@ static int edit_and_replace(const char *object_ref, int force, int raw)
if (repo_get_oid(the_repository, object_ref, &old_oid) < 0)
return error(_("not a valid object name: '%s'"), object_ref);

type = oid_object_info(the_repository, &old_oid, NULL);
type = odb_read_object_info(the_repository->objects, &old_oid, NULL);
if (type < 0)
return error(_("unable to get object type for %s"),
oid_to_hex(&old_oid));

View File

@ -14,7 +14,7 @@
#include "object.h"
#include "object-name.h"
#include "object-file.h"
#include "object-store.h"
#include "odb.h"
#include "pack-bitmap.h"
#include "parse-options.h"
#include "log-tree.h"
@ -110,7 +110,8 @@ static off_t get_object_disk_usage(struct object *obj)
off_t size;
struct object_info oi = OBJECT_INFO_INIT;
oi.disk_sizep = &size;
if (oid_object_info_extended(the_repository, &obj->oid, &oi, 0) < 0)
if (odb_read_object_info_extended(the_repository->objects,
&obj->oid, &oi, 0) < 0)
die(_("unable to get disk usage of %s"), oid_to_hex(&obj->oid));
return size;
}
@ -346,7 +347,8 @@ static void show_commit(struct commit *commit, void *data)
static int finish_object(struct object *obj, const char *name, void *cb_data)
{
struct rev_list_info *info = cb_data;
if (oid_object_info_extended(the_repository, &obj->oid, NULL, 0) < 0) {
if (odb_read_object_info_extended(the_repository->objects,
&obj->oid, NULL, 0) < 0) {
finish_object__ma(obj, name);
return 1;
}

View File

@ -5,7 +5,7 @@
#include "hex.h"
#include "refs/refs-internal.h"
#include "object-name.h"
#include "object-store.h"
#include "odb.h"
#include "object.h"
#include "string-list.h"
#include "parse-options.h"
@ -35,7 +35,7 @@ static void show_one(const struct show_one_options *opts,
const char *hex;
struct object_id peeled;

if (!has_object(the_repository, oid,
if (!odb_has_object(the_repository->objects, oid,
HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
die("git show-ref: bad ref %s (%s)", refname,
oid_to_hex(oid));

View File

@ -28,7 +28,7 @@
#include "diff.h"
#include "object-file.h"
#include "object-name.h"
#include "object-store.h"
#include "odb.h"
#include "advice.h"
#include "branch.h"
#include "list-objects-filter-options.h"
@ -1558,7 +1558,7 @@ static const char alternate_error_advice[] = N_(
);

static int add_possible_reference_from_superproject(
struct object_directory *odb, void *sas_cb)
struct odb_source *alt_odb, void *sas_cb)
{
struct submodule_alternate_setup *sas = sas_cb;
size_t len;
@ -1567,12 +1567,12 @@ static int add_possible_reference_from_superproject(
* If the alternate object store is another repository, try the
* standard layout with .git/(modules/<name>)+/objects
*/
if (strip_suffix(odb->path, "/objects", &len)) {
if (strip_suffix(alt_odb->path, "/objects", &len)) {
struct repository alternate;
char *sm_alternate;
struct strbuf sb = STRBUF_INIT;
struct strbuf err = STRBUF_INIT;
strbuf_add(&sb, odb->path, len);
strbuf_add(&sb, alt_odb->path, len);

if (repo_init(&alternate, sb.buf, NULL) < 0)
die(_("could not get a repository handle for gitdir '%s'"),
@ -1644,7 +1644,8 @@ static void prepare_possible_alternates(const char *sm_name,
die(_("Value '%s' for submodule.alternateErrorStrategy is not recognized"), error_strategy);

if (!strcmp(sm_alternate, "superproject"))
foreach_alt_odb(add_possible_reference_from_superproject, &sas);
odb_for_each_alternate(the_repository->objects,
add_possible_reference_from_superproject, &sas);
else if (!strcmp(sm_alternate, "no"))
; /* do nothing */
else

View File

@ -19,7 +19,7 @@
#include "refs.h"
#include "object-file.h"
#include "object-name.h"
#include "object-store.h"
#include "odb.h"
#include "path.h"
#include "tag.h"
#include "parse-options.h"
@ -244,7 +244,7 @@ static void write_tag_body(int fd, const struct object_id *oid)
struct strbuf payload = STRBUF_INIT;
struct strbuf signature = STRBUF_INIT;

orig = buf = repo_read_object_file(the_repository, oid, &type, &size);
orig = buf = odb_read_object(the_repository->objects, oid, &type, &size);
if (!buf)
return;
if (parse_signature(buf, size, &payload, &signature)) {
@ -304,7 +304,7 @@ static void create_tag(const struct object_id *object, const char *object_ref,
struct strbuf header = STRBUF_INIT;
int should_edit;

type = oid_object_info(the_repository, object, NULL);
type = odb_read_object_info(the_repository->objects, object, NULL);
if (type <= OBJ_NONE)
die(_("bad object type."));

@ -401,13 +401,13 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb)
}

strbuf_addstr(sb, " (");
type = oid_object_info(the_repository, oid, NULL);
type = odb_read_object_info(the_repository->objects, oid, NULL);
switch (type) {
default:
strbuf_addstr(sb, "object of unknown type");
break;
case OBJ_COMMIT:
if ((buf = repo_read_object_file(the_repository, oid, &type, &size))) {
if ((buf = odb_read_object(the_repository->objects, oid, &type, &size))) {
subject_len = find_commit_subject(buf, &subject_start);
strbuf_insert(sb, sb->len, subject_start, subject_len);
} else {

View File

@ -4,7 +4,7 @@
#include "hex.h"
#include "object-file.h"
#include "object-name.h"
#include "object-store.h"
#include "odb.h"

static char *create_temp_file(struct object_id *oid)
{
@ -14,7 +14,7 @@ static char *create_temp_file(struct object_id *oid)
unsigned long size;
int fd;

buf = repo_read_object_file(the_repository, oid, &type, &size);
buf = odb_read_object(the_repository->objects, oid, &type, &size);
if (!buf || type != OBJ_BLOB)
die("unable to read blob object %s", oid_to_hex(oid));


View File

@ -9,7 +9,7 @@
#include "git-zlib.h"
#include "hex.h"
#include "object-file.h"
#include "object-store.h"
#include "odb.h"
#include "object.h"
#include "delta.h"
#include "pack.h"
@ -232,7 +232,7 @@ static int check_object(struct object *obj, enum object_type type,

if (!(obj->flags & FLAG_OPEN)) {
unsigned long size;
int type = oid_object_info(the_repository, &obj->oid, &size);
int type = odb_read_object_info(the_repository->objects, &obj->oid, &size);
if (type != obj->type || type <= 0)
die("object of unexpected type");
obj->flags |= FLAG_WRITTEN;
@ -449,7 +449,7 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,
delta_data = get_data(delta_size);
if (!delta_data)
return;
if (has_object(the_repository, &base_oid,
if (odb_has_object(the_repository->objects, &base_oid,
HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
; /* Ok we have this one */
else if (resolve_against_held(nr, &base_oid,
@ -516,8 +516,8 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,
if (resolve_against_held(nr, &base_oid, delta_data, delta_size))
return;

base = repo_read_object_file(the_repository, &base_oid, &type,
&base_size);
base = odb_read_object(the_repository->objects, &base_oid,
&type, &base_size);
if (!base) {
error("failed to read delta-pack base object %s",
oid_to_hex(&base_oid));

View File

@ -17,7 +17,7 @@
#include "tmp-objdir.h"
#include "packfile.h"
#include "object-file.h"
#include "object-store.h"
#include "odb.h"

static int odb_transaction_nesting;

@ -130,7 +130,7 @@ static void flush_batch_fsync(void)
static int already_written(struct bulk_checkin_packfile *state, struct object_id *oid)
{
/* The object may already exist in the repository */
if (has_object(the_repository, oid,
if (odb_has_object(the_repository->objects, oid,
HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
return 1;


View File

@ -14,7 +14,7 @@
#include "fetch-pack.h"
#include "remote.h"
#include "trace2.h"
#include "object-store.h"
#include "odb.h"

static struct {
enum bundle_list_heuristic heuristic;
@ -278,7 +278,8 @@ static char *find_temp_filename(void)
* Find a temporary filename that is available. This is briefly
* racy, but unlikely to collide.
*/
fd = odb_mkstemp(&name, "bundles/tmp_uri_XXXXXX");
fd = odb_mkstemp(the_repository->objects, &name,
"bundles/tmp_uri_XXXXXX");
if (fd < 0) {
warning(_("failed to create temporary file"));
return NULL;

View File

@ -7,7 +7,7 @@
#include "environment.h"
#include "gettext.h"
#include "hex.h"
#include "object-store.h"
#include "odb.h"
#include "repository.h"
#include "object.h"
#include "commit.h"
@ -233,7 +233,7 @@ int verify_bundle(struct repository *r,
.quiet = 1,
};

if (!r || !r->objects || !r->objects->odb)
if (!r || !r->objects || !r->objects->sources)
return error(_("need a repository to verify a bundle"));

for (i = 0; i < p->nr; i++) {
@ -305,7 +305,7 @@ static int is_tag_in_date_range(struct object *tag, struct rev_info *revs)
if (revs->max_age == -1 && revs->min_age == -1)
goto out;

buf = repo_read_object_file(the_repository, &tag->oid, &type, &size);
buf = odb_read_object(the_repository->objects, &tag->oid, &type, &size);
if (!buf)
goto out;
line = memmem(buf, size, "\ntagger ", 8);

View File

@ -10,7 +10,7 @@
#include "cache-tree.h"
#include "bulk-checkin.h"
#include "object-file.h"
#include "object-store.h"
#include "odb.h"
#include "read-cache-ll.h"
#include "replace-object.h"
#include "repository.h"
@ -239,7 +239,7 @@ int cache_tree_fully_valid(struct cache_tree *it)
if (!it)
return 0;
if (it->entry_count < 0 ||
has_object(the_repository, &it->oid,
odb_has_object(the_repository->objects, &it->oid,
HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
return 0;
for (i = 0; i < it->subtree_nr; i++) {
@ -292,7 +292,7 @@ static int update_one(struct cache_tree *it,
}

if (0 <= it->entry_count &&
has_object(the_repository, &it->oid,
odb_has_object(the_repository->objects, &it->oid,
HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
return it->entry_count;

@ -399,7 +399,8 @@ static int update_one(struct cache_tree *it,
ce_missing_ok = mode == S_IFGITLINK || missing_ok ||
!must_check_existence(ce);
if (is_null_oid(oid) ||
(!ce_missing_ok && !has_object(the_repository, oid,
(!ce_missing_ok &&
!odb_has_object(the_repository->objects, oid,
HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))) {
strbuf_release(&buffer);
if (expected_missing)
@ -448,7 +449,7 @@ static int update_one(struct cache_tree *it,
struct object_id oid;
hash_object_file(the_hash_algo, buffer.buf, buffer.len,
OBJ_TREE, &oid);
if (has_object(the_repository, &oid, HAS_OBJECT_RECHECK_PACKED))
if (odb_has_object(the_repository->objects, &oid, HAS_OBJECT_RECHECK_PACKED))
oidcpy(&it->oid, &oid);
else
to_invalidate = 1;

View File

@ -2,7 +2,7 @@
#define DISABLE_SIGN_COMPARE_WARNINGS

#include "git-compat-util.h"
#include "object-store.h"
#include "odb.h"
#include "commit.h"
#include "convert.h"
#include "diff.h"
@ -325,7 +325,7 @@ static char *grab_blob(struct repository *r,
*size = fill_textconv(r, textconv, df, &blob);
free_filespec(df);
} else {
blob = repo_read_object_file(r, oid, &type, size);
blob = odb_read_object(r->objects, oid, &type, size);
if (!blob)
die(_("unable to read %s"), oid_to_hex(oid));
if (type != OBJ_BLOB)

View File

@ -13,7 +13,7 @@
#include "refs.h"
#include "hash-lookup.h"
#include "commit-graph.h"
#include "object-store.h"
#include "odb.h"
#include "oid-array.h"
#include "path.h"
#include "alloc.h"
@ -37,7 +37,7 @@ void git_test_write_commit_graph_or_die(void)
if (git_env_bool(GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS, 0))
flags = COMMIT_GRAPH_WRITE_BLOOM_FILTERS;

if (write_commit_graph_reachable(the_repository->objects->odb,
if (write_commit_graph_reachable(the_repository->objects->sources,
flags, NULL))
die("failed to write commit-graph under GIT_TEST_COMMIT_GRAPH");
}
@ -191,21 +191,21 @@ static int commit_gen_cmp(const void *va, const void *vb)
return 0;
}

char *get_commit_graph_filename(struct object_directory *obj_dir)
char *get_commit_graph_filename(struct odb_source *source)
{
return xstrfmt("%s/info/commit-graph", obj_dir->path);
return xstrfmt("%s/info/commit-graph", source->path);
}

static char *get_split_graph_filename(struct object_directory *odb,
static char *get_split_graph_filename(struct odb_source *source,
const char *oid_hex)
{
return xstrfmt("%s/info/commit-graphs/graph-%s.graph", odb->path,
return xstrfmt("%s/info/commit-graphs/graph-%s.graph", source->path,
oid_hex);
}

char *get_commit_graph_chain_filename(struct object_directory *odb)
char *get_commit_graph_chain_filename(struct odb_source *source)
{
return xstrfmt("%s/info/commit-graphs/commit-graph-chain", odb->path);
return xstrfmt("%s/info/commit-graphs/commit-graph-chain", source->path);
}

static struct commit_graph *alloc_commit_graph(void)
@ -250,7 +250,7 @@ int open_commit_graph(const char *graph_file, int *fd, struct stat *st)

struct commit_graph *load_commit_graph_one_fd_st(struct repository *r,
int fd, struct stat *st,
struct object_directory *odb)
struct odb_source *source)
{
void *graph_map;
size_t graph_size;
@ -269,7 +269,7 @@ struct commit_graph *load_commit_graph_one_fd_st(struct repository *r,
ret = parse_commit_graph(&r->settings, graph_map, graph_size);

if (ret)
ret->odb = odb;
ret->odb_source = source;
else
munmap(graph_map, graph_size);

@ -487,7 +487,7 @@ free_and_return:

static struct commit_graph *load_commit_graph_one(struct repository *r,
const char *graph_file,
struct object_directory *odb)
struct odb_source *source)
{

struct stat st;
@ -498,7 +498,7 @@ static struct commit_graph *load_commit_graph_one(struct repository *r,
if (!open_ok)
return NULL;

g = load_commit_graph_one_fd_st(r, fd, &st, odb);
g = load_commit_graph_one_fd_st(r, fd, &st, source);

if (g)
g->filename = xstrdup(graph_file);
@ -507,10 +507,10 @@ static struct commit_graph *load_commit_graph_one(struct repository *r,
}

static struct commit_graph *load_commit_graph_v1(struct repository *r,
struct object_directory *odb)
struct odb_source *source)
{
char *graph_name = get_commit_graph_filename(odb);
struct commit_graph *g = load_commit_graph_one(r, graph_name, odb);
char *graph_name = get_commit_graph_filename(source);
struct commit_graph *g = load_commit_graph_one(r, graph_name, source);
free(graph_name);

return g;
@ -649,10 +649,10 @@ struct commit_graph *load_commit_graph_chain_fd_st(struct repository *r,
count = st->st_size / (the_hash_algo->hexsz + 1);
CALLOC_ARRAY(oids, count);

prepare_alt_odb(r);
odb_prepare_alternates(r->objects);

for (i = 0; i < count; i++) {
struct object_directory *odb;
struct odb_source *source;

if (strbuf_getline_lf(&line, fp) == EOF)
break;
@ -665,9 +665,9 @@ struct commit_graph *load_commit_graph_chain_fd_st(struct repository *r,
}

valid = 0;
for (odb = r->objects->odb; odb; odb = odb->next) {
char *graph_name = get_split_graph_filename(odb, line.buf);
struct commit_graph *g = load_commit_graph_one(r, graph_name, odb);
for (source = r->objects->sources; source; source = source->next) {
char *graph_name = get_split_graph_filename(source, line.buf);
struct commit_graph *g = load_commit_graph_one(r, graph_name, source);

free(graph_name);

@ -701,9 +701,9 @@ struct commit_graph *load_commit_graph_chain_fd_st(struct repository *r,
}

static struct commit_graph *load_commit_graph_chain(struct repository *r,
struct object_directory *odb)
struct odb_source *source)
{
char *chain_file = get_commit_graph_chain_filename(odb);
char *chain_file = get_commit_graph_chain_filename(source);
struct stat st;
int fd;
struct commit_graph *g = NULL;
@ -719,24 +719,24 @@ static struct commit_graph *load_commit_graph_chain(struct repository *r,
}

struct commit_graph *read_commit_graph_one(struct repository *r,
struct object_directory *odb)
struct odb_source *source)
{
struct commit_graph *g = load_commit_graph_v1(r, odb);
struct commit_graph *g = load_commit_graph_v1(r, source);

if (!g)
g = load_commit_graph_chain(r, odb);
g = load_commit_graph_chain(r, source);

return g;
}

static void prepare_commit_graph_one(struct repository *r,
struct object_directory *odb)
struct odb_source *source)
{

if (r->objects->commit_graph)
return;

r->objects->commit_graph = read_commit_graph_one(r, odb);
r->objects->commit_graph = read_commit_graph_one(r, source);
}

/*
@ -747,7 +747,7 @@ static void prepare_commit_graph_one(struct repository *r,
*/
static int prepare_commit_graph(struct repository *r)
{
struct object_directory *odb;
struct odb_source *source;

/*
* Early return if there is no git dir or if the commit graph is
@ -778,11 +778,11 @@ static int prepare_commit_graph(struct repository *r)
if (!commit_graph_compatible(r))
return 0;

prepare_alt_odb(r);
for (odb = r->objects->odb;
!r->objects->commit_graph && odb;
odb = odb->next)
prepare_commit_graph_one(r, odb);
odb_prepare_alternates(r->objects);
for (source = r->objects->sources;
!r->objects->commit_graph && source;
source = source->next)
prepare_commit_graph_one(r, source);
return !!r->objects->commit_graph;
}

@ -829,7 +829,7 @@ struct bloom_filter_settings *get_bloom_filter_settings(struct repository *r)
return NULL;
}

void close_commit_graph(struct raw_object_store *o)
void close_commit_graph(struct object_database *o)
{
if (!o->commit_graph)
return;
@ -1040,7 +1040,7 @@ struct commit *lookup_commit_in_graph(struct repository *repo, const struct obje
return NULL;
if (!search_commit_pos_in_graph(id, repo->objects->commit_graph, &pos))
return NULL;
if (commit_graph_paranoia && !has_object(repo, id, 0))
if (commit_graph_paranoia && !odb_has_object(repo->objects, id, 0))
return NULL;

commit = lookup_commit(repo, id);
@ -1137,7 +1137,7 @@ struct packed_commit_list {

struct write_commit_graph_context {
struct repository *r;
struct object_directory *odb;
struct odb_source *odb_source;
char *graph_name;
struct oid_array oids;
struct packed_commit_list commits;
@ -1862,7 +1862,7 @@ static int add_ref_to_set(const char *refname UNUSED,

if (!peel_iterated_oid(the_repository, oid, &peeled))
oid = &peeled;
if (oid_object_info(the_repository, oid, NULL) == OBJ_COMMIT)
if (odb_read_object_info(the_repository->objects, oid, NULL) == OBJ_COMMIT)
oidset_insert(data->commits, oid);

display_progress(data->progress, oidset_size(data->commits));
@ -1870,7 +1870,7 @@ static int add_ref_to_set(const char *refname UNUSED,
return 0;
}

int write_commit_graph_reachable(struct object_directory *odb,
int write_commit_graph_reachable(struct odb_source *source,
enum commit_graph_write_flags flags,
const struct commit_graph_opts *opts)
{
@ -1890,7 +1890,7 @@ int write_commit_graph_reachable(struct object_directory *odb,

stop_progress(&data.progress);

result = write_commit_graph(odb, NULL, &commits,
result = write_commit_graph(source, NULL, &commits,
flags, opts);

oidset_clear(&commits);
@ -1906,7 +1906,7 @@ static int fill_oids_from_packs(struct write_commit_graph_context *ctx,
int dirlen;
int ret = 0;

strbuf_addf(&packname, "%s/pack/", ctx->odb->path);
strbuf_addf(&packname, "%s/pack/", ctx->odb_source->path);
dirlen = packname.len;
if (ctx->report_progress) {
strbuf_addf(&progress_title,
@ -2060,10 +2060,10 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)

strbuf_addf(&tmp_file,
"%s/info/commit-graphs/tmp_graph_XXXXXX",
ctx->odb->path);
ctx->odb_source->path);
ctx->graph_name = strbuf_detach(&tmp_file, NULL);
} else {
ctx->graph_name = get_commit_graph_filename(ctx->odb);
ctx->graph_name = get_commit_graph_filename(ctx->odb_source);
}

if (safe_create_leading_directories(the_repository, ctx->graph_name)) {
@ -2073,7 +2073,7 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)
}

if (ctx->split) {
char *lock_name = get_commit_graph_chain_filename(ctx->odb);
char *lock_name = get_commit_graph_chain_filename(ctx->odb_source);

hold_lock_file_for_update_mode(&lk, lock_name,
LOCK_DIE_ON_ERROR, 0444);
@ -2161,7 +2161,7 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)

if (ctx->split && ctx->base_graph_name && ctx->num_commit_graphs_after > 1) {
char *new_base_hash = xstrdup(oid_to_hex(&ctx->new_base_graph->oid));
char *new_base_name = get_split_graph_filename(ctx->new_base_graph->odb, new_base_hash);
char *new_base_name = get_split_graph_filename(ctx->new_base_graph->odb_source, new_base_hash);

free(ctx->commit_graph_filenames_after[ctx->num_commit_graphs_after - 2]);
free(ctx->commit_graph_hash_after[ctx->num_commit_graphs_after - 2]);
@ -2201,14 +2201,14 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)
}
}
} else {
char *graph_name = get_commit_graph_filename(ctx->odb);
char *graph_name = get_commit_graph_filename(ctx->odb_source);
unlink(graph_name);
free(graph_name);
}

free(ctx->commit_graph_hash_after[ctx->num_commit_graphs_after - 1]);
ctx->commit_graph_hash_after[ctx->num_commit_graphs_after - 1] = xstrdup(hash_to_hex(file_hash));
final_graph_name = get_split_graph_filename(ctx->odb,
final_graph_name = get_split_graph_filename(ctx->odb_source,
ctx->commit_graph_hash_after[ctx->num_commit_graphs_after - 1]);
free(ctx->commit_graph_filenames_after[ctx->num_commit_graphs_after - 1]);
ctx->commit_graph_filenames_after[ctx->num_commit_graphs_after - 1] = final_graph_name;
@ -2259,7 +2259,7 @@ static void split_graph_merge_strategy(struct write_commit_graph_context *ctx)
flags != COMMIT_GRAPH_SPLIT_REPLACE) {
while (g && (g->num_commits <= st_mult(size_mult, num_commits) ||
(max_commits && num_commits > max_commits))) {
if (g->odb != ctx->odb)
if (g->odb_source != ctx->odb_source)
break;

if (unsigned_add_overflows(num_commits, g->num_commits))
@ -2281,10 +2281,10 @@ static void split_graph_merge_strategy(struct write_commit_graph_context *ctx)
"should be 1 with --split=replace");

if (ctx->num_commit_graphs_after == 2) {
char *old_graph_name = get_commit_graph_filename(g->odb);
char *old_graph_name = get_commit_graph_filename(g->odb_source);

if (!strcmp(g->filename, old_graph_name) &&
g->odb != ctx->odb) {
g->odb_source != ctx->odb_source) {
ctx->num_commit_graphs_after = 1;
ctx->new_base_graph = NULL;
}
@ -2456,13 +2456,13 @@ static void expire_commit_graphs(struct write_commit_graph_context *ctx)
if (ctx->opts && ctx->opts->expire_time)
expire_time = ctx->opts->expire_time;
if (!ctx->split) {
char *chain_file_name = get_commit_graph_chain_filename(ctx->odb);
char *chain_file_name = get_commit_graph_chain_filename(ctx->odb_source);
unlink(chain_file_name);
free(chain_file_name);
ctx->num_commit_graphs_after = 0;
}

strbuf_addstr(&path, ctx->odb->path);
strbuf_addstr(&path, ctx->odb_source->path);
strbuf_addstr(&path, "/info/commit-graphs");
dir = opendir(path.buf);

@ -2504,7 +2504,7 @@ out:
strbuf_release(&path);
}

int write_commit_graph(struct object_directory *odb,
int write_commit_graph(struct odb_source *source,
const struct string_list *const pack_indexes,
struct oidset *commits,
enum commit_graph_write_flags flags,
@ -2513,7 +2513,7 @@ int write_commit_graph(struct object_directory *odb,
struct repository *r = the_repository;
struct write_commit_graph_context ctx = {
.r = r,
.odb = odb,
.odb_source = source,
.append = flags & COMMIT_GRAPH_WRITE_APPEND ? 1 : 0,
.report_progress = flags & COMMIT_GRAPH_WRITE_PROGRESS ? 1 : 0,
.split = flags & COMMIT_GRAPH_WRITE_SPLIT ? 1 : 0,

View File

@ -1,7 +1,7 @@
#ifndef COMMIT_GRAPH_H
#define COMMIT_GRAPH_H

#include "object-store.h"
#include "odb.h"
#include "oidset.h"

#define GIT_TEST_COMMIT_GRAPH "GIT_TEST_COMMIT_GRAPH"
@ -26,11 +26,11 @@ void git_test_write_commit_graph_or_die(void);
struct commit;
struct bloom_filter_settings;
struct repository;
struct raw_object_store;
struct object_database;
struct string_list;

char *get_commit_graph_filename(struct object_directory *odb);
char *get_commit_graph_chain_filename(struct object_directory *odb);
char *get_commit_graph_filename(struct odb_source *source);
char *get_commit_graph_chain_filename(struct odb_source *source);
int open_commit_graph(const char *graph_file, int *fd, struct stat *st);
int open_commit_graph_chain(const char *chain_file, int *fd, struct stat *st);

@ -89,7 +89,7 @@ struct commit_graph {
uint32_t num_commits;
struct object_id oid;
char *filename;
struct object_directory *odb;
struct odb_source *odb_source;

uint32_t num_commits_in_base;
unsigned int read_generation_data;
@ -115,12 +115,12 @@ struct commit_graph {

struct commit_graph *load_commit_graph_one_fd_st(struct repository *r,
int fd, struct stat *st,
struct object_directory *odb);
struct odb_source *source);
struct commit_graph *load_commit_graph_chain_fd_st(struct repository *r,
int fd, struct stat *st,
int *incomplete_chain);
struct commit_graph *read_commit_graph_one(struct repository *r,
struct object_directory *odb);
struct odb_source *source);

struct repo_settings;

@ -173,10 +173,10 @@ struct commit_graph_opts {
* is not compatible with the commit-graph feature, then the
* methods will return 0 without writing a commit-graph.
*/
int write_commit_graph_reachable(struct object_directory *odb,
int write_commit_graph_reachable(struct odb_source *source,
enum commit_graph_write_flags flags,
const struct commit_graph_opts *opts);
int write_commit_graph(struct object_directory *odb,
int write_commit_graph(struct odb_source *source,
const struct string_list *pack_indexes,
struct oidset *commits,
enum commit_graph_write_flags flags,
@ -186,7 +186,7 @@ int write_commit_graph(struct object_directory *odb,

int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags);

void close_commit_graph(struct raw_object_store *);
void close_commit_graph(struct object_database *);
void free_commit_graph(struct commit_graph *);

/*

View File

@ -9,7 +9,7 @@
#include "hex.h"
#include "repository.h"
#include "object-name.h"
#include "object-store.h"
#include "odb.h"
#include "utf8.h"
#include "diff.h"
#include "revision.h"
@ -374,7 +374,7 @@ const void *repo_get_commit_buffer(struct repository *r,
if (!ret) {
enum object_type type;
unsigned long size;
ret = repo_read_object_file(r, &commit->object.oid, &type, &size);
ret = odb_read_object(r->objects, &commit->object.oid, &type, &size);
if (!ret)
die("cannot read commit object %s",
oid_to_hex(&commit->object.oid));
@ -575,7 +575,7 @@ int repo_parse_commit_internal(struct repository *r,
if (commit_graph_paranoia == -1)
commit_graph_paranoia = git_env_bool(GIT_COMMIT_GRAPH_PARANOIA, 0);

if (commit_graph_paranoia && !has_object(r, &item->object.oid, 0)) {
if (commit_graph_paranoia && !odb_has_object(r->objects, &item->object.oid, 0)) {
unparse_commit(r, &item->object.oid);
return quiet_on_missing ? -1 :
error(_("commit %s exists in commit-graph but not in the object database"),
@ -585,7 +585,8 @@ int repo_parse_commit_internal(struct repository *r,
return 0;
}

if (oid_object_info_extended(r, &item->object.oid, &oi, flags) < 0)
if (odb_read_object_info_extended(r->objects, &item->object.oid,
&oi, flags) < 0)
return quiet_on_missing ? -1 :
error("Could not read %s",
oid_to_hex(&item->object.oid));
@ -1274,8 +1275,8 @@ static void handle_signed_tag(const struct commit *parent, struct commit_extra_h
desc = merge_remote_util(parent);
if (!desc || !desc->obj)
return;
buf = repo_read_object_file(the_repository, &desc->obj->oid, &type,
&size);
buf = odb_read_object(the_repository->objects, &desc->obj->oid,
&type, &size);
if (!buf || type != OBJ_TAG)
goto free_return;
if (!parse_signature(buf, size, &payload, &signature))
@ -1706,7 +1707,7 @@ int commit_tree_extended(const char *msg, size_t msg_len,
/* Not having i18n.commitencoding is the same as having utf-8 */
encoding_is_utf8 = is_encoding_utf8(git_commit_encoding);

assert_oid_type(tree, OBJ_TREE);
odb_assert_oid_type(the_repository->objects, tree, OBJ_TREE);

if (memchr(msg, '\0', msg_len))
return error("a NUL byte in commit log message not allowed.");

View File

@ -31,7 +31,7 @@
#include "hashmap.h"
#include "string-list.h"
#include "object-name.h"
#include "object-store.h"
#include "odb.h"
#include "pager.h"
#include "path.h"
#include "utf8.h"
@ -1937,7 +1937,7 @@ int git_config_from_blob_oid(config_fn_t fn,
unsigned long size;
int ret;

buf = repo_read_object_file(repo, oid, &type, &size);
buf = odb_read_object(repo->objects, oid, &type, &size);
if (!buf)
return error(_("unable to load config blob object '%s'"), name);
if (type != OBJ_BLOB) {

View File

@ -3,7 +3,7 @@
#include "git-compat-util.h"
#include "gettext.h"
#include "hex.h"
#include "object-store.h"
#include "odb.h"
#include "run-command.h"
#include "sigchain.h"
#include "connected.h"

View File

@ -77,7 +77,7 @@
|
- diff_setup
+ repo_diff_setup
// object-store.h
// odb.h
|
- read_object_file
+ repo_read_object_file

View File

@ -7,7 +7,7 @@
#include "gettext.h"
#include "hex.h"
#include "strvec.h"
#include "object-store.h"
#include "odb.h"
#include "packfile.h"
#include "parse-options.h"
#include "repository.h"
@ -59,13 +59,13 @@ static void dir_file_stats_objects(const char *full_path,
(uintmax_t)st.st_size);
}

static int dir_file_stats(struct object_directory *object_dir, void *data)
static int dir_file_stats(struct odb_source *source, void *data)
{
struct strbuf *buf = data;

strbuf_addf(buf, "Contents of %s:\n", object_dir->path);
strbuf_addf(buf, "Contents of %s:\n", source->path);

for_each_file_in_pack_dir(object_dir->path, dir_file_stats_objects,
for_each_file_in_pack_dir(source->path, dir_file_stats_objects,
data);

return 0;
@ -228,8 +228,8 @@ int create_diagnostics_archive(struct repository *r,

strbuf_reset(&buf);
strbuf_addstr(&buf, "--add-virtual-file=packs-local.txt:");
dir_file_stats(r->objects->odb, &buf);
foreach_alt_odb(dir_file_stats, &buf);
dir_file_stats(r->objects->sources, &buf);
odb_for_each_alternate(r->objects, dir_file_stats, &buf);
strvec_push(&archiver_args, buf.buf);

strbuf_reset(&buf);

10
diff.c
View File

@ -23,7 +23,7 @@
#include "color.h"
#include "run-command.h"
#include "utf8.h"
#include "object-store.h"
#include "odb.h"
#include "userdiff.h"
#include "submodule.h"
#include "hashmap.h"
@ -4230,13 +4230,13 @@ int diff_populate_filespec(struct repository *r,
info.contentp = &s->data;

if (options && options->missing_object_cb) {
if (!oid_object_info_extended(r, &s->oid, &info,
if (!odb_read_object_info_extended(r->objects, &s->oid, &info,
OBJECT_INFO_LOOKUP_REPLACE |
OBJECT_INFO_SKIP_FETCH_OBJECT))
goto object_read;
options->missing_object_cb(options->missing_object_data);
}
if (oid_object_info_extended(r, &s->oid, &info,
if (odb_read_object_info_extended(r->objects, &s->oid, &info,
OBJECT_INFO_LOOKUP_REPLACE))
die("unable to read %s", oid_to_hex(&s->oid));

@ -4252,7 +4252,7 @@ object_read:
}
if (!info.contentp) {
info.contentp = &s->data;
if (oid_object_info_extended(r, &s->oid, &info,
if (odb_read_object_info_extended(r->objects, &s->oid, &info,
OBJECT_INFO_LOOKUP_REPLACE))
die("unable to read %s", oid_to_hex(&s->oid));
}
@ -7019,7 +7019,7 @@ void diff_add_if_missing(struct repository *r,
{
if (filespec && filespec->oid_valid &&
!S_ISGITLINK(filespec->mode) &&
oid_object_info_extended(r, &filespec->oid, NULL,
odb_read_object_info_extended(r->objects, &filespec->oid, NULL,
OBJECT_INFO_FOR_PREFETCH))
oid_array_append(to_fetch, &filespec->oid);
}

2
dir.c
View File

@ -302,7 +302,7 @@ static int do_read_blob(const struct object_id *oid, struct oid_stat *oid_stat,
*size_out = 0;
*data_out = NULL;

data = repo_read_object_file(the_repository, oid, &type, &sz);
data = odb_read_object(the_repository->objects, oid, &type, &sz);
if (!data || type != OBJ_BLOB) {
free(data);
return -1;

View File

@ -1,7 +1,7 @@
#define USE_THE_REPOSITORY_VARIABLE

#include "git-compat-util.h"
#include "object-store.h"
#include "odb.h"
#include "dir.h"
#include "environment.h"
#include "gettext.h"
@ -93,7 +93,7 @@ void *read_blob_entry(const struct cache_entry *ce, size_t *size)
{
enum object_type type;
unsigned long ul;
void *blob_data = repo_read_object_file(the_repository, &ce->oid,
void *blob_data = odb_read_object(the_repository->objects, &ce->oid,
&type, &ul);

*size = ul;

View File

@ -24,7 +24,7 @@
#include "oid-array.h"
#include "oidset.h"
#include "packfile.h"
#include "object-store.h"
#include "odb.h"
#include "path.h"
#include "connected.h"
#include "fetch-negotiator.h"
@ -115,7 +115,8 @@ static void for_each_cached_alternate(struct fetch_negotiator *negotiator,
size_t i;

if (!initialized) {
for_each_alternate_ref(cache_one_alternate, &cache);
odb_for_each_alternate_ref(the_repository->objects,
cache_one_alternate, &cache);
initialized = 1;
}

@ -141,14 +142,14 @@ static struct commit *deref_without_lazy_fetch(const struct object_id *oid,
commit = lookup_commit_in_graph(the_repository, oid);
if (commit) {
if (mark_tags_complete_and_check_obj_db) {
if (!has_object(the_repository, oid, 0))
if (!odb_has_object(the_repository->objects, oid, 0))
die_in_commit_graph_only(oid);
}
return commit;
}

while (1) {
if (oid_object_info_extended(the_repository, oid, &info,
if (odb_read_object_info_extended(the_repository->objects, oid, &info,
OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK))
return NULL;
if (type == OBJ_TAG) {
@ -769,7 +770,7 @@ static void mark_complete_and_common_ref(struct fetch_negotiator *negotiator,
if (!commit) {
struct object *o;

if (!has_object(the_repository, &ref->old_oid, 0))
if (!odb_has_object(the_repository->objects, &ref->old_oid, 0))
continue;
o = parse_object(the_repository, &ref->old_oid);
if (!o || o->type != OBJ_COMMIT)
@ -1983,7 +1984,7 @@ static void update_shallow(struct fetch_pack_args *args,
struct oid_array extra = OID_ARRAY_INIT;
struct object_id *oid = si->shallow->oid;
for (i = 0; i < si->shallow->nr; i++)
if (has_object(the_repository, &oid[i],
if (odb_has_object(the_repository->objects, &oid[i],
HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
oid_array_append(&extra, &oid[i]);
if (extra.nr) {

View File

@ -6,7 +6,7 @@
#include "environment.h"
#include "refs.h"
#include "object-name.h"
#include "object-store.h"
#include "odb.h"
#include "diff.h"
#include "diff-merges.h"
#include "hex.h"
@ -526,8 +526,8 @@ static void fmt_merge_msg_sigs(struct strbuf *out)
struct object_id *oid = origins.items[i].util;
enum object_type type;
unsigned long size;
char *buf = repo_read_object_file(the_repository, oid, &type,
&size);
char *buf = odb_read_object(the_repository->objects, oid,
&type, &size);
char *origbuf = buf;
unsigned long len = size;
struct signature_check sigc = { NULL };

4
fsck.c
View File

@ -4,7 +4,7 @@
#include "date.h"
#include "dir.h"
#include "hex.h"
#include "object-store.h"
#include "odb.h"
#include "path.h"
#include "repository.h"
#include "object.h"
@ -1293,7 +1293,7 @@ static int fsck_blobs(struct oidset *blobs_found, struct oidset *blobs_done,
if (oidset_contains(blobs_done, oid))
continue;

buf = repo_read_object_file(the_repository, oid, &type, &size);
buf = odb_read_object(the_repository->objects, oid, &type, &size);
if (!buf) {
if (is_promisor_object(the_repository, oid))
continue;

6
grep.c
View File

@ -5,7 +5,7 @@
#include "gettext.h"
#include "grep.h"
#include "hex.h"
#include "object-store.h"
#include "odb.h"
#include "pretty.h"
#include "userdiff.h"
#include "xdiff-interface.h"
@ -1931,8 +1931,8 @@ static int grep_source_load_oid(struct grep_source *gs)
{
enum object_type type;

gs->buf = repo_read_object_file(gs->repo, gs->identifier, &type,
&gs->size);
gs->buf = odb_read_object(gs->repo->objects, gs->identifier,
&type, &gs->size);
if (!gs->buf)
return error(_("'%s': unable to read %s"),
gs->name,

View File

@ -18,7 +18,7 @@
#include "url.h"
#include "strvec.h"
#include "packfile.h"
#include "object-store.h"
#include "odb.h"
#include "protocol.h"
#include "date.h"
#include "write-or-die.h"

View File

@ -20,7 +20,7 @@
#include "url.h"
#include "packfile.h"
#include "object-file.h"
#include "object-store.h"
#include "odb.h"
#include "commit-reach.h"

#ifdef EXPAT_NEEDS_XMLPARSE_H
@ -369,7 +369,7 @@ static void start_put(struct transfer_request *request)
ssize_t size;
git_zstream stream;

unpacked = repo_read_object_file(the_repository, &request->obj->oid,
unpacked = odb_read_object(the_repository->objects, &request->obj->oid,
&type, &len);
hdrlen = format_object_header(hdr, sizeof(hdr), type, len);

@ -1447,7 +1447,7 @@ static void one_remote_ref(const char *refname)
* may be required for updating server info later.
*/
if (repo->can_update_info_refs &&
!has_object(the_repository, &ref->old_oid,
!odb_has_object(the_repository->objects, &ref->old_oid,
HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {
obj = lookup_unknown_object(the_repository, &ref->old_oid);
fprintf(stderr, " fetch %s for %s\n",
@ -1653,14 +1653,16 @@ static int delete_remote_branch(const char *pattern, int force)
return error("Remote HEAD symrefs too deep");
if (is_null_oid(&head_oid))
return error("Unable to resolve remote HEAD");
if (!has_object(the_repository, &head_oid, HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
if (!odb_has_object(the_repository->objects, &head_oid,
HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
return error("Remote HEAD resolves to object %s\nwhich does not exist locally, perhaps you need to fetch?", oid_to_hex(&head_oid));

/* Remote branch must resolve to a known object */
if (is_null_oid(&remote_ref->old_oid))
return error("Unable to resolve remote branch %s",
remote_ref->name);
if (!has_object(the_repository, &remote_ref->old_oid, HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
if (!odb_has_object(the_repository->objects, &remote_ref->old_oid,
HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
return error("Remote branch %s resolves to object %s\nwhich does not exist locally, perhaps you need to fetch?", remote_ref->name, oid_to_hex(&remote_ref->old_oid));

/* Remote branch must be an ancestor of remote HEAD */
@ -1881,7 +1883,7 @@ int cmd_main(int argc, const char **argv)
if (!force_all &&
!is_null_oid(&ref->old_oid) &&
!ref->force) {
if (!has_object(the_repository, &ref->old_oid,
if (!odb_has_object(the_repository->objects, &ref->old_oid,
HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) ||
!ref_newer(&ref->peer_ref->new_oid,
&ref->old_oid)) {

View File

@ -10,7 +10,7 @@
#include "transport.h"
#include "packfile.h"
#include "object-file.h"
#include "object-store.h"
#include "odb.h"

struct alt_base {
char *base;
@ -138,7 +138,7 @@ static int fill_active_slot(void *data UNUSED)
list_for_each_safe(pos, tmp, head) {
obj_req = list_entry(pos, struct object_request, node);
if (obj_req->state == WAITING) {
if (has_object(the_repository, &obj_req->oid,
if (odb_has_object(the_repository->objects, &obj_req->oid,
HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
obj_req->state = COMPLETE;
else {
@ -497,7 +497,7 @@ static int fetch_object(struct walker *walker, const struct object_id *oid)
if (!obj_req)
return error("Couldn't find request for %s in the queue", hex);

if (has_object(the_repository, &obj_req->oid,
if (odb_has_object(the_repository->objects, &obj_req->oid,
HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {
if (obj_req->req)
abort_http_object_request(&obj_req->req);
@ -543,7 +543,7 @@ static int fetch_object(struct walker *walker, const struct object_id *oid)
ret = error("File %s has bad hash", hex);
} else if (req->rename < 0) {
struct strbuf buf = STRBUF_INIT;
odb_loose_path(the_repository->objects->odb, &buf, &req->oid);
odb_loose_path(the_repository->objects->sources, &buf, &req->oid);
ret = error("unable to write sha1 filename %s", buf.buf);
strbuf_release(&buf);
}

6
http.c
View File

@ -19,7 +19,7 @@
#include "packfile.h"
#include "string-list.h"
#include "object-file.h"
#include "object-store.h"
#include "odb.h"
#include "tempfile.h"

static struct trace_key trace_curl = TRACE_KEY_INIT(CURL);
@ -2662,7 +2662,7 @@ struct http_object_request *new_http_object_request(const char *base_url,
oidcpy(&freq->oid, oid);
freq->localfile = -1;

odb_loose_path(the_repository->objects->odb, &filename, oid);
odb_loose_path(the_repository->objects->sources, &filename, oid);
strbuf_addf(&freq->tmpfile, "%s.temp", filename.buf);

strbuf_addf(&prevfile, "%s.prev", filename.buf);
@ -2814,7 +2814,7 @@ int finish_http_object_request(struct http_object_request *freq)
unlink_or_warn(freq->tmpfile.buf);
return -1;
}
odb_loose_path(the_repository->objects->odb, &filename, &freq->oid);
odb_loose_path(the_repository->objects->sources, &filename, &freq->oid);
freq->rename = finalize_object_file(freq->tmpfile.buf, filename.buf);
strbuf_release(&filename);


View File

@ -12,7 +12,7 @@
#include "oidmap.h"
#include "oidset.h"
#include "object-name.h"
#include "object-store.h"
#include "odb.h"

/* Remember to update object flag allocation in object.h */
/*
@ -310,7 +310,7 @@ static enum list_objects_filter_result filter_blobs_limit(
assert(obj->type == OBJ_BLOB);
assert((obj->flags & SEEN) == 0);

t = oid_object_info(r, &obj->oid, &object_length);
t = odb_read_object_info(r->objects, &obj->oid, &object_length);
if (t != OBJ_BLOB) { /* probably OBJ_NONE */
/*
* We DO NOT have the blob locally, so we cannot

View File

@ -14,7 +14,7 @@
#include "list-objects-filter.h"
#include "list-objects-filter-options.h"
#include "packfile.h"
#include "object-store.h"
#include "odb.h"
#include "trace.h"
#include "environment.h"

@ -74,7 +74,7 @@ static void process_blob(struct traversal_context *ctx,
* of missing objects.
*/
if (ctx->revs->exclude_promisor_objects &&
!has_object(the_repository, &obj->oid,
!odb_has_object(the_repository->objects, &obj->oid,
HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) &&
is_promisor_object(ctx->revs->repo, &obj->oid))
return;

View File

@ -176,7 +176,7 @@ static int add_ref_decoration(const char *refname, const char *referent UNUSED,
return 0;
}

objtype = oid_object_info(the_repository, oid, NULL);
objtype = odb_read_object_info(the_repository->objects, oid, NULL);
if (objtype < 0)
return 0;
obj = lookup_object_by_type(the_repository, oid, objtype);

46
loose.c
View File

@ -1,7 +1,7 @@
#include "git-compat-util.h"
#include "hash.h"
#include "path.h"
#include "object-store.h"
#include "odb.h"
#include "hex.h"
#include "repository.h"
#include "wrapper.h"
@ -44,36 +44,36 @@ static int insert_oid_pair(kh_oid_map_t *map, const struct object_id *key, const
return 1;
}

static int insert_loose_map(struct object_directory *odb,
static int insert_loose_map(struct odb_source *source,
const struct object_id *oid,
const struct object_id *compat_oid)
{
struct loose_object_map *map = odb->loose_map;
struct loose_object_map *map = source->loose_map;
int inserted = 0;

inserted |= insert_oid_pair(map->to_compat, oid, compat_oid);
inserted |= insert_oid_pair(map->to_storage, compat_oid, oid);
if (inserted)
oidtree_insert(odb->loose_objects_cache, compat_oid);
oidtree_insert(source->loose_objects_cache, compat_oid);

return inserted;
}

static int load_one_loose_object_map(struct repository *repo, struct object_directory *dir)
static int load_one_loose_object_map(struct repository *repo, struct odb_source *source)
{
struct strbuf buf = STRBUF_INIT, path = STRBUF_INIT;
FILE *fp;

if (!dir->loose_map)
loose_object_map_init(&dir->loose_map);
if (!dir->loose_objects_cache) {
ALLOC_ARRAY(dir->loose_objects_cache, 1);
oidtree_init(dir->loose_objects_cache);
if (!source->loose_map)
loose_object_map_init(&source->loose_map);
if (!source->loose_objects_cache) {
ALLOC_ARRAY(source->loose_objects_cache, 1);
oidtree_init(source->loose_objects_cache);
}

insert_loose_map(dir, repo->hash_algo->empty_tree, repo->compat_hash_algo->empty_tree);
insert_loose_map(dir, repo->hash_algo->empty_blob, repo->compat_hash_algo->empty_blob);
insert_loose_map(dir, repo->hash_algo->null_oid, repo->compat_hash_algo->null_oid);
insert_loose_map(source, repo->hash_algo->empty_tree, repo->compat_hash_algo->empty_tree);
insert_loose_map(source, repo->hash_algo->empty_blob, repo->compat_hash_algo->empty_blob);
insert_loose_map(source, repo->hash_algo->null_oid, repo->compat_hash_algo->null_oid);

repo_common_path_replace(repo, &path, "objects/loose-object-idx");
fp = fopen(path.buf, "rb");
@ -93,7 +93,7 @@ static int load_one_loose_object_map(struct repository *repo, struct object_dire
parse_oid_hex_algop(p, &compat_oid, &p, repo->compat_hash_algo) ||
p != buf.buf + buf.len)
goto err;
insert_loose_map(dir, &oid, &compat_oid);
insert_loose_map(source, &oid, &compat_oid);
}

strbuf_release(&buf);
@ -107,15 +107,15 @@ err:

int repo_read_loose_object_map(struct repository *repo)
{
struct object_directory *dir;
struct odb_source *source;

if (!should_use_loose_object_map(repo))
return 0;

prepare_alt_odb(repo);
odb_prepare_alternates(repo->objects);

for (dir = repo->objects->odb; dir; dir = dir->next) {
if (load_one_loose_object_map(repo, dir) < 0) {
for (source = repo->objects->sources; source; source = source->next) {
if (load_one_loose_object_map(repo, source) < 0) {
return -1;
}
}
@ -124,7 +124,7 @@ int repo_read_loose_object_map(struct repository *repo)

int repo_write_loose_object_map(struct repository *repo)
{
kh_oid_map_t *map = repo->objects->odb->loose_map->to_compat;
kh_oid_map_t *map = repo->objects->sources->loose_map->to_compat;
struct lock_file lock;
int fd;
khiter_t iter;
@ -212,7 +212,7 @@ int repo_add_loose_object_map(struct repository *repo, const struct object_id *o
if (!should_use_loose_object_map(repo))
return 0;

inserted = insert_loose_map(repo->objects->odb, oid, compat_oid);
inserted = insert_loose_map(repo->objects->sources, oid, compat_oid);
if (inserted)
return write_one_object(repo, oid, compat_oid);
return 0;
@ -223,12 +223,12 @@ int repo_loose_object_map_oid(struct repository *repo,
const struct git_hash_algo *to,
struct object_id *dest)
{
struct object_directory *dir;
struct odb_source *source;
kh_oid_map_t *map;
khiter_t pos;

for (dir = repo->objects->odb; dir; dir = dir->next) {
struct loose_object_map *loose_map = dir->loose_map;
for (source = repo->objects->sources; source; source = source->next) {
struct loose_object_map *loose_map = source->loose_map;
if (!loose_map)
continue;
map = (to == repo->compat_hash_algo) ?

View File

@ -6,7 +6,7 @@
#include "string-list.h"
#include "mailmap.h"
#include "object-name.h"
#include "object-store.h"
#include "odb.h"
#include "setup.h"

char *git_mailmap_file;
@ -196,7 +196,7 @@ int read_mailmap_blob(struct string_list *map, const char *name)
if (repo_get_oid(the_repository, name, &oid) < 0)
return 0;

buf = repo_read_object_file(the_repository, &oid, &type, &size);
buf = odb_read_object(the_repository->objects, &oid, &type, &size);
if (!buf)
return error("unable to read mailmap object at %s", name);
if (type != OBJ_BLOB) {

View File

@ -7,7 +7,7 @@
#include "tree.h"
#include "tree-walk.h"
#include "object-file.h"
#include "object-store.h"
#include "odb.h"
#include "repository.h"

static int score_missing(unsigned mode)
@ -63,7 +63,7 @@ static void *fill_tree_desc_strict(struct repository *r,
enum object_type type;
unsigned long size;

buffer = repo_read_object_file(r, hash, &type, &size);
buffer = odb_read_object(r->objects, hash, &type, &size);
if (!buffer)
die("unable to read tree (%s)", oid_to_hex(hash));
if (type != OBJ_TREE)
@ -199,7 +199,7 @@ static int splice_tree(struct repository *r,
if (*subpath)
subpath++;

buf = repo_read_object_file(r, oid1, &type, &sz);
buf = odb_read_object(r->objects, oid1, &type, &sz);
if (!buf)
die("cannot read tree %s", oid_to_hex(oid1));
init_tree_desc(&desc, oid1, buf, sz);

View File

@ -4,7 +4,7 @@
#include "merge-ll.h"
#include "blob.h"
#include "merge-blobs.h"
#include "object-store.h"
#include "odb.h"

static int fill_mmfile_blob(mmfile_t *f, struct blob *obj)
{
@ -12,8 +12,8 @@ static int fill_mmfile_blob(mmfile_t *f, struct blob *obj)
unsigned long size;
enum object_type type;

buf = repo_read_object_file(the_repository, &obj->object.oid, &type,
&size);
buf = odb_read_object(the_repository->objects, &obj->object.oid,
&type, &size);
if (!buf)
return -1;
if (type != OBJ_BLOB) {
@ -79,7 +79,7 @@ void *merge_blobs(struct index_state *istate, const char *path,
return NULL;
if (!our)
our = their;
return repo_read_object_file(the_repository, &our->object.oid,
return odb_read_object(the_repository->objects, &our->object.oid,
&type, size);
}


View File

@ -39,7 +39,7 @@
#include "mem-pool.h"
#include "object-file.h"
#include "object-name.h"
#include "object-store.h"
#include "odb.h"
#include "oid-array.h"
#include "path.h"
#include "promisor-remote.h"
@ -3629,7 +3629,7 @@ static int read_oid_strbuf(struct merge_options *opt,
void *buf;
enum object_type type;
unsigned long size;
buf = repo_read_object_file(the_repository, oid, &type, &size);
buf = odb_read_object(the_repository->objects, oid, &type, &size);
if (!buf) {
path_msg(opt, ERROR_OBJECT_READ_FAILED, 0,
path, NULL, NULL, NULL,
@ -4385,7 +4385,7 @@ static void prefetch_for_content_merges(struct merge_options *opt,

if ((ci->filemask & side_mask) &&
S_ISREG(vi->mode) &&
oid_object_info_extended(opt->repo, &vi->oid, NULL,
odb_read_object_info_extended(opt->repo->objects, &vi->oid, NULL,
OBJECT_INFO_FOR_PREFETCH))
oid_array_append(&to_fetch, &vi->oid);
}

View File

@ -396,8 +396,8 @@ libgit_sources = [
'object-file-convert.c',
'object-file.c',
'object-name.c',
'object-store.c',
'object.c',
'odb.c',
'oid-array.c',
'oidmap.c',
'oidset.c',

View File

@ -922,7 +922,7 @@ static struct multi_pack_index *lookup_multi_pack_index(struct repository *r,
struct strbuf cur_path_real = STRBUF_INIT;

/* Ensure the given object_dir is local, or a known alternate. */
find_odb(r, obj_dir_real);
odb_find_source(r->objects, obj_dir_real);

for (cur = get_multi_pack_index(r); cur; cur = cur->next) {
strbuf_realpath(&cur_path_real, cur->object_dir, 1);

6
midx.c
View File

@ -832,7 +832,7 @@ void clear_midx_file(struct repository *r)
{
struct strbuf midx = STRBUF_INIT;

get_midx_filename(r->hash_algo, &midx, r->objects->odb->path);
get_midx_filename(r->hash_algo, &midx, r->objects->sources->path);

if (r->objects && r->objects->multi_pack_index) {
close_midx(r->objects->multi_pack_index);
@ -842,8 +842,8 @@ void clear_midx_file(struct repository *r)
if (remove_path(midx.buf))
die(_("failed to clear multi-pack-index at %s"), midx.buf);

clear_midx_files_ext(r->objects->odb->path, MIDX_EXT_BITMAP, NULL);
clear_midx_files_ext(r->objects->odb->path, MIDX_EXT_REV, NULL);
clear_midx_files_ext(r->objects->sources->path, MIDX_EXT_BITMAP, NULL);
clear_midx_files_ext(r->objects->sources->path, MIDX_EXT_REV, NULL);

strbuf_release(&midx);
}

View File

@ -3,7 +3,7 @@
#include "git-compat-util.h"
#include "notes-cache.h"
#include "object-file.h"
#include "object-store.h"
#include "odb.h"
#include "pretty.h"
#include "repository.h"
#include "commit.h"
@ -87,7 +87,7 @@ char *notes_cache_get(struct notes_cache *c, struct object_id *key_oid,
value_oid = get_note(&c->tree, key_oid);
if (!value_oid)
return NULL;
value = repo_read_object_file(the_repository, value_oid, &type, &size);
value = odb_read_object(the_repository->objects, value_oid, &type, &size);

*outsize = size;
return value;

View File

@ -8,7 +8,7 @@
#include "refs.h"
#include "object-file.h"
#include "object-name.h"
#include "object-store.h"
#include "odb.h"
#include "path.h"
#include "repository.h"
#include "diff.h"
@ -340,7 +340,7 @@ static void write_note_to_worktree(const struct object_id *obj,
{
enum object_type type;
unsigned long size;
void *buf = repo_read_object_file(the_repository, note, &type, &size);
void *buf = odb_read_object(the_repository->objects, note, &type, &size);

if (!buf)
die("cannot read note %s for object %s",

13
notes.c
View File

@ -8,7 +8,7 @@
#include "notes.h"
#include "object-file.h"
#include "object-name.h"
#include "object-store.h"
#include "odb.h"
#include "utf8.h"
#include "strbuf.h"
#include "tree-walk.h"
@ -794,7 +794,7 @@ static int prune_notes_helper(const struct object_id *object_oid,
struct note_delete_list **l = (struct note_delete_list **) cb_data;
struct note_delete_list *n;

if (has_object(the_repository, object_oid,
if (odb_has_object(the_repository->objects, object_oid,
HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
return 0; /* nothing to do for this note */

@ -816,14 +816,14 @@ int combine_notes_concatenate(struct object_id *cur_oid,

/* read in both note blob objects */
if (!is_null_oid(new_oid))
new_msg = repo_read_object_file(the_repository, new_oid,
new_msg = odb_read_object(the_repository->objects, new_oid,
&new_type, &new_len);
if (!new_msg || !new_len || new_type != OBJ_BLOB) {
free(new_msg);
return 0;
}
if (!is_null_oid(cur_oid))
cur_msg = repo_read_object_file(the_repository, cur_oid,
cur_msg = odb_read_object(the_repository->objects, cur_oid,
&cur_type, &cur_len);
if (!cur_msg || !cur_len || cur_type != OBJ_BLOB) {
free(cur_msg);
@ -880,7 +880,7 @@ static int string_list_add_note_lines(struct string_list *list,
return 0;

/* read_sha1_file NUL-terminates */
data = repo_read_object_file(the_repository, oid, &t, &len);
data = odb_read_object(the_repository->objects, oid, &t, &len);
if (t != OBJ_BLOB || !data || !len) {
free(data);
return t != OBJ_BLOB || !data;
@ -1290,7 +1290,8 @@ static void format_note(struct notes_tree *t, const struct object_id *object_oid
if (!oid)
return;

if (!(msg = repo_read_object_file(the_repository, oid, &type, &msglen)) || type != OBJ_BLOB) {
if (!(msg = odb_read_object(the_repository->objects, oid, &type, &msglen)) ||
type != OBJ_BLOB) {
free(msg);
return;
}

View File

@ -21,7 +21,7 @@
#include "loose.h"
#include "object-file-convert.h"
#include "object-file.h"
#include "object-store.h"
#include "odb.h"
#include "oidtree.h"
#include "pack.h"
#include "packfile.h"
@ -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))
odb_prepare_alternates(the_repository->objects);
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);
odb_prepare_alternates(r->objects);
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);
odb_prepare_alternates(r->objects);
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))
odb_prepare_alternates(r->objects);
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);
@ -1108,7 +1108,7 @@ int force_object_loose(const struct object_id *oid, time_t mtime)
oi.typep = &type;
oi.sizep = &len;
oi.contentp = &buf;
if (oid_object_info_extended(the_repository, oid, &oi, 0))
if (odb_read_object_info_extended(the_repository->objects, oid, &oi, 0))
return error(_("cannot read object for %s"), oid_to_hex(oid));
if (compat) {
if (repo_oid_to_algop(repo, oid, compat, &compat_oid))
@ -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,
odb_prepare_alternates(the_repository->objects);
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,
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,

View File

@ -3,12 +3,12 @@

#include "git-zlib.h"
#include "object.h"
#include "object-store.h"
#include "odb.h"

struct index_state;

/*
* Set this to 0 to prevent oid_object_info_extended() from fetching missing
* Set this to 0 to prevent odb_read_object_info_extended() from fetching missing
* blobs. This has a difference only if extensions.partialClone is set.
*
* Its default value is 1.
@ -24,23 +24,23 @@ enum {
int index_fd(struct index_state *istate, struct object_id *oid, int fd, struct stat *st, enum object_type type, const char *path, unsigned flags);
int index_path(struct index_state *istate, struct object_id *oid, const char *path, struct stat *st, unsigned flags);

struct object_directory;
struct odb_source;

/*
* Populate and return the loose object cache array corresponding to the
* given object ID.
*/
struct oidtree *odb_loose_cache(struct object_directory *odb,
struct oidtree *odb_loose_cache(struct odb_source *source,
const struct object_id *oid);

/* Empty the loose object cache for the specified object directory. */
void odb_clear_loose_cache(struct object_directory *odb);
void odb_clear_loose_cache(struct odb_source *source);

/*
* Put in `buf` the name of the file in the local object database that
* would be used to store a loose object with the specified 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);


View File

@ -112,10 +112,10 @@ static enum cb_next match_prefix(const struct object_id *oid, void *arg)

static void find_short_object_filename(struct disambiguate_state *ds)
{
struct object_directory *odb;
struct odb_source *source;

for (odb = ds->repo->objects->odb; odb && !ds->ambiguous; odb = odb->next)
oidtree_each(odb_loose_cache(odb, &ds->bin_pfx),
for (source = ds->repo->objects->sources; source && !ds->ambiguous; source = source->next)
oidtree_each(odb_loose_cache(source, &ds->bin_pfx),
&ds->bin_pfx, ds->len, match_prefix, ds);
}

@ -251,7 +251,7 @@ static int disambiguate_commit_only(struct repository *r,
const struct object_id *oid,
void *cb_data UNUSED)
{
int kind = oid_object_info(r, oid, NULL);
int kind = odb_read_object_info(r->objects, oid, NULL);
return kind == OBJ_COMMIT;
}

@ -262,7 +262,7 @@ static int disambiguate_committish_only(struct repository *r,
struct object *obj;
int kind;

kind = oid_object_info(r, oid, NULL);
kind = odb_read_object_info(r->objects, oid, NULL);
if (kind == OBJ_COMMIT)
return 1;
if (kind != OBJ_TAG)
@ -279,7 +279,7 @@ static int disambiguate_tree_only(struct repository *r,
const struct object_id *oid,
void *cb_data UNUSED)
{
int kind = oid_object_info(r, oid, NULL);
int kind = odb_read_object_info(r->objects, oid, NULL);
return kind == OBJ_TREE;
}

@ -290,7 +290,7 @@ static int disambiguate_treeish_only(struct repository *r,
struct object *obj;
int kind;

kind = oid_object_info(r, oid, NULL);
kind = odb_read_object_info(r->objects, oid, NULL);
if (kind == OBJ_TREE || kind == OBJ_COMMIT)
return 1;
if (kind != OBJ_TAG)
@ -307,7 +307,7 @@ static int disambiguate_blob_only(struct repository *r,
const struct object_id *oid,
void *cb_data UNUSED)
{
int kind = oid_object_info(r, oid, NULL);
int kind = odb_read_object_info(r->objects, oid, NULL);
return kind == OBJ_BLOB;
}

@ -376,7 +376,7 @@ static int init_object_disambiguation(struct repository *r,
ds->hex_pfx[len] = '\0';
ds->repo = r;
ds->bin_pfx.algo = algo ? hash_algo_by_ptr(algo) : GIT_HASH_UNKNOWN;
prepare_alt_odb(r);
odb_prepare_alternates(r->objects);
return 0;
}

@ -399,7 +399,7 @@ static int show_ambiguous_object(const struct object_id *oid, void *data)
return 0;

hash = repo_find_unique_abbrev(ds->repo, oid, DEFAULT_ABBREV);
type = oid_object_info(ds->repo, oid, NULL);
type = odb_read_object_info(ds->repo->objects, oid, NULL);

if (type < 0) {
/*
@ -514,8 +514,8 @@ static int sort_ambiguous(const void *va, const void *vb, void *ctx)
{
struct repository *sort_ambiguous_repo = ctx;
const struct object_id *a = va, *b = vb;
int a_type = oid_object_info(sort_ambiguous_repo, a, NULL);
int b_type = oid_object_info(sort_ambiguous_repo, b, NULL);
int a_type = odb_read_object_info(sort_ambiguous_repo->objects, a, NULL);
int b_type = odb_read_object_info(sort_ambiguous_repo->objects, b, NULL);
int a_type_sort;
int b_type_sort;


View File

@ -1,338 +0,0 @@
#ifndef OBJECT_STORE_H
#define OBJECT_STORE_H

#include "hashmap.h"
#include "object.h"
#include "list.h"
#include "oidset.h"
#include "oidmap.h"
#include "thread-utils.h"

struct oidmap;
struct oidtree;
struct strbuf;
struct repository;

struct object_directory {
struct object_directory *next;

/*
* Used to store the results of readdir(3) calls when we are OK
* sacrificing accuracy due to races for speed. That includes
* object existence with OBJECT_INFO_QUICK, as well as
* our search for unique abbreviated hashes. Don't use it for tasks
* requiring greater accuracy!
*
* Be sure to call odb_load_loose_cache() before using.
*/
uint32_t loose_objects_subdir_seen[8]; /* 256 bits */
struct oidtree *loose_objects_cache;

/* Map between object IDs for loose objects. */
struct loose_object_map *loose_map;

/*
* This is a temporary object store created by the tmp_objdir
* facility. Disable ref updates since the objects in the store
* might be discarded on rollback.
*/
int disable_ref_updates;

/*
* This object store is ephemeral, so there is no need to fsync.
*/
int will_destroy;

/*
* Path to the alternative object store. If this is a relative path,
* it is relative to the current working directory.
*/
char *path;
};

void prepare_alt_odb(struct repository *r);
int has_alt_odb(struct repository *r);
char *compute_alternate_path(const char *path, struct strbuf *err);
struct object_directory *find_odb(struct repository *r, const char *obj_dir);
typedef int alt_odb_fn(struct object_directory *, void *);
int foreach_alt_odb(alt_odb_fn, void*);
typedef void alternate_ref_fn(const struct object_id *oid, void *);
void for_each_alternate_ref(alternate_ref_fn, void *);

/*
* Add the directory to the on-disk alternates file; the new entry will also
* take effect in the current process.
*/
void add_to_alternates_file(const char *dir);

/*
* Add the directory to the in-memory list of alternates (along with any
* recursive alternates it points to), but do not modify the on-disk alternates
* file.
*/
void add_to_alternates_memory(const char *dir);

/*
* Replace the current writable object directory with the specified temporary
* object directory; returns the former primary object directory.
*/
struct object_directory *set_temporary_primary_odb(const char *dir, int will_destroy);

/*
* Restore a previous ODB replaced by set_temporary_main_odb.
*/
void restore_primary_odb(struct object_directory *restore_odb, const char *old_path);

struct packed_git;
struct multi_pack_index;
struct cached_object_entry;

struct raw_object_store {
/*
* Set of all object directories; the main directory is first (and
* cannot be NULL after initialization). Subsequent directories are
* alternates.
*/
struct object_directory *odb;
struct object_directory **odb_tail;
struct kh_odb_path_map *odb_by_path;

int loaded_alternates;

/*
* A list of alternate object directories loaded from the environment;
* this should not generally need to be accessed directly, but will
* populate the "odb" list when prepare_alt_odb() is run.
*/
char *alternate_db;

/*
* Objects that should be substituted by other objects
* (see git-replace(1)).
*/
struct oidmap replace_map;
unsigned replace_map_initialized : 1;
pthread_mutex_t replace_mutex; /* protect object replace functions */

struct commit_graph *commit_graph;
unsigned commit_graph_attempted : 1; /* if loading has been attempted */

/*
* private data
*
* should only be accessed directly by packfile.c and midx.c
*/
struct multi_pack_index *multi_pack_index;

/*
* private data
*
* should only be accessed directly by packfile.c
*/

struct packed_git *packed_git;
/* A most-recently-used ordered version of the packed_git list. */
struct list_head packed_git_mru;

struct {
struct packed_git **packs;
unsigned flags;
} kept_pack_cache;

/*
* This is meant to hold a *small* number of objects that you would
* want repo_read_object_file() to be able to return, but yet you do not want
* to write them into the object store (e.g. a browse-only
* application).
*/
struct cached_object_entry *cached_objects;
size_t cached_object_nr, cached_object_alloc;

/*
* A map of packfiles to packed_git structs for tracking which
* packs have been loaded already.
*/
struct hashmap pack_map;

/*
* A fast, rough count of the number of objects in the repository.
* These two fields are not meant for direct access. Use
* repo_approximate_object_count() instead.
*/
unsigned long approximate_object_count;
unsigned approximate_object_count_valid : 1;

/*
* Whether packed_git has already been populated with this repository's
* packs.
*/
unsigned packed_git_initialized : 1;
};

struct raw_object_store *raw_object_store_new(void);
void raw_object_store_clear(struct raw_object_store *o);

/*
* Create a temporary file rooted in the object database directory, or
* die on failure. The filename is taken from "pattern", which should have the
* usual "XXXXXX" trailer, and the resulting filename is written into the
* "template" buffer. Returns the open descriptor.
*/
int odb_mkstemp(struct strbuf *temp_filename, const char *pattern);

void *repo_read_object_file(struct repository *r,
const struct object_id *oid,
enum object_type *type,
unsigned long *size);

/* Read and unpack an object file into memory, write memory to an object file */
int oid_object_info(struct repository *r, const struct object_id *, unsigned long *);

/*
* Add an object file to the in-memory object store, without writing it
* to disk.
*
* Callers are responsible for calling write_object_file to record the
* object in persistent storage before writing any other new objects
* that reference it.
*/
int pretend_object_file(struct repository *repo,
void *buf, unsigned long len, enum object_type type,
struct object_id *oid);

struct object_info {
/* Request */
enum object_type *typep;
unsigned long *sizep;
off_t *disk_sizep;
struct object_id *delta_base_oid;
void **contentp;

/* Response */
enum {
OI_CACHED,
OI_LOOSE,
OI_PACKED,
OI_DBCACHED
} whence;
union {
/*
* struct {
* ... Nothing to expose in this case
* } cached;
* struct {
* ... Nothing to expose in this case
* } loose;
*/
struct {
struct packed_git *pack;
off_t offset;
unsigned int is_delta;
} packed;
} u;
};

/*
* Initializer for a "struct object_info" that wants no items. You may
* also memset() the memory to all-zeroes.
*/
#define OBJECT_INFO_INIT { 0 }

/* Invoke lookup_replace_object() on the given hash */
#define OBJECT_INFO_LOOKUP_REPLACE 1
/* Do not retry packed storage after checking packed and loose storage */
#define OBJECT_INFO_QUICK 8
/*
* Do not attempt to fetch the object if missing (even if fetch_is_missing is
* nonzero).
*/
#define OBJECT_INFO_SKIP_FETCH_OBJECT 16
/*
* This is meant for bulk prefetching of missing blobs in a partial
* clone. Implies OBJECT_INFO_SKIP_FETCH_OBJECT and OBJECT_INFO_QUICK
*/
#define OBJECT_INFO_FOR_PREFETCH (OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK)

/* Die if object corruption (not just an object being missing) was detected. */
#define OBJECT_INFO_DIE_IF_CORRUPT 32

int oid_object_info_extended(struct repository *r,
const struct object_id *,
struct object_info *, unsigned flags);

enum {
/* Retry packed storage after checking packed and loose storage */
HAS_OBJECT_RECHECK_PACKED = (1 << 0),
/* Allow fetching the object in case the repository has a promisor remote. */
HAS_OBJECT_FETCH_PROMISOR = (1 << 1),
};

/*
* Returns 1 if the object exists. This function will not lazily fetch objects
* in a partial clone by default.
*/
int has_object(struct repository *r, const struct object_id *oid,
unsigned flags);

void assert_oid_type(const struct object_id *oid, enum object_type expect);

/*
* Enabling the object read lock allows multiple threads to safely call the
* following functions in parallel: repo_read_object_file(),
* read_object_with_reference(), oid_object_info() and oid_object_info_extended().
*
* obj_read_lock() and obj_read_unlock() may also be used to protect other
* section which cannot execute in parallel with object reading. Since the used
* lock is a recursive mutex, these sections can even contain calls to object
* reading functions. However, beware that in these cases zlib inflation won't
* be performed in parallel, losing performance.
*
* TODO: oid_object_info_extended()'s call stack has a recursive behavior. If
* any of its callees end up calling it, this recursive call won't benefit from
* parallel inflation.
*/
void enable_obj_read_lock(void);
void disable_obj_read_lock(void);

extern int obj_read_use_lock;
extern pthread_mutex_t obj_read_mutex;

static inline void obj_read_lock(void)
{
if(obj_read_use_lock)
pthread_mutex_lock(&obj_read_mutex);
}

static inline void obj_read_unlock(void)
{
if(obj_read_use_lock)
pthread_mutex_unlock(&obj_read_mutex);
}
/* Flags for for_each_*_object(). */
enum for_each_object_flags {
/* Iterate only over local objects, not alternates. */
FOR_EACH_OBJECT_LOCAL_ONLY = (1<<0),

/* Only iterate over packs obtained from the promisor remote. */
FOR_EACH_OBJECT_PROMISOR_ONLY = (1<<1),

/*
* Visit objects within a pack in packfile order rather than .idx order
*/
FOR_EACH_OBJECT_PACK_ORDER = (1<<2),

/* Only iterate over packs that are not marked as kept in-core. */
FOR_EACH_OBJECT_SKIP_IN_CORE_KEPT_PACKS = (1<<3),

/* Only iterate over packs that do not have .keep files. */
FOR_EACH_OBJECT_SKIP_ON_DISK_KEPT_PACKS = (1<<4),
};


void *read_object_with_reference(struct repository *r,
const struct object_id *oid,
enum object_type required_type,
unsigned long *size,
struct object_id *oid_ret);

#endif /* OBJECT_STORE_H */

View File

@ -214,7 +214,7 @@ enum peel_status peel_object(struct repository *r,
struct object *o = lookup_unknown_object(r, name);

if (o->type == OBJ_NONE) {
int type = oid_object_info(r, name, NULL);
int type = odb_read_object_info(r->objects, name, NULL);
if (type < 0 || !object_as_type(o, type, 0))
return PEEL_INVALID;
}
@ -315,7 +315,7 @@ struct object *parse_object_with_flags(struct repository *r,
}

if ((!obj || obj->type == OBJ_BLOB) &&
oid_object_info(r, oid, NULL) == OBJ_BLOB) {
odb_read_object_info(r->objects, oid, NULL) == OBJ_BLOB) {
if (!skip_hash && stream_object_signature(r, repl) < 0) {
error(_("hash mismatch %s"), oid_to_hex(oid));
return NULL;
@ -331,11 +331,11 @@ struct object *parse_object_with_flags(struct repository *r,
*/
if (skip_hash && discard_tree &&
(!obj || obj->type == OBJ_TREE) &&
oid_object_info(r, oid, NULL) == OBJ_TREE) {
odb_read_object_info(r->objects, oid, NULL) == OBJ_TREE) {
return &lookup_tree(r, oid)->object;
}

buffer = repo_read_object_file(r, oid, &type, &size);
buffer = odb_read_object(r->objects, oid, &type, &size);
if (buffer) {
if (!skip_hash &&
check_object_signature(r, repl, buffer, size, type) < 0) {

View File

@ -1,5 +1,3 @@
#define USE_THE_REPOSITORY_VARIABLE

#include "git-compat-util.h"
#include "abspath.h"
#include "commit-graph.h"
@ -13,7 +11,7 @@
#include "loose.h"
#include "object-file-convert.h"
#include "object-file.h"
#include "object-store.h"
#include "odb.h"
#include "packfile.h"
#include "path.h"
#include "promisor-remote.h"
@ -24,14 +22,15 @@
#include "strbuf.h"
#include "strvec.h"
#include "submodule.h"
#include "trace2.h"
#include "write-or-die.h"

KHASH_INIT(odb_path_map, const char * /* key: odb_path */,
struct object_directory *, 1, fspathhash, fspatheq)
struct odb_source *, 1, fspathhash, fspatheq)

/*
* This is meant to hold a *small* number of objects that you would
* want repo_read_object_file() to be able to return, but yet you do not want
* want odb_read_object() to be able to return, but yet you do not want
* to write them into the object store (e.g. a browse-only
* application).
*/
@ -44,7 +43,7 @@ struct cached_object_entry {
} value;
};

static const struct cached_object *find_cached_object(struct raw_object_store *object_store,
static const struct cached_object *find_cached_object(struct object_database *object_store,
const struct object_id *oid)
{
static const struct cached_object empty_tree = {
@ -63,7 +62,8 @@ static const struct cached_object *find_cached_object(struct raw_object_store *o
return NULL;
}

int odb_mkstemp(struct strbuf *temp_filename, const char *pattern)
int odb_mkstemp(struct object_database *odb,
struct strbuf *temp_filename, const char *pattern)
{
int fd;
/*
@ -71,22 +71,22 @@ int odb_mkstemp(struct strbuf *temp_filename, const char *pattern)
* restrictive except to remove write permission.
*/
int mode = 0444;
repo_git_path_replace(the_repository, temp_filename, "objects/%s", pattern);
repo_git_path_replace(odb->repo, temp_filename, "objects/%s", pattern);
fd = git_mkstemp_mode(temp_filename->buf, mode);
if (0 <= fd)
return fd;

/* slow path */
/* some mkstemp implementations erase temp_filename on failure */
repo_git_path_replace(the_repository, temp_filename, "objects/%s", pattern);
safe_create_leading_directories(the_repository, temp_filename->buf);
repo_git_path_replace(odb->repo, temp_filename, "objects/%s", pattern);
safe_create_leading_directories(odb->repo, temp_filename->buf);
return xmkstemp_mode(temp_filename->buf, mode);
}

/*
* Return non-zero iff the path is usable as an alternate object database.
*/
static int alt_odb_usable(struct raw_object_store *o,
static int alt_odb_usable(struct object_database *o,
struct strbuf *path,
const char *normalized_objdir, khiter_t *pos)
{
@ -104,18 +104,18 @@ static int alt_odb_usable(struct raw_object_store *o,
* Prevent the common mistake of listing the same
* thing twice, or object directory itself.
*/
if (!o->odb_by_path) {
if (!o->source_by_path) {
khiter_t p;

o->odb_by_path = kh_init_odb_path_map();
assert(!o->odb->next);
p = kh_put_odb_path_map(o->odb_by_path, o->odb->path, &r);
o->source_by_path = kh_init_odb_path_map();
assert(!o->sources->next);
p = kh_put_odb_path_map(o->source_by_path, o->sources->path, &r);
assert(r == 1); /* never used */
kh_value(o->odb_by_path, p) = o->odb;
kh_value(o->source_by_path, p) = o->sources;
}
if (fspatheq(path->buf, normalized_objdir))
return 0;
*pos = kh_put_odb_path_map(o->odb_by_path, path->buf, &r);
*pos = kh_put_odb_path_map(o->source_by_path, path->buf, &r);
/* r: 0 = exists, 1 = never used, 2 = deleted */
return r == 0 ? 0 : 1;
}
@ -124,7 +124,7 @@ static int alt_odb_usable(struct raw_object_store *o,
* Prepare alternate object database registry.
*
* The variable alt_odb_list points at the list of struct
* object_directory. The elements on this list come from
* odb_source. The elements on this list come from
* non-empty elements from colon separated ALTERNATE_DB_ENVIRONMENT
* environment variable, and $GIT_OBJECT_DIRECTORY/info/alternates,
* whose contents is similar to that environment variable but can be
@ -135,13 +135,17 @@ static int alt_odb_usable(struct raw_object_store *o,
* of the object ID, an extra slash for the first level indirection, and
* the terminating NUL.
*/
static void read_info_alternates(struct repository *r,
static void read_info_alternates(struct object_database *odb,
const char *relative_base,
int depth);
static int link_alt_odb_entry(struct repository *r, const struct strbuf *entry,
const char *relative_base, int depth, const char *normalized_objdir)

static int link_alt_odb_entry(struct object_database *odb,
const struct strbuf *entry,
const char *relative_base,
int depth,
const char *normalized_objdir)
{
struct object_directory *ent;
struct odb_source *alternate;
struct strbuf pathbuf = STRBUF_INIT;
struct strbuf tmp = STRBUF_INIT;
khiter_t pos;
@ -167,22 +171,23 @@ static int link_alt_odb_entry(struct repository *r, const struct strbuf *entry,
while (pathbuf.len && pathbuf.buf[pathbuf.len - 1] == '/')
strbuf_setlen(&pathbuf, pathbuf.len - 1);

if (!alt_odb_usable(r->objects, &pathbuf, normalized_objdir, &pos))
if (!alt_odb_usable(odb, &pathbuf, normalized_objdir, &pos))
goto error;

CALLOC_ARRAY(ent, 1);
/* pathbuf.buf is already in r->objects->odb_by_path */
ent->path = strbuf_detach(&pathbuf, NULL);
CALLOC_ARRAY(alternate, 1);
alternate->odb = odb;
/* pathbuf.buf is already in r->objects->source_by_path */
alternate->path = strbuf_detach(&pathbuf, NULL);

/* add the alternate entry */
*r->objects->odb_tail = ent;
r->objects->odb_tail = &(ent->next);
ent->next = NULL;
assert(r->objects->odb_by_path);
kh_value(r->objects->odb_by_path, pos) = ent;
*odb->sources_tail = alternate;
odb->sources_tail = &(alternate->next);
alternate->next = NULL;
assert(odb->source_by_path);
kh_value(odb->source_by_path, pos) = alternate;

/* recursively add alternates */
read_info_alternates(r, ent->path, depth + 1);
read_info_alternates(odb, alternate->path, depth + 1);
ret = 0;
error:
strbuf_release(&tmp);
@ -219,7 +224,7 @@ static const char *parse_alt_odb_entry(const char *string,
return end;
}

static void link_alt_odb_entries(struct repository *r, const char *alt,
static void link_alt_odb_entries(struct object_database *odb, const char *alt,
int sep, const char *relative_base, int depth)
{
struct strbuf objdirbuf = STRBUF_INIT;
@ -234,20 +239,20 @@ static void link_alt_odb_entries(struct repository *r, const char *alt,
return;
}

strbuf_realpath(&objdirbuf, r->objects->odb->path, 1);
strbuf_realpath(&objdirbuf, odb->sources->path, 1);

while (*alt) {
alt = parse_alt_odb_entry(alt, sep, &entry);
if (!entry.len)
continue;
link_alt_odb_entry(r, &entry,
link_alt_odb_entry(odb, &entry,
relative_base, depth, objdirbuf.buf);
}
strbuf_release(&entry);
strbuf_release(&objdirbuf);
}

static void read_info_alternates(struct repository *r,
static void read_info_alternates(struct object_database *odb,
const char *relative_base,
int depth)
{
@ -261,15 +266,16 @@ static void read_info_alternates(struct repository *r,
return;
}

link_alt_odb_entries(r, buf.buf, '\n', relative_base, depth);
link_alt_odb_entries(odb, buf.buf, '\n', relative_base, depth);
strbuf_release(&buf);
free(path);
}

void add_to_alternates_file(const char *reference)
void odb_add_to_alternates_file(struct object_database *odb,
const char *reference)
{
struct lock_file lock = LOCK_INIT;
char *alts = repo_git_path(the_repository, "objects/info/alternates");
char *alts = repo_git_path(odb->repo, "objects/info/alternates");
FILE *in, *out;
int found = 0;

@ -302,82 +308,81 @@ void add_to_alternates_file(const char *reference)
fprintf_or_die(out, "%s\n", reference);
if (commit_lock_file(&lock))
die_errno(_("unable to move new alternates file into place"));
if (the_repository->objects->loaded_alternates)
link_alt_odb_entries(the_repository, reference,
if (odb->loaded_alternates)
link_alt_odb_entries(odb, reference,
'\n', NULL, 0);
}
free(alts);
}

void add_to_alternates_memory(const char *reference)
void odb_add_to_alternates_memory(struct object_database *odb,
const char *reference)
{
/*
* Make sure alternates are initialized, or else our entry may be
* overwritten when they are.
*/
prepare_alt_odb(the_repository);
odb_prepare_alternates(odb);

link_alt_odb_entries(the_repository, reference,
link_alt_odb_entries(odb, reference,
'\n', NULL, 0);
}

struct object_directory *set_temporary_primary_odb(const char *dir, int will_destroy)
struct odb_source *odb_set_temporary_primary_source(struct object_database *odb,
const char *dir, int will_destroy)
{
struct object_directory *new_odb;
struct odb_source *source;

/*
* Make sure alternates are initialized, or else our entry may be
* overwritten when they are.
*/
prepare_alt_odb(the_repository);
odb_prepare_alternates(odb);

/*
* Make a new primary odb and link the old primary ODB in as an
* alternate
*/
new_odb = xcalloc(1, sizeof(*new_odb));
new_odb->path = xstrdup(dir);
source = xcalloc(1, sizeof(*source));
source->odb = odb;
source->path = xstrdup(dir);

/*
* Disable ref updates while a temporary odb is active, since
* the objects in the database may roll back.
*/
new_odb->disable_ref_updates = 1;
new_odb->will_destroy = will_destroy;
new_odb->next = the_repository->objects->odb;
the_repository->objects->odb = new_odb;
return new_odb->next;
source->disable_ref_updates = 1;
source->will_destroy = will_destroy;
source->next = odb->sources;
odb->sources = source;
return source->next;
}

static void free_object_directory(struct object_directory *odb)
static void free_object_directory(struct odb_source *source)
{
free(odb->path);
odb_clear_loose_cache(odb);
loose_object_map_clear(&odb->loose_map);
free(odb);
free(source->path);
odb_clear_loose_cache(source);
loose_object_map_clear(&source->loose_map);
free(source);
}

void restore_primary_odb(struct object_directory *restore_odb, const char *old_path)
void odb_restore_primary_source(struct object_database *odb,
struct odb_source *restore_source,
const char *old_path)
{
struct object_directory *cur_odb = the_repository->objects->odb;
struct odb_source *cur_source = odb->sources;

if (strcmp(old_path, cur_odb->path))
if (strcmp(old_path, cur_source->path))
BUG("expected %s as primary object store; found %s",
old_path, cur_odb->path);
old_path, cur_source->path);

if (cur_odb->next != restore_odb)
if (cur_source->next != restore_source)
BUG("we expect the old primary object store to be the first alternate");

the_repository->objects->odb = restore_odb;
free_object_directory(cur_odb);
odb->sources = restore_source;
free_object_directory(cur_source);
}

/*
* Compute the exact path an alternate is at and returns it. In case of
* error NULL is returned and the human readable error is added to `err`
* `path` may be relative and should point to $GIT_DIR.
* `err` must not be null.
*/
char *compute_alternate_path(const char *path, struct strbuf *err)
{
char *ref_git = NULL;
@ -442,15 +447,15 @@ out:
return ref_git;
}

struct object_directory *find_odb(struct repository *r, const char *obj_dir)
struct odb_source *odb_find_source(struct object_database *odb, const char *obj_dir)
{
struct object_directory *odb;
struct odb_source *source;
char *obj_dir_real = real_pathdup(obj_dir, 1);
struct strbuf odb_path_real = STRBUF_INIT;

prepare_alt_odb(r);
for (odb = r->objects->odb; odb; odb = odb->next) {
strbuf_realpath(&odb_path_real, odb->path, 1);
odb_prepare_alternates(odb);
for (source = odb->sources; source; source = source->next) {
strbuf_realpath(&odb_path_real, source->path, 1);
if (!strcmp(obj_dir_real, odb_path_real.buf))
break;
}
@ -458,17 +463,24 @@ struct object_directory *find_odb(struct repository *r, const char *obj_dir)
free(obj_dir_real);
strbuf_release(&odb_path_real);

if (!odb)
if (!source)
die(_("could not find object directory matching %s"), obj_dir);
return odb;
return source;
}

static void fill_alternate_refs_command(struct child_process *cmd,
void odb_add_submodule_source_by_path(struct object_database *odb,
const char *path)
{
string_list_insert(&odb->submodule_source_paths, path);
}

static void fill_alternate_refs_command(struct repository *repo,
struct child_process *cmd,
const char *repo_path)
{
const char *value;

if (!git_config_get_value("core.alternateRefsCommand", &value)) {
if (!repo_config_get_value(repo, "core.alternateRefsCommand", &value)) {
cmd->use_shell = 1;

strvec_push(&cmd->args, value);
@ -480,7 +492,7 @@ static void fill_alternate_refs_command(struct child_process *cmd,
strvec_push(&cmd->args, "for-each-ref");
strvec_push(&cmd->args, "--format=%(objectname)");

if (!git_config_get_value("core.alternateRefsPrefixes", &value)) {
if (!repo_config_get_value(repo, "core.alternateRefsPrefixes", &value)) {
strvec_push(&cmd->args, "--");
strvec_split(&cmd->args, value);
}
@ -490,15 +502,16 @@ static void fill_alternate_refs_command(struct child_process *cmd,
cmd->out = -1;
}

static void read_alternate_refs(const char *path,
alternate_ref_fn *cb,
void *data)
static void read_alternate_refs(struct repository *repo,
const char *path,
odb_for_each_alternate_ref_fn *cb,
void *payload)
{
struct child_process cmd = CHILD_PROCESS_INIT;
struct strbuf line = STRBUF_INIT;
FILE *fh;

fill_alternate_refs_command(&cmd, path);
fill_alternate_refs_command(repo, &cmd, path);

if (start_command(&cmd))
return;
@ -508,13 +521,13 @@ static void read_alternate_refs(const char *path,
struct object_id oid;
const char *p;

if (parse_oid_hex(line.buf, &oid, &p) || *p) {
if (parse_oid_hex_algop(line.buf, &oid, &p, repo->hash_algo) || *p) {
warning(_("invalid line while parsing alternate refs: %s"),
line.buf);
break;
}

cb(&oid, data);
cb(&oid, payload);
}

fclose(fh);
@ -523,18 +536,18 @@ static void read_alternate_refs(const char *path,
}

struct alternate_refs_data {
alternate_ref_fn *fn;
void *data;
odb_for_each_alternate_ref_fn *fn;
void *payload;
};

static int refs_from_alternate_cb(struct object_directory *e,
void *data)
static int refs_from_alternate_cb(struct odb_source *alternate,
void *payload)
{
struct strbuf path = STRBUF_INIT;
size_t base_len;
struct alternate_refs_data *cb = data;
struct alternate_refs_data *cb = payload;

if (!strbuf_realpath(&path, e->path, 0))
if (!strbuf_realpath(&path, alternate->path, 0))
goto out;
if (!strbuf_strip_suffix(&path, "/objects"))
goto out;
@ -546,50 +559,52 @@ static int refs_from_alternate_cb(struct object_directory *e,
goto out;
strbuf_setlen(&path, base_len);

read_alternate_refs(path.buf, cb->fn, cb->data);
read_alternate_refs(alternate->odb->repo, path.buf, cb->fn, cb->payload);

out:
strbuf_release(&path);
return 0;
}

void for_each_alternate_ref(alternate_ref_fn fn, void *data)
void odb_for_each_alternate_ref(struct object_database *odb,
odb_for_each_alternate_ref_fn cb, void *payload)
{
struct alternate_refs_data cb;
cb.fn = fn;
cb.data = data;
foreach_alt_odb(refs_from_alternate_cb, &cb);
struct alternate_refs_data data;
data.fn = cb;
data.payload = payload;
odb_for_each_alternate(odb, refs_from_alternate_cb, &data);
}

int foreach_alt_odb(alt_odb_fn fn, void *cb)
int odb_for_each_alternate(struct object_database *odb,
odb_for_each_alternate_fn cb, void *payload)
{
struct object_directory *ent;
struct odb_source *alternate;
int r = 0;

prepare_alt_odb(the_repository);
for (ent = the_repository->objects->odb->next; ent; ent = ent->next) {
r = fn(ent, cb);
odb_prepare_alternates(odb);
for (alternate = odb->sources->next; alternate; alternate = alternate->next) {
r = cb(alternate, payload);
if (r)
break;
}
return r;
}

void prepare_alt_odb(struct repository *r)
void odb_prepare_alternates(struct object_database *odb)
{
if (r->objects->loaded_alternates)
if (odb->loaded_alternates)
return;

link_alt_odb_entries(r, r->objects->alternate_db, PATH_SEP, NULL, 0);
link_alt_odb_entries(odb, odb->alternate_db, PATH_SEP, NULL, 0);

read_info_alternates(r, r->objects->odb->path, 0);
r->objects->loaded_alternates = 1;
read_info_alternates(odb, odb->sources->path, 0);
odb->loaded_alternates = 1;
}

int has_alt_odb(struct repository *r)
int odb_has_alternates(struct object_database *odb)
{
prepare_alt_odb(r);
return !!r->objects->odb->next;
odb_prepare_alternates(odb);
return !!odb->sources->next;
}

int obj_read_use_lock = 0;
@ -615,7 +630,24 @@ void disable_obj_read_lock(void)

int fetch_if_missing = 1;

static int do_oid_object_info_extended(struct repository *r,
static int register_all_submodule_sources(struct object_database *odb)
{
int ret = odb->submodule_source_paths.nr;

for (size_t i = 0; i < odb->submodule_source_paths.nr; i++)
odb_add_to_alternates_memory(odb,
odb->submodule_source_paths.items[i].string);
if (ret) {
string_list_clear(&odb->submodule_source_paths, 0);
trace2_data_intmax("submodule", odb->repo,
"register_all_submodule_sources/registered", ret);
if (git_env_bool("GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB", 0))
BUG("register_all_submodule_sources() called");
}
return ret;
}

static int do_oid_object_info_extended(struct object_database *odb,
const struct object_id *oid,
struct object_info *oi, unsigned flags)
{
@ -628,7 +660,7 @@ static int do_oid_object_info_extended(struct repository *r,


if (flags & OBJECT_INFO_LOOKUP_REPLACE)
real = lookup_replace_object(r, oid);
real = lookup_replace_object(odb->repo, oid);

if (is_null_oid(real))
return -1;
@ -636,7 +668,7 @@ static int do_oid_object_info_extended(struct repository *r,
if (!oi)
oi = &blank_oi;

co = find_cached_object(r->objects, real);
co = find_cached_object(odb, real);
if (co) {
if (oi->typep)
*(oi->typep) = co->type;
@ -645,7 +677,7 @@ static int do_oid_object_info_extended(struct repository *r,
if (oi->disk_sizep)
*(oi->disk_sizep) = 0;
if (oi->delta_base_oid)
oidclr(oi->delta_base_oid, the_repository->hash_algo);
oidclr(oi->delta_base_oid, odb->repo->hash_algo);
if (oi->contentp)
*oi->contentp = xmemdupz(co->buf, co->size);
oi->whence = OI_CACHED;
@ -653,36 +685,35 @@ static int do_oid_object_info_extended(struct repository *r,
}

while (1) {
if (find_pack_entry(r, real, &e))
if (find_pack_entry(odb->repo, real, &e))
break;

/* Most likely it's a loose object. */
if (!loose_object_info(r, real, oi, flags))
if (!loose_object_info(odb->repo, real, oi, flags))
return 0;

/* Not a loose object; someone else may have just packed it. */
if (!(flags & OBJECT_INFO_QUICK)) {
reprepare_packed_git(r);
if (find_pack_entry(r, real, &e))
reprepare_packed_git(odb->repo);
if (find_pack_entry(odb->repo, real, &e))
break;
}

/*
* If r is the_repository, this might be an attempt at
* accessing a submodule object as if it were in the_repository
* (having called add_submodule_odb() on that submodule's ODB).
* If any such ODBs exist, register them and try again.
* This might be an attempt at accessing a submodule object as
* if it were in main object store (having called
* `odb_add_submodule_source_by_path()` on that submodule's
* ODB). If any such ODBs exist, register them and try again.
*/
if (r == the_repository &&
register_all_submodule_odb_as_alternates())
if (register_all_submodule_sources(odb))
/* We added some alternates; retry */
continue;

/* Check if it is a missing object */
if (fetch_if_missing && repo_has_promisor_remote(r) &&
if (fetch_if_missing && repo_has_promisor_remote(odb->repo) &&
!already_retried &&
!(flags & OBJECT_INFO_SKIP_FETCH_OBJECT)) {
promisor_remote_get_direct(r, real, 1);
promisor_remote_get_direct(odb->repo, real, 1);
already_retried = 1;
continue;
}
@ -692,7 +723,7 @@ static int do_oid_object_info_extended(struct repository *r,
if ((flags & OBJECT_INFO_LOOKUP_REPLACE) && !oideq(real, oid))
die(_("replacement %s not found for %s"),
oid_to_hex(real), oid_to_hex(oid));
if ((p = has_packed_and_bad(r, real)))
if ((p = has_packed_and_bad(odb->repo, real)))
die(_("packed object %s (stored in %s) is corrupt"),
oid_to_hex(real), p->pack_name);
}
@ -705,10 +736,10 @@ static int do_oid_object_info_extended(struct repository *r,
* information below, so return early.
*/
return 0;
rtype = packed_object_info(r, e.p, e.offset, oi);
rtype = packed_object_info(odb->repo, e.p, e.offset, oi);
if (rtype < 0) {
mark_bad_packed_object(e.p, real);
return do_oid_object_info_extended(r, real, oi, 0);
return do_oid_object_info_extended(odb, real, oi, 0);
} else if (oi->whence == OI_PACKED) {
oi->u.packed.offset = e.offset;
oi->u.packed.pack = e.p;
@ -732,10 +763,10 @@ static int oid_object_info_convert(struct repository *r,
void *content;
int ret;

if (repo_oid_to_algop(r, input_oid, the_hash_algo, &oid)) {
if (repo_oid_to_algop(r, input_oid, r->hash_algo, &oid)) {
if (do_die)
die(_("missing mapping of %s to %s"),
oid_to_hex(input_oid), the_hash_algo->name);
oid_to_hex(input_oid), r->hash_algo->name);
return -1;
}

@ -756,7 +787,7 @@ static int oid_object_info_convert(struct repository *r,
oi = &new_oi;
}

ret = oid_object_info_extended(r, &oid, oi, flags);
ret = odb_read_object_info_extended(r->objects, &oid, oi, flags);
if (ret)
return -1;
if (oi == input_oi)
@ -766,8 +797,8 @@ static int oid_object_info_convert(struct repository *r,
struct strbuf outbuf = STRBUF_INIT;

if (type != OBJ_BLOB) {
ret = convert_object_file(the_repository, &outbuf,
the_hash_algo, input_algo,
ret = convert_object_file(r, &outbuf,
r->hash_algo, input_algo,
content, size, type, !do_die);
free(content);
if (ret == -1)
@ -799,23 +830,25 @@ static int oid_object_info_convert(struct repository *r,
return ret;
}

int oid_object_info_extended(struct repository *r, const struct object_id *oid,
struct object_info *oi, unsigned flags)
int odb_read_object_info_extended(struct object_database *odb,
const struct object_id *oid,
struct object_info *oi,
unsigned flags)
{
int ret;

if (oid->algo && (hash_algo_by_ptr(r->hash_algo) != oid->algo))
return oid_object_info_convert(r, oid, oi, flags);
if (oid->algo && (hash_algo_by_ptr(odb->repo->hash_algo) != oid->algo))
return oid_object_info_convert(odb->repo, oid, oi, flags);

obj_read_lock();
ret = do_oid_object_info_extended(r, oid, oi, flags);
ret = do_oid_object_info_extended(odb, oid, oi, flags);
obj_read_unlock();
return ret;
}


/* returns enum object_type or negative */
int oid_object_info(struct repository *r,
int odb_read_object_info(struct object_database *odb,
const struct object_id *oid,
unsigned long *sizep)
{
@ -824,27 +857,27 @@ int oid_object_info(struct repository *r,

oi.typep = &type;
oi.sizep = sizep;
if (oid_object_info_extended(r, oid, &oi,
if (odb_read_object_info_extended(odb, oid, &oi,
OBJECT_INFO_LOOKUP_REPLACE) < 0)
return -1;
return type;
}

int pretend_object_file(struct repository *repo,
int odb_pretend_object(struct object_database *odb,
void *buf, unsigned long len, enum object_type type,
struct object_id *oid)
{
struct cached_object_entry *co;
char *co_buf;

hash_object_file(repo->hash_algo, buf, len, type, oid);
if (has_object(repo, oid, 0) ||
find_cached_object(repo->objects, oid))
hash_object_file(odb->repo->hash_algo, buf, len, type, oid);
if (odb_has_object(odb, oid, 0) ||
find_cached_object(odb, oid))
return 0;

ALLOC_GROW(repo->objects->cached_objects,
repo->objects->cached_object_nr + 1, repo->objects->cached_object_alloc);
co = &repo->objects->cached_objects[repo->objects->cached_object_nr++];
ALLOC_GROW(odb->cached_objects,
odb->cached_object_nr + 1, odb->cached_object_alloc);
co = &odb->cached_objects[odb->cached_object_nr++];
co->value.size = len;
co->value.type = type;
co_buf = xmalloc(len);
@ -854,12 +887,7 @@ int pretend_object_file(struct repository *repo,
return 0;
}

/*
* This function dies on corrupt objects; the callers who want to
* deal with them should arrange to call oid_object_info_extended() and give
* error messages themselves.
*/
void *repo_read_object_file(struct repository *r,
void *odb_read_object(struct object_database *odb,
const struct object_id *oid,
enum object_type *type,
unsigned long *size)
@ -871,13 +899,13 @@ void *repo_read_object_file(struct repository *r,
oi.typep = type;
oi.sizep = size;
oi.contentp = &data;
if (oid_object_info_extended(r, oid, &oi, flags))
if (odb_read_object_info_extended(odb, oid, &oi, flags))
return NULL;

return data;
}

void *read_object_with_reference(struct repository *r,
void *odb_read_object_peeled(struct object_database *odb,
const struct object_id *oid,
enum object_type required_type,
unsigned long *size,
@ -893,7 +921,7 @@ void *read_object_with_reference(struct repository *r,
int ref_length = -1;
const char *ref_type = NULL;

buffer = repo_read_object_file(r, &actual_oid, &type, &isize);
buffer = odb_read_object(odb, &actual_oid, &type, &isize);
if (!buffer)
return NULL;
if (type == required_type) {
@ -913,9 +941,10 @@ void *read_object_with_reference(struct repository *r,
}
ref_length = strlen(ref_type);

if (ref_length + the_hash_algo->hexsz > isize ||
if (ref_length + odb->repo->hash_algo->hexsz > isize ||
memcmp(buffer, ref_type, ref_length) ||
get_oid_hex((char *) buffer + ref_length, &actual_oid)) {
get_oid_hex_algop((char *) buffer + ref_length, &actual_oid,
odb->repo->hash_algo)) {
free(buffer);
return NULL;
}
@ -925,7 +954,7 @@ void *read_object_with_reference(struct repository *r,
}
}

int has_object(struct repository *r, const struct object_id *oid,
int odb_has_object(struct object_database *odb, const struct object_id *oid,
unsigned flags)
{
unsigned object_info_flags = 0;
@ -937,12 +966,13 @@ int has_object(struct repository *r, const struct object_id *oid,
if (!(flags & HAS_OBJECT_FETCH_PROMISOR))
object_info_flags |= OBJECT_INFO_SKIP_FETCH_OBJECT;

return oid_object_info_extended(r, oid, NULL, object_info_flags) >= 0;
return odb_read_object_info_extended(odb, oid, NULL, object_info_flags) >= 0;
}

void assert_oid_type(const struct object_id *oid, enum object_type expect)
void odb_assert_oid_type(struct object_database *odb,
const struct object_id *oid, enum object_type expect)
{
enum object_type type = oid_object_info(the_repository, oid, NULL);
enum object_type type = odb_read_object_info(odb, oid, NULL);
if (type < 0)
die(_("%s is not a valid object"), oid_to_hex(oid));
if (type != expect)
@ -950,31 +980,33 @@ void assert_oid_type(const struct object_id *oid, enum object_type expect)
type_name(expect));
}

struct raw_object_store *raw_object_store_new(void)
struct object_database *odb_new(struct repository *repo)
{
struct raw_object_store *o = xmalloc(sizeof(*o));
struct object_database *o = xmalloc(sizeof(*o));

memset(o, 0, sizeof(*o));
o->repo = repo;
INIT_LIST_HEAD(&o->packed_git_mru);
hashmap_init(&o->pack_map, pack_map_entry_cmp, NULL, 0);
pthread_mutex_init(&o->replace_mutex, NULL);
string_list_init_dup(&o->submodule_source_paths);
return o;
}

static void free_object_directories(struct raw_object_store *o)
static void free_object_directories(struct object_database *o)
{
while (o->odb) {
struct object_directory *next;
while (o->sources) {
struct odb_source *next;

next = o->odb->next;
free_object_directory(o->odb);
o->odb = next;
next = o->sources->next;
free_object_directory(o->sources);
o->sources = next;
}
kh_destroy_odb_path_map(o->odb_by_path);
o->odb_by_path = NULL;
kh_destroy_odb_path_map(o->source_by_path);
o->source_by_path = NULL;
}

void raw_object_store_clear(struct raw_object_store *o)
void odb_clear(struct object_database *o)
{
FREE_AND_NULL(o->alternate_db);

@ -986,7 +1018,7 @@ void raw_object_store_clear(struct raw_object_store *o)
o->commit_graph_attempted = 0;

free_object_directories(o);
o->odb_tail = NULL;
o->sources_tail = NULL;
o->loaded_alternates = 0;

for (size_t i = 0; i < o->cached_object_nr; i++)
@ -1007,4 +1039,5 @@ void raw_object_store_clear(struct raw_object_store *o)
o->packed_git = NULL;

hashmap_clear(&o->pack_map);
string_list_clear(&o->submodule_source_paths, 0);
}

473
odb.h Normal file
View File

@ -0,0 +1,473 @@
#ifndef ODB_H
#define ODB_H

#include "hashmap.h"
#include "object.h"
#include "list.h"
#include "oidset.h"
#include "oidmap.h"
#include "string-list.h"
#include "thread-utils.h"

struct oidmap;
struct oidtree;
struct strbuf;
struct repository;

/*
* Compute the exact path an alternate is at and returns it. In case of
* error NULL is returned and the human readable error is added to `err`
* `path` may be relative and should point to $GIT_DIR.
* `err` must not be null.
*/
char *compute_alternate_path(const char *path, struct strbuf *err);

/*
* The source is the part of the object database that stores the actual
* objects. It thus encapsulates the logic to read and write the specific
* on-disk format. An object database can have multiple sources:
*
* - The primary source, which is typically located in "$GIT_DIR/objects".
* This is where new objects are usually written to.
*
* - Alternate sources, which are configured via "objects/info/alternates" or
* via the GIT_ALTERNATE_OBJECT_DIRECTORIES environment variable. These
* alternate sources are only used to read objects.
*/
struct odb_source {
struct odb_source *next;

/* Object database that owns this object source. */
struct object_database *odb;

/*
* Used to store the results of readdir(3) calls when we are OK
* sacrificing accuracy due to races for speed. That includes
* object existence with OBJECT_INFO_QUICK, as well as
* our search for unique abbreviated hashes. Don't use it for tasks
* requiring greater accuracy!
*
* Be sure to call odb_load_loose_cache() before using.
*/
uint32_t loose_objects_subdir_seen[8]; /* 256 bits */
struct oidtree *loose_objects_cache;

/* Map between object IDs for loose objects. */
struct loose_object_map *loose_map;

/*
* This is a temporary object store created by the tmp_objdir
* facility. Disable ref updates since the objects in the store
* might be discarded on rollback.
*/
int disable_ref_updates;

/*
* This object store is ephemeral, so there is no need to fsync.
*/
int will_destroy;

/*
* Path to the source. If this is a relative path, it is relative to
* the current working directory.
*/
char *path;
};

struct packed_git;
struct multi_pack_index;
struct cached_object_entry;

/*
* The object database encapsulates access to objects in a repository. It
* manages one or more sources that store the actual objects which are
* configured via alternates.
*/
struct object_database {
/* Repository that owns this database. */
struct repository *repo;

/*
* Set of all object directories; the main directory is first (and
* cannot be NULL after initialization). Subsequent directories are
* alternates.
*/
struct odb_source *sources;
struct odb_source **sources_tail;
struct kh_odb_path_map *source_by_path;

int loaded_alternates;

/*
* A list of alternate object directories loaded from the environment;
* this should not generally need to be accessed directly, but will
* populate the "sources" list when odb_prepare_alternates() is run.
*/
char *alternate_db;

/*
* Objects that should be substituted by other objects
* (see git-replace(1)).
*/
struct oidmap replace_map;
unsigned replace_map_initialized : 1;
pthread_mutex_t replace_mutex; /* protect object replace functions */

struct commit_graph *commit_graph;
unsigned commit_graph_attempted : 1; /* if loading has been attempted */

/*
* private data
*
* should only be accessed directly by packfile.c and midx.c
*/
struct multi_pack_index *multi_pack_index;

/*
* private data
*
* should only be accessed directly by packfile.c
*/

struct packed_git *packed_git;
/* A most-recently-used ordered version of the packed_git list. */
struct list_head packed_git_mru;

struct {
struct packed_git **packs;
unsigned flags;
} kept_pack_cache;

/*
* This is meant to hold a *small* number of objects that you would
* want odb_read_object() to be able to return, but yet you do not want
* to write them into the object store (e.g. a browse-only
* application).
*/
struct cached_object_entry *cached_objects;
size_t cached_object_nr, cached_object_alloc;

/*
* A map of packfiles to packed_git structs for tracking which
* packs have been loaded already.
*/
struct hashmap pack_map;

/*
* A fast, rough count of the number of objects in the repository.
* These two fields are not meant for direct access. Use
* repo_approximate_object_count() instead.
*/
unsigned long approximate_object_count;
unsigned approximate_object_count_valid : 1;

/*
* Whether packed_git has already been populated with this repository's
* packs.
*/
unsigned packed_git_initialized : 1;

/*
* Submodule source paths that will be added as additional sources to
* allow lookup of submodule objects via the main object database.
*/
struct string_list submodule_source_paths;
};

struct object_database *odb_new(struct repository *repo);
void odb_clear(struct object_database *o);

/*
* Find source by its object directory path. Dies in case the source couldn't
* be found.
*/
struct odb_source *odb_find_source(struct object_database *odb, const char *obj_dir);

/*
* Replace the current writable object directory with the specified temporary
* object directory; returns the former primary source.
*/
struct odb_source *odb_set_temporary_primary_source(struct object_database *odb,
const char *dir, int will_destroy);

/*
* Restore the primary source that was previously replaced by
* `odb_set_temporary_primary_source()`.
*/
void odb_restore_primary_source(struct object_database *odb,
struct odb_source *restore_source,
const char *old_path);

/*
* Call odb_add_submodule_source_by_path() to add the submodule at the given
* path to a list. The object stores of all submodules in that list will be
* added as additional sources in the object store when looking up objects.
*/
void odb_add_submodule_source_by_path(struct object_database *odb,
const char *path);

/*
* Iterate through all alternates of the database and execute the provided
* callback function for each of them. Stop iterating once the callback
* function returns a non-zero value, in which case the value is bubbled up
* from the callback.
*/
typedef int odb_for_each_alternate_fn(struct odb_source *, void *);
int odb_for_each_alternate(struct object_database *odb,
odb_for_each_alternate_fn cb, void *payload);

/*
* Iterate through all alternates of the database and yield their respective
* references.
*/
typedef void odb_for_each_alternate_ref_fn(const struct object_id *oid, void *);
void odb_for_each_alternate_ref(struct object_database *odb,
odb_for_each_alternate_ref_fn cb, void *payload);

/*
* Create a temporary file rooted in the primary alternate's directory, or die
* on failure. The filename is taken from "pattern", which should have the
* usual "XXXXXX" trailer, and the resulting filename is written into the
* "template" buffer. Returns the open descriptor.
*/
int odb_mkstemp(struct object_database *odb,
struct strbuf *temp_filename, const char *pattern);

/*
* Prepare alternate object sources for the given database by reading
* "objects/info/alternates" and opening the respective sources.
*/
void odb_prepare_alternates(struct object_database *odb);

/*
* Check whether the object database has any alternates. The primary object
* source does not count as alternate.
*/
int odb_has_alternates(struct object_database *odb);

/*
* Add the directory to the on-disk alternates file; the new entry will also
* take effect in the current process.
*/
void odb_add_to_alternates_file(struct object_database *odb,
const char *dir);

/*
* Add the directory to the in-memory list of alternate sources (along with any
* recursive alternates it points to), but do not modify the on-disk alternates
* file.
*/
void odb_add_to_alternates_memory(struct object_database *odb,
const char *dir);

/*
* Read an object from the database. Returns the object data and assigns object
* type and size to the `type` and `size` pointers, if these pointers are
* non-NULL. Returns a `NULL` pointer in case the object does not exist.
*
* This function dies on corrupt objects; the callers who want to deal with
* them should arrange to call odb_read_object_info_extended() and give error
* messages themselves.
*/
void *odb_read_object(struct object_database *odb,
const struct object_id *oid,
enum object_type *type,
unsigned long *size);

void *odb_read_object_peeled(struct object_database *odb,
const struct object_id *oid,
enum object_type required_type,
unsigned long *size,
struct object_id *oid_ret);

/*
* Add an object file to the in-memory object store, without writing it
* to disk.
*
* Callers are responsible for calling write_object_file to record the
* object in persistent storage before writing any other new objects
* that reference it.
*/
int odb_pretend_object(struct object_database *odb,
void *buf, unsigned long len, enum object_type type,
struct object_id *oid);

struct object_info {
/* Request */
enum object_type *typep;
unsigned long *sizep;
off_t *disk_sizep;
struct object_id *delta_base_oid;
void **contentp;

/* Response */
enum {
OI_CACHED,
OI_LOOSE,
OI_PACKED,
OI_DBCACHED
} whence;
union {
/*
* struct {
* ... Nothing to expose in this case
* } cached;
* struct {
* ... Nothing to expose in this case
* } loose;
*/
struct {
struct packed_git *pack;
off_t offset;
unsigned int is_delta;
} packed;
} u;
};

/*
* Initializer for a "struct object_info" that wants no items. You may
* also memset() the memory to all-zeroes.
*/
#define OBJECT_INFO_INIT { 0 }

/* Invoke lookup_replace_object() on the given hash */
#define OBJECT_INFO_LOOKUP_REPLACE 1
/* Do not retry packed storage after checking packed and loose storage */
#define OBJECT_INFO_QUICK 8
/*
* Do not attempt to fetch the object if missing (even if fetch_is_missing is
* nonzero).
*/
#define OBJECT_INFO_SKIP_FETCH_OBJECT 16
/*
* This is meant for bulk prefetching of missing blobs in a partial
* clone. Implies OBJECT_INFO_SKIP_FETCH_OBJECT and OBJECT_INFO_QUICK
*/
#define OBJECT_INFO_FOR_PREFETCH (OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK)

/* Die if object corruption (not just an object being missing) was detected. */
#define OBJECT_INFO_DIE_IF_CORRUPT 32

/*
* Read object info from the object database and populate the `object_info`
* structure. Returns 0 on success, a negative error code otherwise.
*/
int odb_read_object_info_extended(struct object_database *odb,
const struct object_id *oid,
struct object_info *oi,
unsigned flags);

/*
* Read a subset of object info for the given object ID. Returns an `enum
* object_type` on success, a negative error code otherwise. If successful and
* `sizep` is non-NULL, then the size of the object will be written to the
* pointer.
*/
int odb_read_object_info(struct object_database *odb,
const struct object_id *oid,
unsigned long *sizep);

enum {
/* Retry packed storage after checking packed and loose storage */
HAS_OBJECT_RECHECK_PACKED = (1 << 0),
/* Allow fetching the object in case the repository has a promisor remote. */
HAS_OBJECT_FETCH_PROMISOR = (1 << 1),
};

/*
* Returns 1 if the object exists. This function will not lazily fetch objects
* in a partial clone by default.
*/
int odb_has_object(struct object_database *odb,
const struct object_id *oid,
unsigned flags);

void odb_assert_oid_type(struct object_database *odb,
const struct object_id *oid, enum object_type expect);

/*
* Enabling the object read lock allows multiple threads to safely call the
* following functions in parallel: odb_read_object(),
* odb_read_object_peeled(), odb_read_object_info() and odb().
*
* obj_read_lock() and obj_read_unlock() may also be used to protect other
* section which cannot execute in parallel with object reading. Since the used
* lock is a recursive mutex, these sections can even contain calls to object
* reading functions. However, beware that in these cases zlib inflation won't
* be performed in parallel, losing performance.
*
* TODO: odb_read_object_info_extended()'s call stack has a recursive behavior. If
* any of its callees end up calling it, this recursive call won't benefit from
* parallel inflation.
*/
void enable_obj_read_lock(void);
void disable_obj_read_lock(void);

extern int obj_read_use_lock;
extern pthread_mutex_t obj_read_mutex;

static inline void obj_read_lock(void)
{
if(obj_read_use_lock)
pthread_mutex_lock(&obj_read_mutex);
}

static inline void obj_read_unlock(void)
{
if(obj_read_use_lock)
pthread_mutex_unlock(&obj_read_mutex);
}
/* Flags for for_each_*_object(). */
enum for_each_object_flags {
/* Iterate only over local objects, not alternates. */
FOR_EACH_OBJECT_LOCAL_ONLY = (1<<0),

/* Only iterate over packs obtained from the promisor remote. */
FOR_EACH_OBJECT_PROMISOR_ONLY = (1<<1),

/*
* Visit objects within a pack in packfile order rather than .idx order
*/
FOR_EACH_OBJECT_PACK_ORDER = (1<<2),

/* Only iterate over packs that are not marked as kept in-core. */
FOR_EACH_OBJECT_SKIP_IN_CORE_KEPT_PACKS = (1<<3),

/* Only iterate over packs that do not have .keep files. */
FOR_EACH_OBJECT_SKIP_ON_DISK_KEPT_PACKS = (1<<4),
};

/* Compatibility wrappers, to be removed once Git 2.51 has been released. */
#include "repository.h"

static inline int oid_object_info_extended(struct repository *r,
const struct object_id *oid,
struct object_info *oi,
unsigned flags)
{
return odb_read_object_info_extended(r->objects, oid, oi, flags);
}

static inline int oid_object_info(struct repository *r,
const struct object_id *oid,
unsigned long *sizep)
{
return odb_read_object_info(r->objects, oid, sizep);
}

static inline void *repo_read_object_file(struct repository *r,
const struct object_id *oid,
enum object_type *type,
unsigned long *size)
{
return odb_read_object(r->objects, oid, type, size);
}

static inline int has_object(struct repository *r,
const struct object_id *oid,
unsigned flags)
{
return odb_has_object(r->objects, oid, flags);
}

#endif /* ODB_H */

View File

@ -1,5 +1,5 @@
#include "git-compat-util.h"
#include "object-store.h"
#include "odb.h"
#include "packfile.h"

int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);

View File

@ -4,7 +4,7 @@
#include "environment.h"
#include "gettext.h"
#include "hex.h"
#include "object-store.h"
#include "odb.h"
#include "commit.h"
#include "diff.h"
#include "revision.h"
@ -144,7 +144,7 @@ void bitmap_writer_build_type_index(struct bitmap_writer *writer,
break;

default:
real_type = oid_object_info(writer->to_pack->repo,
real_type = odb_read_object_info(writer->to_pack->repo->objects,
&entry->idx.oid, NULL);
break;
}
@ -1052,7 +1052,8 @@ void bitmap_writer_finish(struct bitmap_writer *writer,

struct bitmap_disk_header header;

int fd = odb_mkstemp(&tmp_file, "pack/tmp_bitmap_XXXXXX");
int fd = odb_mkstemp(writer->repo->objects, &tmp_file,
"pack/tmp_bitmap_XXXXXX");

if (writer->pseudo_merges_nr)
options |= BITMAP_OPT_PSEUDO_MERGES;

View File

@ -17,7 +17,7 @@
#include "packfile.h"
#include "repository.h"
#include "trace2.h"
#include "object-store.h"
#include "odb.h"
#include "list-objects-filter-options.h"
#include "midx.h"
#include "config.h"
@ -1868,7 +1868,7 @@ static unsigned long get_size_by_pos(struct bitmap_index *bitmap_git,
size_t eindex_pos = pos - bitmap_num_objects_total(bitmap_git);
struct eindex *eindex = &bitmap_git->ext_index;
struct object *obj = eindex->objects[eindex_pos];
if (oid_object_info_extended(bitmap_repo(bitmap_git), &obj->oid,
if (odb_read_object_info_extended(bitmap_repo(bitmap_git)->objects, &obj->oid,
&oi, 0) < 0)
die(_("unable to get size of %s"), oid_to_hex(&obj->oid));
}
@ -3220,8 +3220,8 @@ static off_t get_disk_usage_for_extended(struct bitmap_index *bitmap_git)
i)))
continue;

if (oid_object_info_extended(bitmap_repo(bitmap_git), &obj->oid,
&oi, 0) < 0)
if (odb_read_object_info_extended(bitmap_repo(bitmap_git)->objects,
&obj->oid, &oi, 0) < 0)
die(_("unable to get disk usage of '%s'"),
oid_to_hex(&obj->oid));


View File

@ -8,7 +8,7 @@
#include "progress.h"
#include "packfile.h"
#include "object-file.h"
#include "object-store.h"
#include "odb.h"

struct idx_entry {
off_t offset;

View File

@ -1,7 +1,7 @@
#include "git-compat-util.h"
#include "gettext.h"
#include "pack-mtimes.h"
#include "object-store.h"
#include "odb.h"
#include "packfile.h"
#include "strbuf.h"


View File

@ -1,7 +1,7 @@
#ifndef PACK_OBJECTS_H
#define PACK_OBJECTS_H

#include "object-store.h"
#include "odb.h"
#include "thread-utils.h"
#include "pack.h"
#include "packfile.h"

View File

@ -1,7 +1,7 @@
#include "git-compat-util.h"
#include "gettext.h"
#include "pack-revindex.h"
#include "object-store.h"
#include "odb.h"
#include "packfile.h"
#include "strbuf.h"
#include "trace2.h"

Some files were not shown because too many files have changed in this diff Show More