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:
René Scharfe
2017-09-23 11:41:45 +02:00
committed by Junio C Hamano
parent 59c0ea183a
commit 54fad6614f
2 changed files with 8 additions and 4 deletions

3
refs.c
View File

@ -1396,9 +1396,12 @@ const char *refs_resolve_ref_unsafe(struct ref_store *refs,
unsigned char *sha1, int *flags)
{
static struct strbuf sb_refname = STRBUF_INIT;
struct object_id unused_oid;
int unused_flags;
int symref_count;
if (!sha1)
sha1 = unused_oid.hash;
if (!flags)
flags = &unused_flags;