aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2017-03-20 17:33:07 +0100
committerJunio C Hamano <gitster@pobox.com>2017-04-14 03:54:31 -0700
commit470be518623b0ca7a30bdb1fcef483f63a8e72ec (patch)
tree48eea01b7ed599b8e4c5aeb8a962367db721b510
parent68fb02e40de22d38cb8988c524e31f93dc40c224 (diff)
downloadgit-470be518623b0ca7a30bdb1fcef483f63a8e72ec.tar.gz
git-470be518623b0ca7a30bdb1fcef483f63a8e72ec.tar.xz
refs_read_raw_ref(): new function
Extract a new function from `refs_resolve_ref_unsafe()`. It will be useful elsewhere. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--refs.c11
-rw-r--r--refs/refs-internal.h4
2 files changed, 13 insertions, 2 deletions
diff --git a/refs.c b/refs.c
index bad05ba86..aa461156c 100644
--- a/refs.c
+++ b/refs.c
@@ -1326,6 +1326,13 @@ int for_each_rawref(each_ref_fn fn, void *cb_data)
return refs_for_each_rawref(get_main_ref_store(), fn, cb_data);
}
+int refs_read_raw_ref(struct ref_store *ref_store,
+ const char *refname, unsigned char *sha1,
+ struct strbuf *referent, unsigned int *type)
+{
+ return ref_store->be->read_raw_ref(ref_store, refname, sha1, referent, type);
+}
+
/* This function needs to return a meaningful errno on failure */
const char *refs_resolve_ref_unsafe(struct ref_store *refs,
const char *refname,
@@ -1362,8 +1369,8 @@ const char *refs_resolve_ref_unsafe(struct ref_store *refs,
for (symref_count = 0; symref_count < SYMREF_MAXDEPTH; symref_count++) {
unsigned int read_flags = 0;
- if (refs->be->read_raw_ref(refs, refname,
- sha1, &sb_refname, &read_flags)) {
+ if (refs_read_raw_ref(refs, refname,
+ sha1, &sb_refname, &read_flags)) {
*flags |= read_flags;
if (errno != ENOENT || (resolve_flags & RESOLVE_REF_READING))
return NULL;
diff --git a/refs/refs-internal.h b/refs/refs-internal.h
index 690498698..6ee9f20db 100644
--- a/refs/refs-internal.h
+++ b/refs/refs-internal.h
@@ -165,6 +165,10 @@ struct ref_update {
const char refname[FLEX_ARRAY];
};
+int refs_read_raw_ref(struct ref_store *ref_store,
+ const char *refname, unsigned char *sha1,
+ struct strbuf *referent, unsigned int *type);
+
/*
* Add a ref_update with the specified properties to transaction, and
* return a pointer to the new object. This function does not verify