aboutsummaryrefslogtreecommitdiffstats
path: root/object-file.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2025-07-17 06:56:30 +0200
committerJunio C Hamano <gitster@pobox.com>2025-07-16 22:16:13 -0700
commitf6638bf55d0c611b86873cc1c88b0dac3bc653e2 (patch)
treeea2db280eb13e6f67af81757aaed34672b1c6f52 /object-file.c
parentobject-file: get rid of `the_repository` in `has_loose_object()` (diff)
downloadgit-f6638bf55d0c611b86873cc1c88b0dac3bc653e2.tar.gz
git-f6638bf55d0c611b86873cc1c88b0dac3bc653e2.zip
object-file: inline `check_and_freshen()` functions
The `check_and_freshen()` functions are only used by a single caller now. Inline them into `freshen_loose_object()`. While at it, rename `check_and_freshen_odb()` to `_source()` to reflect that it works on a single object source instead of on the whole database. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'object-file.c')
-rw-r--r--object-file.c41
1 files changed, 13 insertions, 28 deletions
diff --git a/object-file.c b/object-file.c
index 7aecaa3d2a..9e17e608f7 100644
--- a/object-file.c
+++ b/object-file.c
@@ -89,42 +89,19 @@ int check_and_freshen_file(const char *fn, int freshen)
return 1;
}
-static int check_and_freshen_odb(struct odb_source *source,
- const struct object_id *oid,
- int freshen)
+static int check_and_freshen_source(struct odb_source *source,
+ const struct object_id *oid,
+ int freshen)
{
static struct strbuf path = STRBUF_INIT;
odb_loose_path(source, &path, oid);
return check_and_freshen_file(path.buf, freshen);
}
-static int check_and_freshen_local(const struct object_id *oid, int freshen)
-{
- return check_and_freshen_odb(the_repository->objects->sources, oid, freshen);
-}
-
-static int check_and_freshen_nonlocal(const struct object_id *oid, int freshen)
-{
- struct odb_source *source;
-
- odb_prepare_alternates(the_repository->objects);
- for (source = the_repository->objects->sources->next; source; source = source->next) {
- if (check_and_freshen_odb(source, oid, freshen))
- return 1;
- }
- return 0;
-}
-
-static int check_and_freshen(const struct object_id *oid, int freshen)
-{
- return check_and_freshen_local(oid, freshen) ||
- check_and_freshen_nonlocal(oid, freshen);
-}
-
int has_loose_object(struct odb_source *source,
const struct object_id *oid)
{
- return check_and_freshen_odb(source, oid, 0);
+ return check_and_freshen_source(source, oid, 0);
}
int format_object_header(char *str, size_t size, enum object_type type,
@@ -918,7 +895,15 @@ static int write_loose_object(const struct object_id *oid, char *hdr,
static int freshen_loose_object(const struct object_id *oid)
{
- return check_and_freshen(oid, 1);
+ struct odb_source *source;
+
+ odb_prepare_alternates(the_repository->objects);
+ for (source = the_repository->objects->sources; source; source = source->next) {
+ if (check_and_freshen_source(source, oid, 1))
+ return 1;
+ }
+
+ return 0;
}
static int freshen_packed_object(const struct object_id *oid)