]> git.ipfire.org Git - thirdparty/git.git/commitdiff
odb: rename `has_object()`
authorPatrick Steinhardt <ps@pks.im>
Thu, 5 Jun 2025 06:47:05 +0000 (08:47 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 5 Jun 2025 15:52:02 +0000 (08:52 -0700)
Rename `has_object()` to `odb_has_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>
30 files changed:
apply.c
builtin/backfill.c
builtin/cat-file.c
builtin/clone.c
builtin/fetch.c
builtin/fsck.c
builtin/index-pack.c
builtin/pack-objects.c
builtin/receive-pack.c
builtin/remote.c
builtin/show-ref.c
builtin/unpack-objects.c
bulk-checkin.c
cache-tree.c
commit-graph.c
commit.c
fetch-pack.c
http-push.c
http-walker.c
list-objects.c
notes.c
odb.c
odb.h
reflog.c
refs.c
remote.c
send-pack.c
shallow.c
upload-pack.c
walker.c

diff --git a/apply.c b/apply.c
index a34ced04625e1827e7b44f457349cca04785eecb..a6836692d0ce087519f4473daa04a3d45032a237 100644 (file)
--- a/apply.c
+++ b/apply.c
@@ -3204,7 +3204,7 @@ 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;
index 0b49baa39fa5c88b57813e5c409fe1f9f7a723bb..80056abe4730ae6c81da5c6ad9e432be37f6dccc 100644 (file)
@@ -67,8 +67,8 @@ 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],
-                               OBJECT_INFO_FOR_PREFETCH))
+               if (!odb_has_object(ctx->repo->objects, &list->oid[i],
+                                   OBJECT_INFO_FOR_PREFETCH))
                        oid_array_append(&ctx->current_batch, &list->oid[i]);
        }
 
index 90a3e159d119cd5dccca8d3dfee9d401f0476814..01672ec74bd2b8a9aeec70194513a8727fcf7694 100644 (file)
@@ -160,8 +160,8 @@ 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,
-                                 HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR);
+               ret = !odb_has_object(the_repository->objects, &oid,
+                                     HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR);
                goto cleanup;
 
        case 'w':
index 3aabdf6570b71b7def7da697d23c4922f3b3c878..6d08abed37c4ce2190ada3658f72b247545ed07d 100644 (file)
@@ -506,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,
index b842bc9c51bb1cc7cee0bc9ad9211d4ecf0c9d3a..65ea6c84368ecf15f31a50551d88270156a7e498 100644 (file)
@@ -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);
 
@@ -910,8 +910,8 @@ 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,
-                       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
+       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));
 
        if (oideq(&ref->old_oid, &ref->new_oid)) {
@@ -1330,7 +1330,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;
        }
 
@@ -1485,7 +1486,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;
index 6e3465b026696af92cc66162a24859f0b5471783..0084cf7400bd46ba7d8b72a908a67c3536abc907 100644 (file)
@@ -161,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),
index 180d261f6ce288c67c75d43649d7a81f4d0073a3..19c67a8534414a700604488dddc603194d1494ba 100644 (file)
@@ -893,8 +893,8 @@ 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,
-                                                  HAS_OBJECT_FETCH_PROMISOR);
+               collision_test_needed = odb_has_object(the_repository->objects, oid,
+                                                      HAS_OBJECT_FETCH_PROMISOR);
                read_unlock();
        }
 
index 580a5c1996b4063719c28205bbe9672abdb8f8c7..06bdeb4223b6d739fa36be0763fb49269e7dc909 100644 (file)
@@ -3968,7 +3968,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);
@@ -3982,7 +3982,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;
 
index 7ea273d93e40ae9e762d56c50f5b6b06349e4154..26e77d70726aaec60aa4752497201e3361333797 100644 (file)
@@ -1509,8 +1509,8 @@ static const char *update(struct command *cmd, struct shallow_info *si)
        }
 
        if (!is_null_oid(new_oid) &&
-           !has_object(the_repository, new_oid,
-                       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {
+           !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));
                ret = "bad pack";
index ac5b8d2a1a6506cae98d4f5239b51c2e21075479..7cbda285ebed3313aef8e5c5ea28410450a8ba37 100644 (file)
@@ -454,8 +454,8 @@ 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,
-                                   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) &&
+               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;
                else
index 90ec1de78f90024e155edcf4d457d090faffdbe2..117709cb076ab37d4aa3d3e88a0dd29cbe564896 100644 (file)
@@ -35,8 +35,8 @@ static void show_one(const struct show_one_options *opts,
        const char *hex;
        struct object_id peeled;
 
-       if (!has_object(the_repository, oid,
-                       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
+       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));
 
index 4bc6575a5743e15f4651c8455b72ae175198db44..a69d59eb50c90251a98430c7b3d069a3b9d0a552 100644 (file)
@@ -449,8 +449,8 @@ 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,
-                              HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
+               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,
                                              delta_data, delta_size))
index 55406a539e7d4a23ea40d76ef7620f2b19cada7c..16df86c0ba89db6a33e7425c54737a5896cfc3c5 100644 (file)
@@ -130,8 +130,8 @@ 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,
-                      HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
+       if (odb_has_object(the_repository->objects, oid,
+                          HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
                return 1;
 
        /* Might want to keep the list sorted */
index 9786b32b3a1caab41190588ff2028c30e374d645..a4bc14ad15c8a077733630960b8f08cb40ae0c4a 100644 (file)
@@ -239,8 +239,8 @@ int cache_tree_fully_valid(struct cache_tree *it)
        if (!it)
                return 0;
        if (it->entry_count < 0 ||
-           has_object(the_repository, &it->oid,
-                      HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
+           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++) {
                if (!cache_tree_fully_valid(it->down[i]->cache_tree))
@@ -292,8 +292,8 @@ static int update_one(struct cache_tree *it,
        }
 
        if (0 <= it->entry_count &&
-           has_object(the_repository, &it->oid,
-                      HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
+           odb_has_object(the_repository->objects, &it->oid,
+                          HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
                return it->entry_count;
 
        /*
@@ -399,8 +399,9 @@ 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,
-                                                  HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))) {
+                   (!ce_missing_ok &&
+                    !odb_has_object(the_repository->objects, oid,
+                                    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))) {
                        strbuf_release(&buffer);
                        if (expected_missing)
                                return -1;
@@ -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;
index 5f482d3377ff1b14dd36ed458b472f92d61bb833..bd7b6f5338bd9dbef1694292a4171b82d9ecac18 100644 (file)
@@ -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);
index 28ee6b73ae6be01a1c066fabb8e334e2952bfe39..15115125c3612c045b3be2f68a94aae4bad1fc4a 100644 (file)
--- a/commit.c
+++ b/commit.c
@@ -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"),
index 0f5de1c94d147876b1460c05605d5913acc9f8f5..5e74235fc06f096d581c6b84e1e352e2d79b2c14 100644 (file)
@@ -142,7 +142,7 @@ 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;
@@ -770,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)
@@ -1984,8 +1984,8 @@ 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],
-                                      HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
+                       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) {
                        setup_alternate_shallow(&shallow_lock,
index 9481825abfb8ad74a0a9619d610a7f9b203a6dd6..beb41732fb6bfacf009f276b54b913f68a137e11 100644 (file)
@@ -1447,8 +1447,8 @@ 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,
-                       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {
+           !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",
                        oid_to_hex(&ref->old_oid), refname);
@@ -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,8 +1883,8 @@ 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,
-                                       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) ||
+                       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)) {
                                /*
index 05fb9ce714a4c94972aa3ad7c60a23851faace15..0f7ae46d7f12c0a53ea7d0ff7139c3bb56313fb6 100644 (file)
@@ -138,8 +138,8 @@ 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,
-                                      HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
+                       if (odb_has_object(the_repository->objects, &obj_req->oid,
+                                          HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
                                obj_req->state = COMPLETE;
                        else {
                                start_object_request(obj_req);
@@ -497,8 +497,8 @@ 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,
-                      HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {
+       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);
                abort_object_request(obj_req);
index c50b9578584d20c561c65dbc83ee0e05abc3e298..42c17d9573910b26569dee08f8cd3d5ba29b77cd 100644 (file)
@@ -74,8 +74,8 @@ static void process_blob(struct traversal_context *ctx,
         * of missing objects.
         */
        if (ctx->revs->exclude_promisor_objects &&
-           !has_object(the_repository, &obj->oid,
-                       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) &&
+           !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;
 
diff --git a/notes.c b/notes.c
index 73eb5f00cf51742732dd16ce42eb19002239ceaf..97b995f3f2da6f154337b4672af6f67438ae0f2a 100644 (file)
--- a/notes.c
+++ b/notes.c
@@ -794,8 +794,8 @@ 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,
-                      HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
+       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 */
 
        /* failed to find object => prune this note */
diff --git a/odb.c b/odb.c
index fc39fbe12d89750840d1051fc2f136ab3469c6f3..4dccb9215d8d6d1d64546e1ac4b6f0e1444e0450 100644 (file)
--- a/odb.c
+++ b/odb.c
@@ -871,7 +871,7 @@ int pretend_object_file(struct repository *repo,
        char *co_buf;
 
        hash_object_file(repo->hash_algo, buf, len, type, oid);
-       if (has_object(repo, oid, 0) ||
+       if (odb_has_object(repo->objects, oid, 0) ||
            find_cached_object(repo->objects, oid))
                return 0;
 
@@ -953,7 +953,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;
@@ -965,7 +965,7 @@ 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 odb_read_object_info_extended(r->objects, oid, NULL, object_info_flags) >= 0;
+       return odb_read_object_info_extended(odb, oid, NULL, object_info_flags) >= 0;
 }
 
 void odb_assert_oid_type(struct object_database *odb,
diff --git a/odb.h b/odb.h
index a4a5154fd0ff1d6654dbb9745dc43273697c6410..2532c4904619dabb384fb358989b4f0772f5bf1a 100644 (file)
--- a/odb.h
+++ b/odb.h
@@ -372,8 +372,9 @@ enum {
  * 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);
+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);
@@ -463,4 +464,11 @@ static inline void *repo_read_object_file(struct repository *r,
        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 */
index 747b82eada83f4081591059f5b727aa678b9ee16..39c205fd26e77b2a71ffe8c22812479f87b8d8bd 100644 (file)
--- a/reflog.c
+++ b/reflog.c
@@ -152,7 +152,7 @@ static int tree_is_complete(const struct object_id *oid)
        init_tree_desc(&desc, &tree->object.oid, tree->buffer, tree->size);
        complete = 1;
        while (tree_entry(&desc, &entry)) {
-               if (!has_object(the_repository, &entry.oid,
+               if (!odb_has_object(the_repository->objects, &entry.oid,
                                HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) ||
                    (S_ISDIR(entry.mode) && !tree_is_complete(&entry.oid))) {
                        tree->object.flags |= INCOMPLETE;
diff --git a/refs.c b/refs.c
index 0ff0e582a6b0190d99436be9dae36365ee27589c..26e5c2a7d9cf18b3aacda11aa7b017affdf5259a 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -376,7 +376,8 @@ int ref_resolves_to_object(const char *refname,
 {
        if (flags & REF_ISBROKEN)
                return 0;
-       if (!has_object(repo, oid, HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {
+       if (!odb_has_object(repo->objects, oid,
+                           HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {
                error(_("%s does not point to a valid object!"), refname);
                return 0;
        }
index 72c36239d31e34b7dbb3eb15e7eea0b3967bdcdb..5edf2a9f4b2d0ea746e4dbeea55a5bdbf8e3abdf 100644 (file)
--- a/remote.c
+++ b/remote.c
@@ -1703,7 +1703,7 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
                if (!reject_reason && !ref->deletion && !is_null_oid(&ref->old_oid)) {
                        if (starts_with(ref->name, "refs/tags/"))
                                reject_reason = REF_STATUS_REJECT_ALREADY_EXISTS;
-                       else if (!has_object(the_repository, &ref->old_oid, HAS_OBJECT_RECHECK_PACKED))
+                       else if (!odb_has_object(the_repository->objects, &ref->old_oid, HAS_OBJECT_RECHECK_PACKED))
                                reject_reason = REF_STATUS_REJECT_FETCH_FIRST;
                        else if (!lookup_commit_reference_gently(the_repository, &ref->old_oid, 1) ||
                                 !lookup_commit_reference_gently(the_repository, &ref->new_oid, 1))
index abca2dd38a78ba9e88638aad5b643afdfb808195..d029f748232a420b9a584f94063b04a13f4e2cf0 100644 (file)
@@ -45,7 +45,7 @@ int option_parse_push_signed(const struct option *opt,
 static void feed_object(struct repository *r,
                        const struct object_id *oid, FILE *fh, int negative)
 {
-       if (negative && !has_object(r, oid, 0))
+       if (negative && !odb_has_object(r->objects, oid, 0))
                return;
 
        if (negative)
index d379756e39a67a18929b62e5180f6eb479fea9af..ef3adb635fdb9ca625ed10bd30a760962f140471 100644 (file)
--- a/shallow.c
+++ b/shallow.c
@@ -310,8 +310,8 @@ static int write_one_shallow(const struct commit_graft *graft, void *cb_data)
        if (graft->nr_parent != -1)
                return 0;
        if (data->flags & QUICK) {
-               if (!has_object(the_repository, &graft->oid,
-                               HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
+               if (!odb_has_object(the_repository->objects, &graft->oid,
+                                   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
                        return 0;
        } else if (data->flags & SEEN_ONLY) {
                struct commit *c = lookup_commit(the_repository, &graft->oid);
@@ -477,8 +477,8 @@ void prepare_shallow_info(struct shallow_info *info, struct oid_array *sa)
        ALLOC_ARRAY(info->ours, sa->nr);
        ALLOC_ARRAY(info->theirs, sa->nr);
        for (size_t i = 0; i < sa->nr; i++) {
-               if (has_object(the_repository, sa->oid + i,
-                              HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {
+               if (odb_has_object(the_repository->objects, sa->oid + i,
+                                  HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {
                        struct commit_graft *graft;
                        graft = lookup_commit_graft(the_repository,
                                                    &sa->oid[i]);
@@ -515,8 +515,8 @@ void remove_nonexistent_theirs_shallow(struct shallow_info *info)
        for (i = dst = 0; i < info->nr_theirs; i++) {
                if (i != dst)
                        info->theirs[dst] = info->theirs[i];
-               if (has_object(the_repository, oid + info->theirs[i],
-                              HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
+               if (odb_has_object(the_repository->objects, oid + info->theirs[i],
+                                  HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
                        dst++;
        }
        info->nr_theirs = dst;
index e994d6a901b6679111083dbd276c11749943430b..4f26f6afc77106ead4ba04bae6f529ed39af7e02 100644 (file)
@@ -509,7 +509,7 @@ static int got_oid(struct upload_pack_data *data,
 {
        if (get_oid_hex(hex, oid))
                die("git upload-pack: expected SHA1 object, got '%s'", hex);
-       if (!has_object(the_repository, oid, 0))
+       if (!odb_has_object(the_repository->objects, oid, 0))
                return -1;
        return do_got_oid(data, oid);
 }
index a8abe8a2e78ee53bdac18b9638345c949e3c17a9..d131af04c7bf04e92a677b6c46f572672c94723b 100644 (file)
--- a/walker.c
+++ b/walker.c
@@ -150,8 +150,8 @@ static int process(struct walker *walker, struct object *obj)
                return 0;
        obj->flags |= SEEN;
 
-       if (has_object(the_repository, &obj->oid,
-                      HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {
+       if (odb_has_object(the_repository->objects, &obj->oid,
+                          HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {
                /* We already have it, so we should scan it now. */
                obj->flags |= TO_SCAN;
        }