refs: add referent to each_ref_fn

Add a parameter to each_ref_fn so that callers to the ref APIs
that use this function as a callback can have acess to the
unresolved value of a symbolic ref.

Signed-off-by: John Cai <johncai86@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
John Cai
2024-08-09 15:37:50 +00:00
committed by Junio C Hamano
parent cfd971520e
commit e8207717f1
48 changed files with 78 additions and 54 deletions

View File

@ -77,7 +77,7 @@ struct ls_refs_data {
unsigned unborn : 1;
};
static int send_ref(const char *refname, const struct object_id *oid,
static int send_ref(const char *refname, const char *referent UNUSED, const struct object_id *oid,
int flag, void *cb_data)
{
struct ls_refs_data *data = cb_data;
@ -135,7 +135,7 @@ static void send_possibly_unborn_head(struct ls_refs_data *data)
oid_is_null = is_null_oid(&oid);
if (!oid_is_null ||
(data->unborn && data->symrefs && (flag & REF_ISSYMREF)))
send_ref(namespaced.buf, oid_is_null ? NULL : &oid, flag, data);
send_ref(namespaced.buf, NULL, oid_is_null ? NULL : &oid, flag, data);
strbuf_release(&namespaced);
}