odb: rename `repo_read_object_file()`
Rename `repo_read_object_file()` to `odb_read_object()` to match other functions related to the object database and our modern coding guidelines. Introduce a compatibility wrapper so that any in-flight topics will continue to compile. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
e989dd96b8
commit
d4ff88aee3
10
apply.c
10
apply.c
|
@ -3210,8 +3210,8 @@ static int apply_binary(struct apply_state *state,
|
|||
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);
|
||||
|
|
|
@ -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;
|
||||
|
|
2
attr.c
2
attr.c
|
@ -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;
|
||||
|
|
2
bisect.c
2
bisect.c
|
@ -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;
|
||||
|
|
7
blame.c
7
blame.c
|
@ -1041,7 +1041,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;
|
||||
|
@ -2869,9 +2869,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)
|
||||
|
|
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -219,10 +219,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
|
|||
struct object_id blob_oid;
|
||||
if (odb_read_object_info(the_repository->objects,
|
||||
&oid, NULL) == OBJ_TAG) {
|
||||
char *buffer = repo_read_object_file(the_repository,
|
||||
&oid,
|
||||
&type,
|
||||
&size);
|
||||
char *buffer = odb_read_object(the_repository->objects,
|
||||
&oid, &type, &size);
|
||||
const char *target;
|
||||
|
||||
if (!buffer)
|
||||
|
@ -403,10 +401,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);
|
||||
|
@ -423,8 +419,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));
|
||||
|
||||
|
@ -533,8 +529,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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -1265,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));
|
||||
}
|
||||
|
@ -3002,7 +3002,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);
|
||||
|
@ -3110,8 +3110,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));
|
||||
|
|
|
@ -573,7 +573,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));
|
||||
|
@ -666,7 +666,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)"),
|
||||
|
|
|
@ -914,7 +914,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
|
|||
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)
|
||||
|
@ -1521,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;
|
||||
|
||||
|
|
|
@ -714,7 +714,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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -337,11 +337,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)
|
||||
|
@ -506,7 +506,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)
|
||||
|
@ -1895,7 +1895,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) {
|
||||
|
@ -2762,7 +2762,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);
|
||||
|
@ -2777,7 +2777,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);
|
||||
|
|
|
@ -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)) {
|
||||
|
@ -407,7 +407,7 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb)
|
|||
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 {
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
|
@ -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));
|
||||
|
|
2
bundle.c
2
bundle.c
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
6
commit.c
6
commit.c
|
@ -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));
|
||||
|
@ -1275,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))
|
||||
|
|
2
config.c
2
config.c
|
@ -1942,7 +1942,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) {
|
||||
|
|
2
dir.c
2
dir.c
|
@ -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;
|
||||
|
|
2
entry.c
2
entry.c
|
@ -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;
|
||||
|
|
|
@ -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 };
|
||||
|
|
2
fsck.c
2
fsck.c
|
@ -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;
|
||||
|
|
4
grep.c
4
grep.c
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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",
|
||||
|
|
9
notes.c
9
notes.c
|
@ -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;
|
||||
}
|
||||
|
|
2
object.c
2
object.c
|
@ -335,7 +335,7 @@ struct object *parse_object_with_flags(struct repository *r,
|
|||
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) {
|
||||
|
|
13
odb.c
13
odb.c
|
@ -30,7 +30,7 @@ KHASH_INIT(odb_path_map, const char * /* key: odb_path */,
|
|||
|
||||
/*
|
||||
* 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).
|
||||
*/
|
||||
|
@ -887,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 odb_read_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)
|
||||
|
@ -904,7 +899,7 @@ void *repo_read_object_file(struct repository *r,
|
|||
oi.typep = type;
|
||||
oi.sizep = size;
|
||||
oi.contentp = &data;
|
||||
if (odb_read_object_info_extended(r->objects, oid, &oi, flags))
|
||||
if (odb_read_object_info_extended(odb, oid, &oi, flags))
|
||||
return NULL;
|
||||
|
||||
return data;
|
||||
|
@ -926,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(r->objects, &actual_oid, &type, &isize);
|
||||
if (!buffer)
|
||||
return NULL;
|
||||
if (type == required_type) {
|
||||
|
|
23
odb.h
23
odb.h
|
@ -140,7 +140,7 @@ struct object_database {
|
|||
|
||||
/*
|
||||
* 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).
|
||||
*/
|
||||
|
@ -260,7 +260,16 @@ void odb_add_to_alternates_file(struct object_database *odb,
|
|||
void odb_add_to_alternates_memory(struct object_database *odb,
|
||||
const char *dir);
|
||||
|
||||
void *repo_read_object_file(struct repository *r,
|
||||
/*
|
||||
* 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);
|
||||
|
@ -371,7 +380,7 @@ void odb_assert_oid_type(struct object_database *odb,
|
|||
|
||||
/*
|
||||
* Enabling the object read lock allows multiple threads to safely call the
|
||||
* following functions in parallel: repo_read_object_file(),
|
||||
* following functions in parallel: odb_read_object(),
|
||||
* read_object_with_reference(), odb_read_object_info() and odb().
|
||||
*
|
||||
* obj_read_lock() and obj_read_unlock() may also be used to protect other
|
||||
|
@ -446,4 +455,12 @@ static inline int oid_object_info(struct repository *r,
|
|||
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);
|
||||
}
|
||||
|
||||
#endif /* ODB_H */
|
||||
|
|
|
@ -254,7 +254,7 @@ static int ce_compare_link(const struct cache_entry *ce, size_t expected_size)
|
|||
if (strbuf_readlink(&sb, ce->name, expected_size))
|
||||
return -1;
|
||||
|
||||
buffer = repo_read_object_file(the_repository, &ce->oid, &type, &size);
|
||||
buffer = odb_read_object(the_repository->objects, &ce->oid, &type, &size);
|
||||
if (buffer) {
|
||||
if (size == sb.len)
|
||||
match = memcmp(buffer, sb.buf, size);
|
||||
|
@ -3485,7 +3485,7 @@ void *read_blob_data_from_index(struct index_state *istate,
|
|||
}
|
||||
if (pos < 0)
|
||||
return NULL;
|
||||
data = repo_read_object_file(the_repository, &istate->cache[pos]->oid,
|
||||
data = odb_read_object(the_repository->objects, &istate->cache[pos]->oid,
|
||||
&type, &sz);
|
||||
if (!data || type != OBJ_BLOB) {
|
||||
free(data);
|
||||
|
|
4
reflog.c
4
reflog.c
|
@ -140,8 +140,8 @@ static int tree_is_complete(const struct object_id *oid)
|
|||
if (!tree->buffer) {
|
||||
enum object_type type;
|
||||
unsigned long size;
|
||||
void *data = repo_read_object_file(the_repository, oid, &type,
|
||||
&size);
|
||||
void *data = odb_read_object(the_repository->objects, oid,
|
||||
&type, &size);
|
||||
if (!data) {
|
||||
tree->object.flags |= INCOMPLETE;
|
||||
return 0;
|
||||
|
|
5
rerere.c
5
rerere.c
|
@ -1000,9 +1000,8 @@ static int handle_cache(struct index_state *istate,
|
|||
break;
|
||||
i = ce_stage(ce) - 1;
|
||||
if (!mmfile[i].ptr) {
|
||||
mmfile[i].ptr = repo_read_object_file(the_repository,
|
||||
&ce->oid, &type,
|
||||
&size);
|
||||
mmfile[i].ptr = odb_read_object(the_repository->objects,
|
||||
&ce->oid, &type, &size);
|
||||
if (!mmfile[i].ptr)
|
||||
die(_("unable to read %s"),
|
||||
oid_to_hex(&ce->oid));
|
||||
|
|
|
@ -743,8 +743,8 @@ static const struct submodule *config_from(struct submodule_cache *cache,
|
|||
if (submodule)
|
||||
goto out;
|
||||
|
||||
config = repo_read_object_file(the_repository, &oid, &type,
|
||||
&config_size);
|
||||
config = odb_read_object(the_repository->objects, &oid,
|
||||
&type, &config_size);
|
||||
if (!config || type != OBJ_BLOB)
|
||||
goto out;
|
||||
|
||||
|
|
6
tag.c
6
tag.c
|
@ -60,7 +60,7 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,
|
|||
repo_find_unique_abbrev(the_repository, oid, DEFAULT_ABBREV),
|
||||
type_name(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("%s: unable to read file.",
|
||||
name_to_report ?
|
||||
|
@ -222,8 +222,8 @@ int parse_tag(struct tag *item)
|
|||
|
||||
if (item->object.parsed)
|
||||
return 0;
|
||||
data = repo_read_object_file(the_repository, &item->object.oid, &type,
|
||||
&size);
|
||||
data = odb_read_object(the_repository->objects, &item->object.oid,
|
||||
&type, &size);
|
||||
if (!data)
|
||||
return error("Could not read %s",
|
||||
oid_to_hex(&item->object.oid));
|
||||
|
|
|
@ -795,7 +795,7 @@ enum get_oid_result get_tree_entry_follow_symlinks(struct repository *r,
|
|||
*/
|
||||
retval = DANGLING_SYMLINK;
|
||||
|
||||
contents = repo_read_object_file(r,
|
||||
contents = odb_read_object(r->objects,
|
||||
¤t_tree_oid, &type,
|
||||
&link_len);
|
||||
|
||||
|
|
2
tree.c
2
tree.c
|
@ -193,7 +193,7 @@ int parse_tree_gently(struct tree *item, int quiet_on_missing)
|
|||
|
||||
if (item->object.parsed)
|
||||
return 0;
|
||||
buffer = repo_read_object_file(the_repository, &item->object.oid,
|
||||
buffer = odb_read_object(the_repository->objects, &item->object.oid,
|
||||
&type, &size);
|
||||
if (!buffer)
|
||||
return quiet_on_missing ? -1 :
|
||||
|
|
|
@ -187,7 +187,7 @@ void read_mmblob(mmfile_t *ptr, const struct object_id *oid)
|
|||
return;
|
||||
}
|
||||
|
||||
ptr->ptr = repo_read_object_file(the_repository, oid, &type, &size);
|
||||
ptr->ptr = odb_read_object(the_repository->objects, oid, &type, &size);
|
||||
if (!ptr->ptr || type != OBJ_BLOB)
|
||||
die("unable to read blob object %s", oid_to_hex(oid));
|
||||
ptr->size = size;
|
||||
|
|
Loading…
Reference in New Issue