packed_peel_ref(): new function, extracted from files_peel_ref()

This will later become a method of `packed_ref_store`.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Michael Haggerty
2017-06-23 09:01:34 +02:00
committed by Johannes Schindelin
parent dc892828fd
commit 87b2ccea9b

View File

@@ -1014,6 +1014,18 @@ out:
return ret;
}
static int packed_peel_ref(struct packed_ref_store *refs,
const char *refname, unsigned char *sha1)
{
struct ref_entry *r = get_packed_ref(refs, refname);
if (!r || peel_entry(r, 0))
return -1;
hashcpy(sha1, r->u.value.peeled.hash);
return 0;
}
static int files_peel_ref(struct ref_store *ref_store,
const char *refname, unsigned char *sha1)
{
@@ -1044,17 +1056,9 @@ static int files_peel_ref(struct ref_store *ref_store,
* be expensive and (b) loose references anyway usually do not
* have REF_KNOWS_PEELED.
*/
if (flag & REF_ISPACKED) {
struct ref_entry *r =
get_packed_ref(refs->packed_ref_store, refname);
if (r) {
if (peel_entry(r, 0))
return -1;
hashcpy(sha1, r->u.value.peeled.hash);
return 0;
}
}
if (flag & REF_ISPACKED &&
!packed_peel_ref(refs->packed_ref_store, refname, sha1))
return 0;
return peel_object(base, sha1);
}