Skip to content

Commit 470be51

Browse files
mhaggergitster
authored andcommitted
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>
1 parent 68fb02e commit 470be51

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

refs.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,6 +1326,13 @@ int for_each_rawref(each_ref_fn fn, void *cb_data)
13261326
return refs_for_each_rawref(get_main_ref_store(), fn, cb_data);
13271327
}
13281328

1329+
int refs_read_raw_ref(struct ref_store *ref_store,
1330+
const char *refname, unsigned char *sha1,
1331+
struct strbuf *referent, unsigned int *type)
1332+
{
1333+
return ref_store->be->read_raw_ref(ref_store, refname, sha1, referent, type);
1334+
}
1335+
13291336
/* This function needs to return a meaningful errno on failure */
13301337
const char *refs_resolve_ref_unsafe(struct ref_store *refs,
13311338
const char *refname,
@@ -1362,8 +1369,8 @@ const char *refs_resolve_ref_unsafe(struct ref_store *refs,
13621369
for (symref_count = 0; symref_count < SYMREF_MAXDEPTH; symref_count++) {
13631370
unsigned int read_flags = 0;
13641371

1365-
if (refs->be->read_raw_ref(refs, refname,
1366-
sha1, &sb_refname, &read_flags)) {
1372+
if (refs_read_raw_ref(refs, refname,
1373+
sha1, &sb_refname, &read_flags)) {
13671374
*flags |= read_flags;
13681375
if (errno != ENOENT || (resolve_flags & RESOLVE_REF_READING))
13691376
return NULL;

refs/refs-internal.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,10 @@ struct ref_update {
165165
const char refname[FLEX_ARRAY];
166166
};
167167

168+
int refs_read_raw_ref(struct ref_store *ref_store,
169+
const char *refname, unsigned char *sha1,
170+
struct strbuf *referent, unsigned int *type);
171+
168172
/*
169173
* Add a ref_update with the specified properties to transaction, and
170174
* return a pointer to the new object. This function does not verify

0 commit comments

Comments
 (0)