]> git.ipfire.org Git - thirdparty/git.git/commitdiff
treewide: convert users of `repo_has_object_file()` to `has_object()`
authorPatrick Steinhardt <ps@pks.im>
Tue, 29 Apr 2025 07:52:20 +0000 (09:52 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 29 Apr 2025 17:08:13 +0000 (10:08 -0700)
As the comment of `repo_has_object_file()` and its `_with_flags()`
variant tells us, these functions are considered to be deprecated in
favor of `has_object()`. There are a couple of slight benefits in favor
of the replacement:

  - The new function has a short-and-sweet name.

  - More explicit defaults: `has_object()` doesn't fetch missing objects
    via promisor remotes, and neither does it reload packfiles if an
    object wasn't found by default. This ensures that it becomes
    immediately obvious when a simple object existence check may result
    in expensive actions.

Most importantly though, it is confusing that we have two sets of
functions that ultimately do the same thing, but with different
defaults.

Start sunsetting `repo_has_object_file()` and its `_with_flags()`
sibling by replacing all callsites with `has_object()`:

  - `repo_has_object_file(...)` is equivalent to
    `has_object(..., HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)`.

  - `repo_has_object_file_with_flags(..., OBJECT_INFO_QUICK | OBJECT_INFO_SKIP_FETCH_OBJECT)`
    is equivalent to `has_object(..., 0)`.

  - `repo_has_object_file_with_flags(..., OBJECT_INFO_SKIP_FETCH_OBJECT)`
    is equivalent to `has_object(..., HAS_OBJECT_RECHECK_PACKED)`.

  - `repo_has_object_file_with_flags(..., OBJECT_INFO_QUICK)`
    is equivalent to `has_object(..., HAS_OBJECT_FETCH_PROMISOR)`.

The replacements should be functionally equivalent.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
23 files changed:
builtin/cat-file.c
builtin/clone.c
builtin/fetch.c
builtin/index-pack.c
builtin/receive-pack.c
builtin/remote.c
builtin/show-ref.c
builtin/unpack-objects.c
bulk-checkin.c
cache-tree.c
fetch-pack.c
http-push.c
http-walker.c
list-objects.c
notes.c
object-store.c
reflog.c
refs.c
remote.c
send-pack.c
shallow.c
upload-pack.c
walker.c

index 0e3f10a946700e62a8b9ec20a476c8e2ae03a136..3914a2a3f61c61f68e68d3432b820154ea5d2765 100644 (file)
@@ -169,7 +169,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
                goto cleanup;
 
        case 'e':
-               ret = !repo_has_object_file(the_repository, &oid);
+               ret = !has_object(the_repository, &oid,
+                                 HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR);
                goto cleanup;
 
        case 'w':
index 6b1d11a3ed20014dfffb014925a65a520f129d84..b498b81a0434b36101475d2c92201e907872fdc9 100644 (file)
@@ -504,9 +504,7 @@ static void write_followtags(const struct ref *refs, const char *msg)
                        continue;
                if (ends_with(ref->name, "^{}"))
                        continue;
-               if (!repo_has_object_file_with_flags(the_repository, &ref->old_oid,
-                                                    OBJECT_INFO_QUICK |
-                                                    OBJECT_INFO_SKIP_FETCH_OBJECT))
+               if (!has_object(the_repository, &ref->old_oid, 0))
                        continue;
                refs_update_ref(get_main_ref_store(the_repository), msg,
                                ref->name, &ref->old_oid, NULL, 0,
index 95589b499485d1c26783da9ea8499293d4b36925..aadcf49a5b4777249c7fd4edb14ea17d91d49496 100644 (file)
@@ -337,7 +337,6 @@ static void find_non_local_tags(const struct ref *refs,
        struct string_list_item *remote_ref_item;
        const struct ref *ref;
        struct refname_hash_entry *item = NULL;
-       const int quick_flags = OBJECT_INFO_QUICK | OBJECT_INFO_SKIP_FETCH_OBJECT;
 
        refname_hash_init(&existing_refs);
        refname_hash_init(&remote_refs);
@@ -367,9 +366,9 @@ static void find_non_local_tags(const struct ref *refs,
                 */
                if (ends_with(ref->name, "^{}")) {
                        if (item &&
-                           !repo_has_object_file_with_flags(the_repository, &ref->old_oid, quick_flags) &&
+                           !has_object(the_repository, &ref->old_oid, 0) &&
                            !oidset_contains(&fetch_oids, &ref->old_oid) &&
-                           !repo_has_object_file_with_flags(the_repository, &item->oid, quick_flags) &&
+                           !has_object(the_repository, &item->oid, 0) &&
                            !oidset_contains(&fetch_oids, &item->oid))
                                clear_item(item);
                        item = NULL;
@@ -383,7 +382,7 @@ static void find_non_local_tags(const struct ref *refs,
                 * fetch.
                 */
                if (item &&
-                   !repo_has_object_file_with_flags(the_repository, &item->oid, quick_flags) &&
+                   !has_object(the_repository, &item->oid, 0) &&
                    !oidset_contains(&fetch_oids, &item->oid))
                        clear_item(item);
 
@@ -404,7 +403,7 @@ static void find_non_local_tags(const struct ref *refs,
         * checked to see if it needs fetching.
         */
        if (item &&
-           !repo_has_object_file_with_flags(the_repository, &item->oid, quick_flags) &&
+           !has_object(the_repository, &item->oid, 0) &&
            !oidset_contains(&fetch_oids, &item->oid))
                clear_item(item);
 
@@ -911,7 +910,8 @@ static int update_local_ref(struct ref *ref,
        struct commit *current = NULL, *updated;
        int fast_forward = 0;
 
-       if (!repo_has_object_file(the_repository, &ref->new_oid))
+       if (!has_object(the_repository, &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,8 +1330,7 @@ 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 (!repo_has_object_file_with_flags(the_repository, &r->old_oid,
-                                                    OBJECT_INFO_SKIP_FETCH_OBJECT))
+               if (!has_object(the_repository, &r->old_oid, HAS_OBJECT_RECHECK_PACKED))
                        return -1;
        }
 
index f49431d626b173d623949f6fa42ff68311e43106..147e9b8b47956a85971c71be7ce74a30a0f4ac4a 100644 (file)
@@ -892,9 +892,8 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
 
        if (startup_info->have_repository) {
                read_lock();
-               collision_test_needed =
-                       repo_has_object_file_with_flags(the_repository, oid,
-                                                       OBJECT_INFO_QUICK);
+               collision_test_needed = has_object(the_repository, oid,
+                                                  HAS_OBJECT_FETCH_PROMISOR);
                read_unlock();
        }
 
index be314879e8290894a38900a86c8ac7a40e674ec4..c92e57ba188a196e9b6d18c1ede5e76fbf8c0b33 100644 (file)
@@ -1506,7 +1506,9 @@ static const char *update(struct command *cmd, struct shallow_info *si)
                }
        }
 
-       if (!is_null_oid(new_oid) && !repo_has_object_file(the_repository, new_oid)) {
+       if (!is_null_oid(new_oid) &&
+           !has_object(the_repository, 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 b4baa34e665a8f71496b89d8e12b540a7169f203..0d6755bcb71e3db51b2a2b0f7150b66d40000b6e 100644 (file)
@@ -454,7 +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 (repo_has_object_file(the_repository, &ref->old_oid) &&
+               else if (has_object(the_repository, &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 f81209f23c33866ceae1903564c4e81a5ad1d41d..623a52a45f85cf634f0f9a6ce9b017dbe752d59e 100644 (file)
@@ -35,7 +35,8 @@ static void show_one(const struct show_one_options *opts,
        const char *hex;
        struct object_id peeled;
 
-       if (!repo_has_object_file(the_repository, oid))
+       if (!has_object(the_repository, oid,
+                       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
                die("git show-ref: bad ref %s (%s)", refname,
                    oid_to_hex(oid));
 
index 661be789f1340cae1ee5da3bc705a696c7fc4a15..e905d5f4e1964b43e2262500053f3e53753eaeab 100644 (file)
@@ -449,7 +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 (repo_has_object_file(the_repository, &base_oid))
+               if (has_object(the_repository, &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 c31c31b18d8a0b5c148af2189257a4e63c093670..678e2ecc2c29da93d918dabaee4088e4ca28ceb8 100644 (file)
@@ -130,7 +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 (repo_has_object_file(the_repository, oid))
+       if (has_object(the_repository, oid,
+                      HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
                return 1;
 
        /* Might want to keep the list sorted */
index c0e1e9ee1d4af0770025dee702b488262b4eb948..fa3858e2829aa89eb8246d6519991d8925b04402 100644 (file)
@@ -238,7 +238,9 @@ int cache_tree_fully_valid(struct cache_tree *it)
        int i;
        if (!it)
                return 0;
-       if (it->entry_count < 0 || !repo_has_object_file(the_repository, &it->oid))
+       if (it->entry_count < 0 ||
+           has_object(the_repository, &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))
@@ -289,7 +291,9 @@ static int update_one(struct cache_tree *it,
                }
        }
 
-       if (0 <= it->entry_count && repo_has_object_file(the_repository, &it->oid))
+       if (0 <= it->entry_count &&
+           has_object(the_repository, &it->oid,
+                      HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
                return it->entry_count;
 
        /*
@@ -395,7 +399,8 @@ static int update_one(struct cache_tree *it,
                ce_missing_ok = mode == S_IFGITLINK || missing_ok ||
                        !must_check_existence(ce);
                if (is_null_oid(oid) ||
-                   (!ce_missing_ok && !repo_has_object_file(the_repository, oid))) {
+                   (!ce_missing_ok && !has_object(the_repository, oid,
+                                                  HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))) {
                        strbuf_release(&buffer);
                        if (expected_missing)
                                return -1;
@@ -443,7 +448,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 (repo_has_object_file_with_flags(the_repository, &oid, OBJECT_INFO_SKIP_FETCH_OBJECT))
+               if (has_object(the_repository, &oid, HAS_OBJECT_RECHECK_PACKED))
                        oidcpy(&it->oid, &oid);
                else
                        to_invalidate = 1;
index 210dc30d50f6d6237f9c18104c01a56219478013..fa4231fee74c9f4efbeb61480859c20219718d29 100644 (file)
@@ -769,9 +769,7 @@ static void mark_complete_and_common_ref(struct fetch_negotiator *negotiator,
                if (!commit) {
                        struct object *o;
 
-                       if (!repo_has_object_file_with_flags(the_repository, &ref->old_oid,
-                                                            OBJECT_INFO_QUICK |
-                                                            OBJECT_INFO_SKIP_FETCH_OBJECT))
+                       if (!has_object(the_repository, &ref->old_oid, 0))
                                continue;
                        o = parse_object(the_repository, &ref->old_oid);
                        if (!o || o->type != OBJ_COMMIT)
@@ -1985,7 +1983,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 (repo_has_object_file(the_repository, &oid[i]))
+                       if (has_object(the_repository, &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 32e37565f4e08f5f46bae21de98501ccdf181ee7..f9e67cabd4bee8ac4ac223e990623988314683c3 100644 (file)
@@ -1446,7 +1446,9 @@ static void one_remote_ref(const char *refname)
         * Fetch a copy of the object if it doesn't exist locally - it
         * may be required for updating server info later.
         */
-       if (repo->can_update_info_refs && !repo_has_object_file(the_repository, &ref->old_oid)) {
+       if (repo->can_update_info_refs &&
+           !has_object(the_repository, &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);
@@ -1651,14 +1653,14 @@ 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 (!repo_has_object_file(the_repository, &head_oid))
+               if (!has_object(the_repository, &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 (!repo_has_object_file(the_repository, &remote_ref->old_oid))
+               if (!has_object(the_repository, &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 */
@@ -1879,7 +1881,8 @@ int cmd_main(int argc, const char **argv)
                if (!force_all &&
                    !is_null_oid(&ref->old_oid) &&
                    !ref->force) {
-                       if (!repo_has_object_file(the_repository, &ref->old_oid) ||
+                       if (!has_object(the_repository, &ref->old_oid,
+                                       HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) ||
                            !ref_newer(&ref->peer_ref->new_oid,
                                       &ref->old_oid)) {
                                /*
index 95458e2f6384bccb2b81d0e835dae91a6a357639..463f7b119ad4ca174c8b042ee04a51449bf98651 100644 (file)
@@ -138,7 +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 (repo_has_object_file(the_repository, &obj_req->oid))
+                       if (has_object(the_repository, &obj_req->oid,
+                                      HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
                                obj_req->state = COMPLETE;
                        else {
                                start_object_request(obj_req);
@@ -496,7 +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 (repo_has_object_file(the_repository, &obj_req->oid)) {
+       if (has_object(the_repository, &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 1e5512e1318a2c6f0ce557fe51cdc124b3ecd338..597114281f6596e6fe50171a0764ce71fc442657 100644 (file)
@@ -74,7 +74,8 @@ static void process_blob(struct traversal_context *ctx,
         * of missing objects.
         */
        if (ctx->revs->exclude_promisor_objects &&
-           !repo_has_object_file(the_repository, &obj->oid) &&
+           !has_object(the_repository, &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 d9645c4b5dc6031405982c6fd74e460f6bf4250f..0a128f1de980506466ac0b66568ef15219ec4dff 100644 (file)
--- a/notes.c
+++ b/notes.c
@@ -794,7 +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 (repo_has_object_file(the_repository, object_oid))
+       if (has_object(the_repository, 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 */
index 0d873868a6d7cb87650daacfc775a80f498d7fc9..2db34804e8ff02dee5d0442be3f13a18e9782995 100644 (file)
@@ -847,7 +847,7 @@ int pretend_object_file(struct repository *repo,
        char *co_buf;
 
        hash_object_file(repo->hash_algo, buf, len, type, oid);
-       if (repo_has_object_file_with_flags(repo, oid, OBJECT_INFO_QUICK | OBJECT_INFO_SKIP_FETCH_OBJECT) ||
+       if (has_object(repo, oid, 0) ||
            find_cached_object(repo->objects, oid))
                return 0;
 
index 12f7a02e3408db6d0eb0a642914391282fcdfc97..15d81ebea978d347670b6486dc54dc084355d23c 100644 (file)
--- a/reflog.c
+++ b/reflog.c
@@ -152,7 +152,8 @@ 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 (!repo_has_object_file(the_repository, &entry.oid) ||
+               if (!has_object(the_repository, &entry.oid,
+                               HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) ||
                    (S_ISDIR(entry.mode) && !tree_is_complete(&entry.oid))) {
                        tree->object.flags |= INCOMPLETE;
                        complete = 0;
diff --git a/refs.c b/refs.c
index 6559db378909e427d064970e711d05920f425e0f..dce5c49ca2ba65fd6a2974e38f67134215bee369 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -376,7 +376,7 @@ int ref_resolves_to_object(const char *refname,
 {
        if (flags & REF_ISBROKEN)
                return 0;
-       if (!repo_has_object_file(repo, oid)) {
+       if (!has_object(repo, oid, HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {
                error(_("%s does not point to a valid object!"), refname);
                return 0;
        }
index 9fa3614e7a337448f0de730d95ddad5c63225131..4099183cacdc8a607a8b5eaec86e456b2ef46b48 100644 (file)
--- a/remote.c
+++ b/remote.c
@@ -1702,7 +1702,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 (!repo_has_object_file_with_flags(the_repository, &ref->old_oid, OBJECT_INFO_SKIP_FETCH_OBJECT))
+                       else if (!has_object(the_repository, &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 5005689cb55a483da6298e1bceac54dca647c03f..86592ce526db95bb4b13c2c6b19d604a464755ff 100644 (file)
@@ -45,10 +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 &&
-           !repo_has_object_file_with_flags(r, oid,
-                                            OBJECT_INFO_SKIP_FETCH_OBJECT |
-                                            OBJECT_INFO_QUICK))
+       if (negative && !has_object(r, oid, 0))
                return;
 
        if (negative)
index 2f82ebd6e3f5e5ba963b29a7dc27f66eacd3daa0..faeeeb45f986e13065290712e16a800f46b42364 100644 (file)
--- a/shallow.c
+++ b/shallow.c
@@ -310,7 +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 (!repo_has_object_file(the_repository, &graft->oid))
+               if (!has_object(the_repository, &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);
@@ -476,7 +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 (repo_has_object_file(the_repository, sa->oid + i)) {
+               if (has_object(the_repository, sa->oid + i,
+                              HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {
                        struct commit_graft *graft;
                        graft = lookup_commit_graft(the_repository,
                                                    &sa->oid[i]);
@@ -513,7 +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 (repo_has_object_file(the_repository, oid + info->theirs[i]))
+               if (has_object(the_repository, oid + info->theirs[i],
+                              HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
                        dst++;
        }
        info->nr_theirs = dst;
index 30e4630f3a1cb328896e48188e3a5fb884ca7558..956da5b061a0e5eecbcb1b0d8adae032b9a2b16e 100644 (file)
@@ -509,8 +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 (!repo_has_object_file_with_flags(the_repository, oid,
-                                            OBJECT_INFO_QUICK | OBJECT_INFO_SKIP_FETCH_OBJECT))
+       if (!has_object(the_repository, oid, 0))
                return -1;
        return do_got_oid(data, oid);
 }
index 4fedc19f346e66eeee2a4d7a2910fd699c4ef12f..b470d43e54d486c370651be98eb1d0dc0da39434 100644 (file)
--- a/walker.c
+++ b/walker.c
@@ -150,7 +150,8 @@ static int process(struct walker *walker, struct object *obj)
                return 0;
        obj->flags |= SEEN;
 
-       if (repo_has_object_file(the_repository, &obj->oid)) {
+       if (has_object(the_repository, &obj->oid,
+                      HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {
                /* We already have it, so we should scan it now. */
                obj->flags |= TO_SCAN;
        }