]> git.ipfire.org Git - thirdparty/git.git/commit
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)
commit062b914c841329a003f74e1340ea5178391274a6
tree0339100263b007798bb28ddf8f9b3dc443f2d800
parentf8fc4cacd37afa254a8822258f76de53ae2dfbb2
treewide: convert users of `repo_has_object_file()` to `has_object()`

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