mirror of
https://github.com/git/git.git
synced 2025-12-12 20:36:24 +01:00
refs: introduce .ref field for the base iterator
The base iterator has a couple of fields that tracks the name, target, object ID and flags for the current reference. Due to this design we have to create a new `struct reference` whenever we want to hand over that reference to the callback function, which is tedious and not very efficient. Convert the structure to instead contain a `struct reference` as member. This member is expected to be populated by the implementations of the iterator and is handed over to the callback directly. While at it, simplify `should_pack_ref()` to take a `struct reference` directly instead of passing its respective fields. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
bdbebe5714
commit
89baa52da6
8
refs.c
8
refs.c
@@ -2327,8 +2327,8 @@ int refs_optimize(struct ref_store *refs, struct pack_refs_opts *opts)
|
||||
int peel_iterated_oid(struct repository *r, const struct object_id *base, struct object_id *peeled)
|
||||
{
|
||||
if (current_ref_iter &&
|
||||
(current_ref_iter->oid == base ||
|
||||
oideq(current_ref_iter->oid, base)))
|
||||
(current_ref_iter->ref.oid == base ||
|
||||
oideq(current_ref_iter->ref.oid, base)))
|
||||
return ref_iterator_peel(current_ref_iter, peeled);
|
||||
|
||||
return peel_object(r, base, peeled) ? -1 : 0;
|
||||
@@ -2703,7 +2703,7 @@ enum ref_transaction_error refs_verify_refnames_available(struct ref_store *refs
|
||||
|
||||
while ((ok = ref_iterator_advance(iter)) == ITER_OK) {
|
||||
if (skip &&
|
||||
string_list_has_string(skip, iter->refname))
|
||||
string_list_has_string(skip, iter->ref.name))
|
||||
continue;
|
||||
|
||||
if (transaction && ref_transaction_maybe_set_rejected(
|
||||
@@ -2712,7 +2712,7 @@ enum ref_transaction_error refs_verify_refnames_available(struct ref_store *refs
|
||||
continue;
|
||||
|
||||
strbuf_addf(err, _("'%s' exists; cannot create '%s'"),
|
||||
iter->refname, refname);
|
||||
iter->ref.name, refname);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user