summaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2016-09-04 18:08:21 +0200
committerJunio C Hamano <gitster@pobox.com>2016-09-09 15:28:13 -0700
commitbd40dcda27cc7d6b8b247caa5b650992c5e397fb (patch)
tree0cf038403818ca5deab3b7d986613bb7439598f8 /refs.c
parent34c7ad8ffc79c64d7f2261e6bcf6efd3adb16e7e (diff)
downloadgit-bd40dcda27cc7d6b8b247caa5b650992c5e397fb.tar.gz
resolve_ref_recursively(): new function
Add a new function, resolve_ref_recursively(), which is basically like the old resolve_ref_unsafe() except that it takes a (ref_store *) argument and also works for submodules. Re-implement resolve_ref_unsafe() as a thin wrapper around resolve_ref_recursively(). Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/refs.c b/refs.c
index b3a775e640..464fe71928 100644
--- a/refs.c
+++ b/refs.c
@@ -1216,13 +1216,14 @@ int for_each_rawref(each_ref_fn fn, void *cb_data)
}
/* This function needs to return a meaningful errno on failure */
-const char *resolve_ref_unsafe(const char *refname, int resolve_flags,
- unsigned char *sha1, int *flags)
+static const char *resolve_ref_recursively(struct ref_store *refs,
+ const char *refname,
+ int resolve_flags,
+ unsigned char *sha1, int *flags)
{
static struct strbuf sb_refname = STRBUF_INIT;
int unused_flags;
int symref_count;
- struct ref_store *refs = get_ref_store(NULL);
if (!flags)
flags = &unused_flags;
@@ -1291,6 +1292,13 @@ const char *resolve_ref_unsafe(const char *refname, int resolve_flags,
return NULL;
}
+const char *resolve_ref_unsafe(const char *refname, int resolve_flags,
+ unsigned char *sha1, int *flags)
+{
+ return resolve_ref_recursively(get_ref_store(NULL), refname,
+ resolve_flags, sha1, flags);
+}
+
/* A pointer to the ref_store for the main repository: */
static struct ref_store *main_ref_store;