Skip to content

Commit fcf8e3e

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d4ff88a commit fcf8e3e

30 files changed

+87
-74
lines changed

apply.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3204,7 +3204,7 @@ static int apply_binary(struct apply_state *state,
32043204
return 0; /* deletion patch */
32053205
}
32063206

3207-
if (has_object(the_repository, &oid, 0)) {
3207+
if (odb_has_object(the_repository->objects, &oid, 0)) {
32083208
/* We already have the postimage */
32093209
enum object_type type;
32103210
unsigned long size;

builtin/backfill.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ static int fill_missing_blobs(const char *path UNUSED,
6767
return 0;
6868

6969
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))
7272
oid_array_append(&ctx->current_batch, &list->oid[i]);
7373
}
7474

builtin/cat-file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
160160
goto cleanup;
161161

162162
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);
165165
goto cleanup;
166166

167167
case 'w':

builtin/clone.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ static void write_followtags(const struct ref *refs, const char *msg)
506506
continue;
507507
if (ends_with(ref->name, "^{}"))
508508
continue;
509-
if (!has_object(the_repository, &ref->old_oid, 0))
509+
if (!odb_has_object(the_repository->objects, &ref->old_oid, 0))
510510
continue;
511511
refs_update_ref(get_main_ref_store(the_repository), msg,
512512
ref->name, &ref->old_oid, NULL, 0,

builtin/fetch.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -366,9 +366,9 @@ static void find_non_local_tags(const struct ref *refs,
366366
*/
367367
if (ends_with(ref->name, "^{}")) {
368368
if (item &&
369-
!has_object(the_repository, &ref->old_oid, 0) &&
369+
!odb_has_object(the_repository->objects, &ref->old_oid, 0) &&
370370
!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) &&
372372
!oidset_contains(&fetch_oids, &item->oid))
373373
clear_item(item);
374374
item = NULL;
@@ -382,7 +382,7 @@ static void find_non_local_tags(const struct ref *refs,
382382
* fetch.
383383
*/
384384
if (item &&
385-
!has_object(the_repository, &item->oid, 0) &&
385+
!odb_has_object(the_repository->objects, &item->oid, 0) &&
386386
!oidset_contains(&fetch_oids, &item->oid))
387387
clear_item(item);
388388

@@ -403,7 +403,7 @@ static void find_non_local_tags(const struct ref *refs,
403403
* checked to see if it needs fetching.
404404
*/
405405
if (item &&
406-
!has_object(the_repository, &item->oid, 0) &&
406+
!odb_has_object(the_repository->objects, &item->oid, 0) &&
407407
!oidset_contains(&fetch_oids, &item->oid))
408408
clear_item(item);
409409

@@ -910,8 +910,8 @@ static int update_local_ref(struct ref *ref,
910910
struct commit *current = NULL, *updated;
911911
int fast_forward = 0;
912912

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))
915915
die(_("object %s not found"), oid_to_hex(&ref->new_oid));
916916

917917
if (oideq(&ref->old_oid, &ref->new_oid)) {
@@ -1330,7 +1330,8 @@ static int check_exist_and_connected(struct ref *ref_map)
13301330
* we need all direct targets to exist.
13311331
*/
13321332
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))
13341335
return -1;
13351336
}
13361337

@@ -1485,7 +1486,7 @@ static void add_negotiation_tips(struct git_transport_options *smart_options)
14851486
struct object_id oid;
14861487
if (repo_get_oid(the_repository, s, &oid))
14871488
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))
14891490
die(_("the object %s does not exist"), s);
14901491
oid_array_append(oids, &oid);
14911492
continue;

builtin/fsck.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ static int mark_object(struct object *obj, enum object_type type,
161161
return 0;
162162

163163
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)) {
165165
printf_ln(_("broken link from %7s %s\n"
166166
" to %7s %s"),
167167
printable_type(&parent->oid, parent->type),

builtin/index-pack.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -893,8 +893,8 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
893893

894894
if (startup_info->have_repository) {
895895
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);
898898
read_unlock();
899899
}
900900

builtin/pack-objects.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3968,7 +3968,7 @@ static void show_object__ma_allow_any(struct object *obj, const char *name, void
39683968
* Quietly ignore ALL missing objects. This avoids problems with
39693969
* staging them now and getting an odd error later.
39703970
*/
3971-
if (!has_object(the_repository, &obj->oid, 0))
3971+
if (!odb_has_object(the_repository->objects, &obj->oid, 0))
39723972
return;
39733973

39743974
show_object(obj, name, data);
@@ -3982,7 +3982,7 @@ static void show_object__ma_allow_promisor(struct object *obj, const char *name,
39823982
* Quietly ignore EXPECTED missing objects. This avoids problems with
39833983
* staging them now and getting an odd error later.
39843984
*/
3985-
if (!has_object(the_repository, &obj->oid, 0) &&
3985+
if (!odb_has_object(the_repository->objects, &obj->oid, 0) &&
39863986
is_promisor_object(to_pack.repo, &obj->oid))
39873987
return;
39883988

builtin/receive-pack.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,8 +1509,8 @@ static const char *update(struct command *cmd, struct shallow_info *si)
15091509
}
15101510

15111511
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)) {
15141514
error("unpack should have generated %s, "
15151515
"but I can't find it!", oid_to_hex(new_oid));
15161516
ret = "bad pack";

builtin/remote.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,8 +454,8 @@ static int get_push_ref_states(const struct ref *remote_refs,
454454
info->status = PUSH_STATUS_UPTODATE;
455455
else if (is_null_oid(&ref->old_oid))
456456
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) &&
459459
ref_newer(&ref->new_oid, &ref->old_oid))
460460
info->status = PUSH_STATUS_FASTFORWARD;
461461
else

0 commit comments

Comments
 (0)