mirror of
https://github.com/git/git.git
synced 2025-12-12 20:36:24 +01:00
odb: rename oid_object_info()
Rename `oid_object_info()` to `odb_read_object_info()` as well as their `_extended()` variant to match other functions related to the object database and our modern coding guidelines. Introduce compatibility wrappers 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>
This commit is contained in:
committed by
Junio C Hamano
parent
16cf749496
commit
e989dd96b8
@@ -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
blame.c
4
blame.c
@@ -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;
|
||||
}
|
||||
|
||||
@@ -1245,7 +1245,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:
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)) {
|
||||
@@ -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);
|
||||
|
||||
@@ -217,7 +217,8 @@ 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) {
|
||||
if (odb_read_object_info(the_repository->objects,
|
||||
&oid, NULL) == OBJ_TAG) {
|
||||
char *buffer = repo_read_object_file(the_repository,
|
||||
&oid,
|
||||
&type,
|
||||
@@ -235,7 +236,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;
|
||||
}
|
||||
@@ -294,7 +296,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;
|
||||
@@ -484,12 +486,12 @@ 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,
|
||||
&data->oid, &data->info,
|
||||
OBJECT_INFO_LOOKUP_REPLACE);
|
||||
ret = odb_read_object_info_extended(the_repository->objects,
|
||||
&data->oid, &data->info,
|
||||
OBJECT_INFO_LOOKUP_REPLACE);
|
||||
if (ret < 0) {
|
||||
report_object_status(opt, obj_name, &data->oid, "missing");
|
||||
return;
|
||||
@@ -872,7 +874,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.
|
||||
*/
|
||||
memset(&data, 0, sizeof(data));
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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));
|
||||
|
||||
|
||||
@@ -1756,8 +1756,8 @@ 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,
|
||||
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));
|
||||
e = insert_object(oid);
|
||||
@@ -2416,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",
|
||||
@@ -2553,7 +2553,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);
|
||||
@@ -2895,7 +2895,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
|
||||
@@ -3085,8 +3086,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! */
|
||||
|
||||
@@ -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)
|
||||
@@ -232,8 +233,8 @@ 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,
|
||||
&obj->oid, NULL);
|
||||
enum object_type type = odb_read_object_info(the_repository->objects,
|
||||
&obj->oid, NULL);
|
||||
if (type > 0)
|
||||
object_as_type(obj, type, 0);
|
||||
}
|
||||
|
||||
@@ -1080,7 +1080,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);
|
||||
|
||||
@@ -520,7 +520,7 @@ 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,
|
||||
|
||||
@@ -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));
|
||||
@@ -908,7 +909,7 @@ 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)
|
||||
@@ -1501,9 +1502,9 @@ 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,
|
||||
OBJECT_INFO_FOR_PREFETCH))
|
||||
if (!odb_read_object_info_extended(the_repository->objects,
|
||||
&d->oid, NULL,
|
||||
OBJECT_INFO_FOR_PREFETCH))
|
||||
continue;
|
||||
oid_array_append(&to_fetch, &d->oid);
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -124,10 +124,10 @@ 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,
|
||||
OBJECT_INFO_LOOKUP_REPLACE |
|
||||
OBJECT_INFO_QUICK |
|
||||
OBJECT_INFO_SKIP_FETCH_OBJECT) < 0)
|
||||
if (odb_read_object_info_extended(the_repository->objects, &oid, &oi,
|
||||
OBJECT_INFO_LOOKUP_REPLACE |
|
||||
OBJECT_INFO_QUICK |
|
||||
OBJECT_INFO_SKIP_FETCH_OBJECT) < 0)
|
||||
obj_type = -1;
|
||||
|
||||
if (obj_type < 0) {
|
||||
|
||||
@@ -2154,10 +2154,10 @@ 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,
|
||||
&entry->idx.oid,
|
||||
NULL,
|
||||
OBJECT_INFO_FOR_PREFETCH))
|
||||
if (!odb_read_object_info_extended(the_repository->objects,
|
||||
&entry->idx.oid,
|
||||
NULL,
|
||||
OBJECT_INFO_FOR_PREFETCH))
|
||||
continue;
|
||||
oid_array_append(&to_fetch, &entry->idx.oid);
|
||||
}
|
||||
@@ -2298,19 +2298,19 @@ 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,
|
||||
OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0) {
|
||||
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,
|
||||
OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0)
|
||||
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 {
|
||||
type = -1;
|
||||
@@ -2384,12 +2384,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);
|
||||
}
|
||||
@@ -2677,7 +2678,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);
|
||||
@@ -4063,7 +4065,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);
|
||||
@@ -4449,7 +4451,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;
|
||||
}
|
||||
|
||||
@@ -99,8 +99,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(the_repository, oid,
|
||||
NULL);
|
||||
enum object_type type = odb_read_object_info(the_repository->objects,
|
||||
oid, NULL);
|
||||
printf("%s %s\n", oid_to_hex(oid),
|
||||
(type > 0) ? type_name(type) : "unknown");
|
||||
}
|
||||
|
||||
@@ -707,7 +707,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 ? "+" : "",
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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,7 +401,7 @@ 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");
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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));
|
||||
|
||||
3
commit.c
3
commit.c
@@ -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));
|
||||
|
||||
18
diff.c
18
diff.c
@@ -4230,14 +4230,14 @@ 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,
|
||||
OBJECT_INFO_LOOKUP_REPLACE |
|
||||
OBJECT_INFO_SKIP_FETCH_OBJECT))
|
||||
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,
|
||||
OBJECT_INFO_LOOKUP_REPLACE))
|
||||
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));
|
||||
|
||||
object_read:
|
||||
@@ -4252,8 +4252,8 @@ object_read:
|
||||
}
|
||||
if (!info.contentp) {
|
||||
info.contentp = &s->data;
|
||||
if (oid_object_info_extended(r, &s->oid, &info,
|
||||
OBJECT_INFO_LOOKUP_REPLACE))
|
||||
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));
|
||||
}
|
||||
s->should_free = 1;
|
||||
@@ -7019,8 +7019,8 @@ 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,
|
||||
OBJECT_INFO_FOR_PREFETCH))
|
||||
odb_read_object_info_extended(r->objects, &filespec->oid, NULL,
|
||||
OBJECT_INFO_FOR_PREFETCH))
|
||||
oid_array_append(to_fetch, &filespec->oid);
|
||||
}
|
||||
|
||||
|
||||
@@ -149,8 +149,8 @@ static struct commit *deref_without_lazy_fetch(const struct object_id *oid,
|
||||
}
|
||||
|
||||
while (1) {
|
||||
if (oid_object_info_extended(the_repository, oid, &info,
|
||||
OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK))
|
||||
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) {
|
||||
struct tag *tag = (struct tag *)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -4385,8 +4385,8 @@ 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,
|
||||
OBJECT_INFO_FOR_PREFETCH))
|
||||
odb_read_object_info_extended(opt->repo->objects, &vi->oid, NULL,
|
||||
OBJECT_INFO_FOR_PREFETCH))
|
||||
oid_array_append(&to_fetch, &vi->oid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
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.
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
6
object.c
6
object.c
@@ -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,7 +331,7 @@ 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;
|
||||
}
|
||||
|
||||
|
||||
60
odb.c
60
odb.c
@@ -647,7 +647,7 @@ static int register_all_submodule_sources(struct object_database *odb)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int do_oid_object_info_extended(struct repository *r,
|
||||
static int do_oid_object_info_extended(struct object_database *odb,
|
||||
const struct object_id *oid,
|
||||
struct object_info *oi, unsigned flags)
|
||||
{
|
||||
@@ -660,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;
|
||||
@@ -668,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;
|
||||
@@ -677,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, r->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;
|
||||
@@ -685,17 +685,17 @@ 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;
|
||||
}
|
||||
|
||||
@@ -705,15 +705,15 @@ static int do_oid_object_info_extended(struct repository *r,
|
||||
* `odb_add_submodule_source_by_path()` on that submodule's
|
||||
* ODB). If any such ODBs exist, register them and try again.
|
||||
*/
|
||||
if (register_all_submodule_sources(r->objects))
|
||||
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;
|
||||
}
|
||||
@@ -723,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);
|
||||
}
|
||||
@@ -736,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;
|
||||
@@ -787,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)
|
||||
@@ -830,33 +830,35 @@ 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,
|
||||
const struct object_id *oid,
|
||||
unsigned long *sizep)
|
||||
int odb_read_object_info(struct object_database *odb,
|
||||
const struct object_id *oid,
|
||||
unsigned long *sizep)
|
||||
{
|
||||
enum object_type type;
|
||||
struct object_info oi = OBJECT_INFO_INIT;
|
||||
|
||||
oi.typep = &type;
|
||||
oi.sizep = sizep;
|
||||
if (oid_object_info_extended(r, oid, &oi,
|
||||
OBJECT_INFO_LOOKUP_REPLACE) < 0)
|
||||
if (odb_read_object_info_extended(odb, oid, &oi,
|
||||
OBJECT_INFO_LOOKUP_REPLACE) < 0)
|
||||
return -1;
|
||||
return type;
|
||||
}
|
||||
@@ -887,7 +889,7 @@ int pretend_object_file(struct repository *repo,
|
||||
|
||||
/*
|
||||
* This function dies on corrupt objects; the callers who want to
|
||||
* deal with them should arrange to call oid_object_info_extended() and give
|
||||
* 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,
|
||||
@@ -902,7 +904,7 @@ 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(r->objects, oid, &oi, flags))
|
||||
return NULL;
|
||||
|
||||
return data;
|
||||
@@ -968,13 +970,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(r->objects, oid, NULL, object_info_flags) >= 0;
|
||||
}
|
||||
|
||||
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(odb->repo, 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)
|
||||
|
||||
46
odb.h
46
odb.h
@@ -265,9 +265,6 @@ void *repo_read_object_file(struct repository *r,
|
||||
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.
|
||||
@@ -336,9 +333,24 @@ struct object_info {
|
||||
/* 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);
|
||||
/*
|
||||
* 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 */
|
||||
@@ -360,7 +372,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(),
|
||||
* read_object_with_reference(), oid_object_info() and oid_object_info_extended().
|
||||
* read_object_with_reference(), 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
|
||||
@@ -368,7 +380,7 @@ void odb_assert_oid_type(struct object_database *odb,
|
||||
* 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
|
||||
* 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.
|
||||
*/
|
||||
@@ -416,4 +428,22 @@ void *read_object_with_reference(struct repository *r,
|
||||
unsigned long *size,
|
||||
struct object_id *oid_ret);
|
||||
|
||||
/* 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);
|
||||
}
|
||||
|
||||
#endif /* ODB_H */
|
||||
|
||||
@@ -144,8 +144,8 @@ void bitmap_writer_build_type_index(struct bitmap_writer *writer,
|
||||
break;
|
||||
|
||||
default:
|
||||
real_type = oid_object_info(writer->to_pack->repo,
|
||||
&entry->idx.oid, NULL);
|
||||
real_type = odb_read_object_info(writer->to_pack->repo->objects,
|
||||
&entry->idx.oid, NULL);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -1868,8 +1868,8 @@ 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,
|
||||
&oi, 0) < 0)
|
||||
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));
|
||||
|
||||
|
||||
@@ -1321,7 +1321,7 @@ static int retry_bad_packed_offset(struct repository *r,
|
||||
return OBJ_BAD;
|
||||
nth_packed_object_id(&oid, p, pack_pos_to_index(p, pos));
|
||||
mark_bad_packed_object(p, &oid);
|
||||
type = oid_object_info(r, &oid, NULL);
|
||||
type = odb_read_object_info(r->objects, &oid, NULL);
|
||||
if (type <= OBJ_NONE)
|
||||
return OBJ_BAD;
|
||||
return type;
|
||||
@@ -1849,7 +1849,8 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
|
||||
oi.typep = &type;
|
||||
oi.sizep = &base_size;
|
||||
oi.contentp = &base;
|
||||
if (oid_object_info_extended(r, &base_oid, &oi, 0) < 0)
|
||||
if (odb_read_object_info_extended(r->objects, &base_oid,
|
||||
&oi, 0) < 0)
|
||||
base = NULL;
|
||||
|
||||
external_base = base;
|
||||
|
||||
@@ -245,8 +245,8 @@ static int remove_fetched_oids(struct repository *repo,
|
||||
struct object_id *new_oids;
|
||||
|
||||
for (i = 0; i < oid_nr; i++)
|
||||
if (oid_object_info_extended(repo, &old_oids[i], NULL,
|
||||
OBJECT_INFO_SKIP_FETCH_OBJECT)) {
|
||||
if (odb_read_object_info_extended(repo->objects, &old_oids[i], NULL,
|
||||
OBJECT_INFO_SKIP_FETCH_OBJECT)) {
|
||||
remaining[i] = 1;
|
||||
remaining_nr++;
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ static void send_info(struct repository *r, struct packet_writer *writer,
|
||||
strbuf_addstr(&send_buffer, oid_str);
|
||||
|
||||
if (info->size) {
|
||||
if (oid_object_info(r, &oid, &object_size) < 0) {
|
||||
if (odb_read_object_info(r->objects, &oid, &object_size) < 0) {
|
||||
strbuf_addstr(&send_buffer, " ");
|
||||
} else {
|
||||
strbuf_addf(&send_buffer, " %lu", object_size);
|
||||
|
||||
@@ -211,7 +211,7 @@ static void add_recent_object(const struct object_id *oid,
|
||||
* later processing, and the revision machinery expects
|
||||
* commits and tags to have been parsed.
|
||||
*/
|
||||
type = oid_object_info(the_repository, oid, NULL);
|
||||
type = odb_read_object_info(the_repository->objects, oid, NULL);
|
||||
if (type < 0)
|
||||
die("unable to get object info for %s", oid_to_hex(oid));
|
||||
|
||||
|
||||
@@ -3729,9 +3729,9 @@ void prefetch_cache_entries(const struct index_state *istate,
|
||||
|
||||
if (S_ISGITLINK(ce->ce_mode) || !must_prefetch(ce))
|
||||
continue;
|
||||
if (!oid_object_info_extended(the_repository, &ce->oid,
|
||||
NULL,
|
||||
OBJECT_INFO_FOR_PREFETCH))
|
||||
if (!odb_read_object_info_extended(the_repository->objects,
|
||||
&ce->oid, NULL,
|
||||
OBJECT_INFO_FOR_PREFETCH))
|
||||
continue;
|
||||
oid_array_append(&to_fetch, &ce->oid);
|
||||
}
|
||||
|
||||
@@ -2302,8 +2302,8 @@ static int get_object(struct ref_array_item *ref, int deref, struct object **obj
|
||||
oi->info.sizep = &oi->size;
|
||||
oi->info.typep = &oi->type;
|
||||
}
|
||||
if (oid_object_info_extended(the_repository, &oi->oid, &oi->info,
|
||||
OBJECT_INFO_LOOKUP_REPLACE))
|
||||
if (odb_read_object_info_extended(the_repository->objects, &oi->oid, &oi->info,
|
||||
OBJECT_INFO_LOOKUP_REPLACE))
|
||||
return strbuf_addf_ret(err, -1, _("missing object %s for %s"),
|
||||
oid_to_hex(&oi->oid), ref->refname);
|
||||
if (oi->info.disk_sizep && oi->disk_size < 0)
|
||||
|
||||
5
remote.c
5
remote.c
@@ -1182,7 +1182,7 @@ static void show_push_unqualified_ref_name_error(const char *dst_value,
|
||||
BUG("'%s' is not a valid object, "
|
||||
"match_explicit_lhs() should catch this!",
|
||||
matched_src_name);
|
||||
type = oid_object_info(the_repository, &oid, NULL);
|
||||
type = odb_read_object_info(the_repository->objects, &oid, NULL);
|
||||
if (type == OBJ_COMMIT) {
|
||||
advise(_("The <src> part of the refspec is a commit object.\n"
|
||||
"Did you mean to create a new branch by pushing to\n"
|
||||
@@ -1412,7 +1412,8 @@ static void add_missing_tags(struct ref *src, struct ref **dst, struct ref ***ds
|
||||
continue; /* not a tag */
|
||||
if (string_list_has_string(&dst_tag, ref->name))
|
||||
continue; /* they already have it */
|
||||
if (oid_object_info(the_repository, &ref->new_oid, NULL) != OBJ_TAG)
|
||||
if (odb_read_object_info(the_repository->objects,
|
||||
&ref->new_oid, NULL) != OBJ_TAG)
|
||||
continue; /* be conservative */
|
||||
item = string_list_append(&src_tag, ref->name);
|
||||
item->util = ref;
|
||||
|
||||
@@ -5503,9 +5503,8 @@ int sequencer_pick_revisions(struct repository *r,
|
||||
|
||||
if (!repo_get_oid(r, name, &oid)) {
|
||||
if (!lookup_commit_reference_gently(r, &oid, 1)) {
|
||||
enum object_type type = oid_object_info(r,
|
||||
&oid,
|
||||
NULL);
|
||||
enum object_type type = odb_read_object_info(r->objects,
|
||||
&oid, NULL);
|
||||
res = error(_("%s: can't cherry-pick a %s"),
|
||||
name, type_name(type));
|
||||
goto out;
|
||||
|
||||
@@ -44,7 +44,7 @@ struct git_istream {
|
||||
|
||||
union {
|
||||
struct {
|
||||
char *buf; /* from oid_object_info_extended() */
|
||||
char *buf; /* from odb_read_object_info_extended() */
|
||||
unsigned long read_ptr;
|
||||
} incore;
|
||||
|
||||
@@ -403,8 +403,8 @@ static int open_istream_incore(struct git_istream *st, struct repository *r,
|
||||
oi.typep = type;
|
||||
oi.sizep = &st->size;
|
||||
oi.contentp = (void **)&st->u.incore.buf;
|
||||
return oid_object_info_extended(r, oid, &oi,
|
||||
OBJECT_INFO_DIE_IF_CORRUPT);
|
||||
return odb_read_object_info_extended(r->objects, oid, &oi,
|
||||
OBJECT_INFO_DIE_IF_CORRUPT);
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
@@ -422,7 +422,7 @@ static int istream_source(struct git_istream *st,
|
||||
|
||||
oi.typep = type;
|
||||
oi.sizep = &size;
|
||||
status = oid_object_info_extended(r, oid, &oi, 0);
|
||||
status = odb_read_object_info_extended(r->objects, oid, &oi, 0);
|
||||
if (status < 0)
|
||||
return status;
|
||||
|
||||
|
||||
@@ -968,7 +968,7 @@ static int check_has_commit(const struct object_id *oid, void *data)
|
||||
return 0;
|
||||
}
|
||||
|
||||
type = oid_object_info(&subrepo, oid, NULL);
|
||||
type = odb_read_object_info(subrepo.objects, oid, NULL);
|
||||
|
||||
switch (type) {
|
||||
case OBJ_COMMIT:
|
||||
@@ -1752,8 +1752,7 @@ static int fetch_start_failure(struct strbuf *err UNUSED,
|
||||
static int commit_missing_in_sub(const struct object_id *oid, void *data)
|
||||
{
|
||||
struct repository *subrepo = data;
|
||||
|
||||
enum object_type type = oid_object_info(subrepo, oid, NULL);
|
||||
enum object_type type = odb_read_object_info(subrepo->objects, oid, NULL);
|
||||
|
||||
return type != OBJ_COMMIT;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ static void object_info(const char *gitdir, const char *oid_hex)
|
||||
die("could not init repo");
|
||||
if (parse_oid_hex_algop(oid_hex, &oid, &p, r.hash_algo))
|
||||
die("could not parse oid");
|
||||
if (oid_object_info_extended(&r, &oid, &oi, 0))
|
||||
if (odb_read_object_info_extended(r.objects, &oid, &oi, 0))
|
||||
die("could not obtain object info");
|
||||
printf("%d\n", (int) size);
|
||||
|
||||
|
||||
2
tag.c
2
tag.c
@@ -52,7 +52,7 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,
|
||||
unsigned long size;
|
||||
int ret;
|
||||
|
||||
type = oid_object_info(the_repository, oid, NULL);
|
||||
type = odb_read_object_info(the_repository->objects, oid, NULL);
|
||||
if (type != OBJ_TAG)
|
||||
return error("%s: cannot verify a non-tag object of type %s.",
|
||||
name_to_report ?
|
||||
|
||||
Reference in New Issue
Block a user