odb: rename `has_object()`

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>

Patrick Steinhardt committed Jul 1, 2025 at 14:22 UTC fcf8e3e111ec46705f91151baee40f2c0a3637da
30 files changed +87 -74
apply.c
+1 -1
@@ -3204,7 +3204,7 @@ static int apply_binary(struct apply_state *state,
3204 return 0; /* deletion patch */
3205 }
3206
3207 - if (has_object(the_repository, &oid, 0)) {
3207 + if (odb_has_object(the_repository->objects, &oid, 0)) {
3208 /* We already have the postimage */
3209 enum object_type type;
3210 unsigned long size;
builtin/backfill.c
+2 -2
@@ -67,8 +67,8 @@ static int fill_missing_blobs(const char *path UNUSED,
67 return 0;
68
69 for (size_t i = 0; i < list->nr; i++) {
70 - if (!has_object(ctx->repo, &list->oid[i],
71 - OBJECT_INFO_FOR_PREFETCH))
70 + if (!odb_has_object(ctx->repo->objects, &list->oid[i],
71 + OBJECT_INFO_FOR_PREFETCH))
72 oid_array_append(&ctx->current_batch, &list->oid[i]);
73 }
74
builtin/cat-file.c
+2 -2
@@ -160,8 +160,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
160 goto cleanup;
161
162 case 'e':
163 - ret = !has_object(the_repository, &oid,
164 - HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR);
163 + ret = !odb_has_object(the_repository->objects, &oid,
164 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR);
165 goto cleanup;
166
167 case 'w':
builtin/clone.c
+1 -1
@@ -506,7 +506,7 @@ static void write_followtags(const struct ref *refs, const char *msg)
506 continue;
507 if (ends_with(ref->name, "^{}"))
508 continue;
509 - if (!has_object(the_repository, &ref->old_oid, 0))
509 + if (!odb_has_object(the_repository->objects, &ref->old_oid, 0))
510 continue;
511 refs_update_ref(get_main_ref_store(the_repository), msg,
512 ref->name, &ref->old_oid, NULL, 0,
builtin/fetch.c
+9 -8
@@ -366,9 +366,9 @@ static void find_non_local_tags(const struct ref *refs,
366 */
367 if (ends_with(ref->name, "^{}")) {
368 if (item &&
369 - !has_object(the_repository, &ref->old_oid, 0) &&
369 + !odb_has_object(the_repository->objects, &ref->old_oid, 0) &&
370 !oidset_contains(&fetch_oids, &ref->old_oid) &&
371 - !has_object(the_repository, &item->oid, 0) &&
371 + !odb_has_object(the_repository->objects, &item->oid, 0) &&
372 !oidset_contains(&fetch_oids, &item->oid))
373 clear_item(item);
374 item = NULL;
@@ -382,7 +382,7 @@ static void find_non_local_tags(const struct ref *refs,
382 * fetch.
383 */
384 if (item &&
385 - !has_object(the_repository, &item->oid, 0) &&
385 + !odb_has_object(the_repository->objects, &item->oid, 0) &&
386 !oidset_contains(&fetch_oids, &item->oid))
387 clear_item(item);
388
@@ -403,7 +403,7 @@ static void find_non_local_tags(const struct ref *refs,
403 * checked to see if it needs fetching.
404 */
405 if (item &&
406 - !has_object(the_repository, &item->oid, 0) &&
406 + !odb_has_object(the_repository->objects, &item->oid, 0) &&
407 !oidset_contains(&fetch_oids, &item->oid))
408 clear_item(item);
409
@@ -910,8 +910,8 @@ static int update_local_ref(struct ref *ref,
910 struct commit *current = NULL, *updated;
911 int fast_forward = 0;
912
913 - if (!has_object(the_repository, &ref->new_oid,
914 - HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
913 + if (!odb_has_object(the_repository->objects, &ref->new_oid,
914 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
915 die(_("object %s not found"), oid_to_hex(&ref->new_oid));
916
917 if (oideq(&ref->old_oid, &ref->new_oid)) {
@@ -1330,7 +1330,8 @@ static int check_exist_and_connected(struct ref *ref_map)
1330 * we need all direct targets to exist.
1331 */
1332 for (r = rm; r; r = r->next) {
1333 - if (!has_object(the_repository, &r->old_oid, HAS_OBJECT_RECHECK_PACKED))
1333 + if (!odb_has_object(the_repository->objects, &r->old_oid,
1334 + HAS_OBJECT_RECHECK_PACKED))
1335 return -1;
1336 }
1337
@@ -1485,7 +1486,7 @@ static void add_negotiation_tips(struct git_transport_options *smart_options)
1486 struct object_id oid;
1487 if (repo_get_oid(the_repository, s, &oid))
1488 die(_("%s is not a valid object"), s);
1488 - if (!has_object(the_repository, &oid, 0))
1489 + if (!odb_has_object(the_repository->objects, &oid, 0))
1490 die(_("the object %s does not exist"), s);
1491 oid_array_append(oids, &oid);
1492 continue;
builtin/fsck.c
+1 -1
@@ -161,7 +161,7 @@ static int mark_object(struct object *obj, enum object_type type,
161 return 0;
162
163 if (!(obj->flags & HAS_OBJ)) {
164 - if (parent && !has_object(the_repository, &obj->oid, 1)) {
164 + if (parent && !odb_has_object(the_repository->objects, &obj->oid, 1)) {
165 printf_ln(_("broken link from %7s %s\n"
166 " to %7s %s"),
167 printable_type(&parent->oid, parent->type),
builtin/index-pack.c
+2 -2
@@ -893,8 +893,8 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
893
894 if (startup_info->have_repository) {
895 read_lock();
896 - collision_test_needed = has_object(the_repository, oid,
897 - HAS_OBJECT_FETCH_PROMISOR);
896 + collision_test_needed = odb_has_object(the_repository->objects, oid,
897 + HAS_OBJECT_FETCH_PROMISOR);
898 read_unlock();
899 }
900
builtin/pack-objects.c
+2 -2
@@ -3968,7 +3968,7 @@ static void show_object__ma_allow_any(struct object *obj, const char *name, void
3968 * Quietly ignore ALL missing objects. This avoids problems with
3969 * staging them now and getting an odd error later.
3970 */
3971 - if (!has_object(the_repository, &obj->oid, 0))
3971 + if (!odb_has_object(the_repository->objects, &obj->oid, 0))
3972 return;
3973
3974 show_object(obj, name, data);
@@ -3982,7 +3982,7 @@ static void show_object__ma_allow_promisor(struct object *obj, const char *name,
3982 * Quietly ignore EXPECTED missing objects. This avoids problems with
3983 * staging them now and getting an odd error later.
3984 */
3985 - if (!has_object(the_repository, &obj->oid, 0) &&
3985 + if (!odb_has_object(the_repository->objects, &obj->oid, 0) &&
3986 is_promisor_object(to_pack.repo, &obj->oid))
3987 return;
3988
builtin/receive-pack.c
+2 -2
@@ -1509,8 +1509,8 @@ static const char *update(struct command *cmd, struct shallow_info *si)
1509 }
1510
1511 if (!is_null_oid(new_oid) &&
1512 - !has_object(the_repository, new_oid,
1513 - HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {
1512 + !odb_has_object(the_repository->objects, new_oid,
1513 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {
1514 error("unpack should have generated %s, "
1515 "but I can't find it!", oid_to_hex(new_oid));
1516 ret = "bad pack";
builtin/remote.c
+2 -2
@@ -454,8 +454,8 @@ static int get_push_ref_states(const struct ref *remote_refs,
454 info->status = PUSH_STATUS_UPTODATE;
455 else if (is_null_oid(&ref->old_oid))
456 info->status = PUSH_STATUS_CREATE;
457 - else if (has_object(the_repository, &ref->old_oid,
458 - HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) &&
457 + else if (odb_has_object(the_repository->objects, &ref->old_oid,
458 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) &&
459 ref_newer(&ref->new_oid, &ref->old_oid))
460 info->status = PUSH_STATUS_FASTFORWARD;
461 else
builtin/show-ref.c
+2 -2
@@ -35,8 +35,8 @@ static void show_one(const struct show_one_options *opts,
35 const char *hex;
36 struct object_id peeled;
37
38 - if (!has_object(the_repository, oid,
39 - HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
38 + if (!odb_has_object(the_repository->objects, oid,
39 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
40 die("git show-ref: bad ref %s (%s)", refname,
41 oid_to_hex(oid));
42
builtin/unpack-objects.c
+2 -2
@@ -449,8 +449,8 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,
449 delta_data = get_data(delta_size);
450 if (!delta_data)
451 return;
452 - if (has_object(the_repository, &base_oid,
453 - HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
452 + if (odb_has_object(the_repository->objects, &base_oid,
453 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
454 ; /* Ok we have this one */
455 else if (resolve_against_held(nr, &base_oid,
456 delta_data, delta_size))
bulk-checkin.c
+2 -2
@@ -130,8 +130,8 @@ static void flush_batch_fsync(void)
130 static int already_written(struct bulk_checkin_packfile *state, struct object_id *oid)
131 {
132 /* The object may already exist in the repository */
133 - if (has_object(the_repository, oid,
134 - HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
133 + if (odb_has_object(the_repository->objects, oid,
134 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
135 return 1;
136
137 /* Might want to keep the list sorted */
cache-tree.c
+8 -7
@@ -239,8 +239,8 @@ int cache_tree_fully_valid(struct cache_tree *it)
239 if (!it)
240 return 0;
241 if (it->entry_count < 0 ||
242 - has_object(the_repository, &it->oid,
243 - HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
242 + odb_has_object(the_repository->objects, &it->oid,
243 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
244 return 0;
245 for (i = 0; i < it->subtree_nr; i++) {
246 if (!cache_tree_fully_valid(it->down[i]->cache_tree))
@@ -292,8 +292,8 @@ static int update_one(struct cache_tree *it,
292 }
293
294 if (0 <= it->entry_count &&
295 - has_object(the_repository, &it->oid,
296 - HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
295 + odb_has_object(the_repository->objects, &it->oid,
296 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
297 return it->entry_count;
298
299 /*
@@ -399,8 +399,9 @@ static int update_one(struct cache_tree *it,
399 ce_missing_ok = mode == S_IFGITLINK || missing_ok ||
400 !must_check_existence(ce);
401 if (is_null_oid(oid) ||
402 - (!ce_missing_ok && !has_object(the_repository, oid,
403 - HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))) {
402 + (!ce_missing_ok &&
403 + !odb_has_object(the_repository->objects, oid,
404 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))) {
405 strbuf_release(&buffer);
406 if (expected_missing)
407 return -1;
@@ -448,7 +449,7 @@ static int update_one(struct cache_tree *it,
449 struct object_id oid;
450 hash_object_file(the_hash_algo, buffer.buf, buffer.len,
451 OBJ_TREE, &oid);
451 - if (has_object(the_repository, &oid, HAS_OBJECT_RECHECK_PACKED))
452 + if (odb_has_object(the_repository->objects, &oid, HAS_OBJECT_RECHECK_PACKED))
453 oidcpy(&it->oid, &oid);
454 else
455 to_invalidate = 1;
commit-graph.c
+1 -1
@@ -1040,7 +1040,7 @@ struct commit *lookup_commit_in_graph(struct repository *repo, const struct obje
1040 return NULL;
1041 if (!search_commit_pos_in_graph(id, repo->objects->commit_graph, &pos))
1042 return NULL;
1043 - if (commit_graph_paranoia && !has_object(repo, id, 0))
1043 + if (commit_graph_paranoia && !odb_has_object(repo->objects, id, 0))
1044 return NULL;
1045
1046 commit = lookup_commit(repo, id);
commit.c
+1 -1
@@ -575,7 +575,7 @@ int repo_parse_commit_internal(struct repository *r,
575 if (commit_graph_paranoia == -1)
576 commit_graph_paranoia = git_env_bool(GIT_COMMIT_GRAPH_PARANOIA, 0);
577
578 - if (commit_graph_paranoia && !has_object(r, &item->object.oid, 0)) {
578 + if (commit_graph_paranoia && !odb_has_object(r->objects, &item->object.oid, 0)) {
579 unparse_commit(r, &item->object.oid);
580 return quiet_on_missing ? -1 :
581 error(_("commit %s exists in commit-graph but not in the object database"),
fetch-pack.c
+4 -4
@@ -142,7 +142,7 @@ static struct commit *deref_without_lazy_fetch(const struct object_id *oid,
142 commit = lookup_commit_in_graph(the_repository, oid);
143 if (commit) {
144 if (mark_tags_complete_and_check_obj_db) {
145 - if (!has_object(the_repository, oid, 0))
145 + if (!odb_has_object(the_repository->objects, oid, 0))
146 die_in_commit_graph_only(oid);
147 }
148 return commit;
@@ -770,7 +770,7 @@ static void mark_complete_and_common_ref(struct fetch_negotiator *negotiator,
770 if (!commit) {
771 struct object *o;
772
773 - if (!has_object(the_repository, &ref->old_oid, 0))
773 + if (!odb_has_object(the_repository->objects, &ref->old_oid, 0))
774 continue;
775 o = parse_object(the_repository, &ref->old_oid);
776 if (!o || o->type != OBJ_COMMIT)
@@ -1984,8 +1984,8 @@ static void update_shallow(struct fetch_pack_args *args,
1984 struct oid_array extra = OID_ARRAY_INIT;
1985 struct object_id *oid = si->shallow->oid;
1986 for (i = 0; i < si->shallow->nr; i++)
1987 - if (has_object(the_repository, &oid[i],
1988 - HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
1987 + if (odb_has_object(the_repository->objects, &oid[i],
1988 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
1989 oid_array_append(&extra, &oid[i]);
1990 if (extra.nr) {
1991 setup_alternate_shallow(&shallow_lock,
http-push.c
+8 -6
@@ -1447,8 +1447,8 @@ static void one_remote_ref(const char *refname)
1447 * may be required for updating server info later.
1448 */
1449 if (repo->can_update_info_refs &&
1450 - !has_object(the_repository, &ref->old_oid,
1451 - HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {
1450 + !odb_has_object(the_repository->objects, &ref->old_oid,
1451 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {
1452 obj = lookup_unknown_object(the_repository, &ref->old_oid);
1453 fprintf(stderr, " fetch %s for %s\n",
1454 oid_to_hex(&ref->old_oid), refname);
@@ -1653,14 +1653,16 @@ static int delete_remote_branch(const char *pattern, int force)
1653 return error("Remote HEAD symrefs too deep");
1654 if (is_null_oid(&head_oid))
1655 return error("Unable to resolve remote HEAD");
1656 - if (!has_object(the_repository, &head_oid, HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
1656 + if (!odb_has_object(the_repository->objects, &head_oid,
1657 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
1658 return error("Remote HEAD resolves to object %s\nwhich does not exist locally, perhaps you need to fetch?", oid_to_hex(&head_oid));
1659
1660 /* Remote branch must resolve to a known object */
1661 if (is_null_oid(&remote_ref->old_oid))
1662 return error("Unable to resolve remote branch %s",
1663 remote_ref->name);
1663 - if (!has_object(the_repository, &remote_ref->old_oid, HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
1664 + if (!odb_has_object(the_repository->objects, &remote_ref->old_oid,
1665 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
1666 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));
1667
1668 /* Remote branch must be an ancestor of remote HEAD */
@@ -1881,8 +1883,8 @@ int cmd_main(int argc, const char **argv)
1883 if (!force_all &&
1884 !is_null_oid(&ref->old_oid) &&
1885 !ref->force) {
1884 - if (!has_object(the_repository, &ref->old_oid,
1885 - HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) ||
1886 + if (!odb_has_object(the_repository->objects, &ref->old_oid,
1887 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) ||
1888 !ref_newer(&ref->peer_ref->new_oid,
1889 &ref->old_oid)) {
1890 /*
http-walker.c
+4 -4
@@ -138,8 +138,8 @@ static int fill_active_slot(void *data UNUSED)
138 list_for_each_safe(pos, tmp, head) {
139 obj_req = list_entry(pos, struct object_request, node);
140 if (obj_req->state == WAITING) {
141 - if (has_object(the_repository, &obj_req->oid,
142 - HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
141 + if (odb_has_object(the_repository->objects, &obj_req->oid,
142 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
143 obj_req->state = COMPLETE;
144 else {
145 start_object_request(obj_req);
@@ -497,8 +497,8 @@ static int fetch_object(struct walker *walker, const struct object_id *oid)
497 if (!obj_req)
498 return error("Couldn't find request for %s in the queue", hex);
499
500 - if (has_object(the_repository, &obj_req->oid,
501 - HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {
500 + if (odb_has_object(the_repository->objects, &obj_req->oid,
501 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {
502 if (obj_req->req)
503 abort_http_object_request(&obj_req->req);
504 abort_object_request(obj_req);
list-objects.c
+2 -2
@@ -74,8 +74,8 @@ static void process_blob(struct traversal_context *ctx,
74 * of missing objects.
75 */
76 if (ctx->revs->exclude_promisor_objects &&
77 - !has_object(the_repository, &obj->oid,
78 - HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) &&
77 + !odb_has_object(the_repository->objects, &obj->oid,
78 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) &&
79 is_promisor_object(ctx->revs->repo, &obj->oid))
80 return;
81
notes.c
+2 -2
@@ -794,8 +794,8 @@ static int prune_notes_helper(const struct object_id *object_oid,
794 struct note_delete_list **l = (struct note_delete_list **) cb_data;
795 struct note_delete_list *n;
796
797 - if (has_object(the_repository, object_oid,
798 - HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
797 + if (odb_has_object(the_repository->objects, object_oid,
798 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
799 return 0; /* nothing to do for this note */
800
801 /* failed to find object => prune this note */
odb.c
+3 -3
@@ -871,7 +871,7 @@ int pretend_object_file(struct repository *repo,
871 char *co_buf;
872
873 hash_object_file(repo->hash_algo, buf, len, type, oid);
874 - if (has_object(repo, oid, 0) ||
874 + if (odb_has_object(repo->objects, oid, 0) ||
875 find_cached_object(repo->objects, oid))
876 return 0;
877
@@ -953,7 +953,7 @@ void *read_object_with_reference(struct repository *r,
953 }
954 }
955
956 -int has_object(struct repository *r, const struct object_id *oid,
956 +int odb_has_object(struct object_database *odb, const struct object_id *oid,
957 unsigned flags)
958 {
959 unsigned object_info_flags = 0;
@@ -965,7 +965,7 @@ int has_object(struct repository *r, const struct object_id *oid,
965 if (!(flags & HAS_OBJECT_FETCH_PROMISOR))
966 object_info_flags |= OBJECT_INFO_SKIP_FETCH_OBJECT;
967
968 - return odb_read_object_info_extended(r->objects, oid, NULL, object_info_flags) >= 0;
968 + return odb_read_object_info_extended(odb, oid, NULL, object_info_flags) >= 0;
969 }
970
971 void odb_assert_oid_type(struct object_database *odb,
odb.h
+10 -2
@@ -372,8 +372,9 @@ enum {
372 * Returns 1 if the object exists. This function will not lazily fetch objects
373 * in a partial clone by default.
374 */
375 -int has_object(struct repository *r, const struct object_id *oid,
376 - unsigned flags);
375 +int odb_has_object(struct object_database *odb,
376 + const struct object_id *oid,
377 + unsigned flags);
378
379 void odb_assert_oid_type(struct object_database *odb,
380 const struct object_id *oid, enum object_type expect);
@@ -463,4 +464,11 @@ static inline void *repo_read_object_file(struct repository *r,
464 return odb_read_object(r->objects, oid, type, size);
465 }
466
467 +static inline int has_object(struct repository *r,
468 + const struct object_id *oid,
469 + unsigned flags)
470 +{
471 + return odb_has_object(r->objects, oid, flags);
472 +}
473 +
474 #endif /* ODB_H */
reflog.c
+1 -1
@@ -152,7 +152,7 @@ static int tree_is_complete(const struct object_id *oid)
152 init_tree_desc(&desc, &tree->object.oid, tree->buffer, tree->size);
153 complete = 1;
154 while (tree_entry(&desc, &entry)) {
155 - if (!has_object(the_repository, &entry.oid,
155 + if (!odb_has_object(the_repository->objects, &entry.oid,
156 HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) ||
157 (S_ISDIR(entry.mode) && !tree_is_complete(&entry.oid))) {
158 tree->object.flags |= INCOMPLETE;
refs.c
+2 -1
@@ -376,7 +376,8 @@ int ref_resolves_to_object(const char *refname,
376 {
377 if (flags & REF_ISBROKEN)
378 return 0;
379 - if (!has_object(repo, oid, HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {
379 + if (!odb_has_object(repo->objects, oid,
380 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {
381 error(_("%s does not point to a valid object!"), refname);
382 return 0;
383 }
remote.c
+1 -1
@@ -1703,7 +1703,7 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
1703 if (!reject_reason && !ref->deletion && !is_null_oid(&ref->old_oid)) {
1704 if (starts_with(ref->name, "refs/tags/"))
1705 reject_reason = REF_STATUS_REJECT_ALREADY_EXISTS;
1706 - else if (!has_object(the_repository, &ref->old_oid, HAS_OBJECT_RECHECK_PACKED))
1706 + else if (!odb_has_object(the_repository->objects, &ref->old_oid, HAS_OBJECT_RECHECK_PACKED))
1707 reject_reason = REF_STATUS_REJECT_FETCH_FIRST;
1708 else if (!lookup_commit_reference_gently(the_repository, &ref->old_oid, 1) ||
1709 !lookup_commit_reference_gently(the_repository, &ref->new_oid, 1))
send-pack.c
+1 -1
@@ -45,7 +45,7 @@ int option_parse_push_signed(const struct option *opt,
45 static void feed_object(struct repository *r,
46 const struct object_id *oid, FILE *fh, int negative)
47 {
48 - if (negative && !has_object(r, oid, 0))
48 + if (negative && !odb_has_object(r->objects, oid, 0))
49 return;
50
51 if (negative)
shallow.c
+6 -6
@@ -310,8 +310,8 @@ static int write_one_shallow(const struct commit_graft *graft, void *cb_data)
310 if (graft->nr_parent != -1)
311 return 0;
312 if (data->flags & QUICK) {
313 - if (!has_object(the_repository, &graft->oid,
314 - HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
313 + if (!odb_has_object(the_repository->objects, &graft->oid,
314 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
315 return 0;
316 } else if (data->flags & SEEN_ONLY) {
317 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)
477 ALLOC_ARRAY(info->ours, sa->nr);
478 ALLOC_ARRAY(info->theirs, sa->nr);
479 for (size_t i = 0; i < sa->nr; i++) {
480 - if (has_object(the_repository, sa->oid + i,
481 - HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {
480 + if (odb_has_object(the_repository->objects, sa->oid + i,
481 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {
482 struct commit_graft *graft;
483 graft = lookup_commit_graft(the_repository,
484 &sa->oid[i]);
@@ -515,8 +515,8 @@ void remove_nonexistent_theirs_shallow(struct shallow_info *info)
515 for (i = dst = 0; i < info->nr_theirs; i++) {
516 if (i != dst)
517 info->theirs[dst] = info->theirs[i];
518 - if (has_object(the_repository, oid + info->theirs[i],
519 - HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
518 + if (odb_has_object(the_repository->objects, oid + info->theirs[i],
519 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
520 dst++;
521 }
522 info->nr_theirs = dst;
upload-pack.c
+1 -1
@@ -509,7 +509,7 @@ static int got_oid(struct upload_pack_data *data,
509 {
510 if (get_oid_hex(hex, oid))
511 die("git upload-pack: expected SHA1 object, got '%s'", hex);
512 - if (!has_object(the_repository, oid, 0))
512 + if (!odb_has_object(the_repository->objects, oid, 0))
513 return -1;
514 return do_got_oid(data, oid);
515 }
walker.c
+2 -2
@@ -150,8 +150,8 @@ static int process(struct walker *walker, struct object *obj)
150 return 0;
151 obj->flags |= SEEN;
152
153 - if (has_object(the_repository, &obj->oid,
154 - HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {
153 + if (odb_has_object(the_repository->objects, &obj->oid,
154 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {
155 /* We already have it, so we should scan it now. */
156 obj->flags |= TO_SCAN;
157 }