refs: make sha1 output parameter of refs_resolve_ref_unsafe() optional
Allow callers of refs_resolve_ref_unsafe() to pass NULL if they don't need the resolved hash value. We already allow the same for the flags parameter. This new leniency is inherited by the various wrappers like resolve_ref_unsafe(). Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
59c0ea183a
commit
54fad6614f
3
refs.c
3
refs.c
@ -1396,9 +1396,12 @@ const char *refs_resolve_ref_unsafe(struct ref_store *refs,
|
|||||||
unsigned char *sha1, int *flags)
|
unsigned char *sha1, int *flags)
|
||||||
{
|
{
|
||||||
static struct strbuf sb_refname = STRBUF_INIT;
|
static struct strbuf sb_refname = STRBUF_INIT;
|
||||||
|
struct object_id unused_oid;
|
||||||
int unused_flags;
|
int unused_flags;
|
||||||
int symref_count;
|
int symref_count;
|
||||||
|
|
||||||
|
if (!sha1)
|
||||||
|
sha1 = unused_oid.hash;
|
||||||
if (!flags)
|
if (!flags)
|
||||||
flags = &unused_flags;
|
flags = &unused_flags;
|
||||||
|
|
||||||
|
9
refs.h
9
refs.h
@ -10,10 +10,11 @@ struct worktree;
|
|||||||
/*
|
/*
|
||||||
* Resolve a reference, recursively following symbolic refererences.
|
* Resolve a reference, recursively following symbolic refererences.
|
||||||
*
|
*
|
||||||
* Store the referred-to object's name in sha1 and return the name of
|
* Return the name of the non-symbolic reference that ultimately pointed
|
||||||
* the non-symbolic reference that ultimately pointed at it. The
|
* at the resolved object name. The return value, if not NULL, is a
|
||||||
* return value, if not NULL, is a pointer into either a static buffer
|
* pointer into either a static buffer or the input ref.
|
||||||
* or the input ref.
|
*
|
||||||
|
* If sha1 is non-NULL, store the referred-to object's name in it.
|
||||||
*
|
*
|
||||||
* If the reference cannot be resolved to an object, the behavior
|
* If the reference cannot be resolved to an object, the behavior
|
||||||
* depends on the RESOLVE_REF_READING flag:
|
* depends on the RESOLVE_REF_READING flag:
|
||||||
|
Loading…
Reference in New Issue
Block a user