summaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2017-09-28 14:47:56 +0900
committerLibravatar Junio C Hamano <gitster@pobox.com>2017-09-28 14:47:56 +0900
commit73ecdc606eedbfd98ec66d50d44b3374425fd13b (patch)
tree6a2aeb6eb0b30e1645c8af06b10c9f4ec2815dd8 /refs.c
parentMerge branch 'rs/mailinfo-qp-decode-fix' (diff)
parentrefs: pass NULL to resolve_ref_unsafe() if hash is not needed (diff)
downloadtgif-73ecdc606eedbfd98ec66d50d44b3374425fd13b.tar.xz
Merge branch 'rs/resolve-ref-optional-result'
Code clean-up. * rs/resolve-ref-optional-result: refs: pass NULL to resolve_ref_unsafe() if hash is not needed refs: pass NULL to refs_resolve_ref_unsafe() if hash is not needed refs: make sha1 output parameter of refs_resolve_ref_unsafe() optional
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/refs.c b/refs.c
index 83f0e68785..6042645c40 100644
--- a/refs.c
+++ b/refs.c
@@ -239,8 +239,7 @@ int read_ref(const char *refname, unsigned char *sha1)
int ref_exists(const char *refname)
{
- unsigned char sha1[20];
- return !!resolve_ref_unsafe(refname, RESOLVE_REF_READING, sha1, NULL);
+ return !!resolve_ref_unsafe(refname, RESOLVE_REF_READING, NULL, NULL);
}
static int filter_refs(const char *refname, const struct object_id *oid,
@@ -286,12 +285,11 @@ static int warn_if_dangling_symref(const char *refname, const struct object_id *
{
struct warn_if_dangling_data *d = cb_data;
const char *resolves_to;
- struct object_id junk;
if (!(flags & REF_ISSYMREF))
return 0;
- resolves_to = resolve_ref_unsafe(refname, 0, junk.hash, NULL);
+ resolves_to = resolve_ref_unsafe(refname, 0, NULL, NULL);
if (!resolves_to
|| (d->refname
? strcmp(resolves_to, d->refname)
@@ -1398,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;