aboutsummaryrefslogtreecommitdiff
path: root/object-name.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2026-03-20 08:07:30 +0100
committerJunio C Hamano <gitster@pobox.com>2026-03-20 13:16:42 -0700
commit284b7862be735bb47276ac288ace153ae3d06938 (patch)
tree884e93b77a757e03ed237a1d3fde640cb1eeb8e8 /object-name.c
parentcfd575f0a9730712107e4ee6799a37665bcd8204 (diff)
downloadgit-284b7862be735bb47276ac288ace153ae3d06938.tar.xz
object-name: move logic to iterate through loose prefixed objects
The logic to iterate through loose objects that have a certain prefix is currently hosted in "object-name.c". This logic reaches into specifics of the loose object source, so it breaks once a different backend is used for the object storage. Move the logic to iterate through loose objects with a prefix into "object-file.c". This is done by extending the for-each-object options to support an optional prefix that is then honored by the loose source. Naturally, we'll also have this support in the packfile store. This is done in the next commit. Furthermore, there are no users of the loose cache outside of "object-file.c" anymore. As such, convert `odb_source_loose_cache()` to have file scope. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'object-name.c')
-rw-r--r--object-name.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/object-name.c b/object-name.c
index a24a1b48e1..929a68dbd0 100644
--- a/object-name.c
+++ b/object-name.c
@@ -16,7 +16,6 @@
#include "remote.h"
#include "dir.h"
#include "oid-array.h"
-#include "oidtree.h"
#include "packfile.h"
#include "pretty.h"
#include "object-file.h"
@@ -103,7 +102,7 @@ static void update_candidates(struct disambiguate_state *ds, const struct object
static int match_hash(unsigned, const unsigned char *, const unsigned char *);
-static int match_prefix(const struct object_id *oid, void *arg)
+static int match_prefix(const struct object_id *oid, struct object_info *oi UNUSED, void *arg)
{
struct disambiguate_state *ds = arg;
/* no need to call match_hash, oidtree_each did prefix match */
@@ -113,11 +112,14 @@ static int match_prefix(const struct object_id *oid, void *arg)
static void find_short_object_filename(struct disambiguate_state *ds)
{
+ struct odb_for_each_object_options opts = {
+ .prefix = &ds->bin_pfx,
+ .prefix_hex_len = ds->len,
+ };
struct odb_source *source;
for (source = ds->repo->objects->sources; source && !ds->ambiguous; source = source->next)
- oidtree_each(odb_source_loose_cache(source, &ds->bin_pfx),
- &ds->bin_pfx, ds->len, match_prefix, ds);
+ odb_source_loose_for_each_object(source, NULL, match_prefix, ds, &opts);
}
static int match_hash(unsigned len, const unsigned char *a, const unsigned char *b)