git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 1/3] refs: make sha1 output parameter of refs_resolve_ref_unsafe() optional
@ 2017-09-23  9:41 René Scharfe
  2017-09-23  9:44 ` [PATCH 2/3] refs: pass NULL to refs_resolve_ref_unsafe() if hash is not needed René Scharfe
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: René Scharfe @ 2017-09-23  9:41 UTC (permalink / raw)
  To: Git List; +Cc: Junio C Hamano, Michael Haggerty

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>
---
 refs.c | 3 +++
 refs.h | 9 +++++----
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/refs.c b/refs.c
index c30f4c36be..36439fdb54 100644
--- a/refs.c
+++ b/refs.c
@@ -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;
 
diff --git a/refs.h b/refs.h
index 78a26400b6..996d4ea54d 100644
--- a/refs.h
+++ b/refs.h
@@ -10,10 +10,11 @@ struct worktree;
 /*
  * Resolve a reference, recursively following symbolic refererences.
  *
- * Store the referred-to object's name in sha1 and return the name of
- * the non-symbolic reference that ultimately pointed at it.  The
- * return value, if not NULL, is a pointer into either a static buffer
- * or the input ref.
+ * Return the name of the non-symbolic reference that ultimately pointed
+ * at the resolved object name.  The return value, if not NULL, is a
+ * pointer into either a static buffer 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
  * depends on the RESOLVE_REF_READING flag:
-- 
2.14.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-10-01  8:29 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-23  9:41 [PATCH 1/3] refs: make sha1 output parameter of refs_resolve_ref_unsafe() optional René Scharfe
2017-09-23  9:44 ` [PATCH 2/3] refs: pass NULL to refs_resolve_ref_unsafe() if hash is not needed René Scharfe
2017-09-23  9:45 ` [PATCH 3/3] refs: pass NULL to resolve_ref_unsafe() " René Scharfe
2017-09-24  1:26 ` [PATCH 1/3] refs: make sha1 output parameter of refs_resolve_ref_unsafe() optional Junio C Hamano
2017-09-24 12:39   ` René Scharfe
2017-10-01  7:28 ` [PATCH 4/3] refs: pass NULL to refs_resolve_refdup() if hash is not needed René Scharfe
2017-10-01  7:29 ` [PATCH 5/3] refs: pass NULL to resolve_refdup() " René Scharfe
2017-10-01  8:29   ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).