Skip to content

Commit 6dc6ba7

Browse files
mhaggergitster
authored andcommitted
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>
1 parent 0f199b1 commit 6dc6ba7

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

refs/files-backend.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,6 +1013,18 @@ static int lock_raw_ref(struct files_ref_store *refs,
10131013
return ret;
10141014
}
10151015

1016+
static int packed_peel_ref(struct packed_ref_store *refs,
1017+
const char *refname, unsigned char *sha1)
1018+
{
1019+
struct ref_entry *r = get_packed_ref(refs, refname);
1020+
1021+
if (!r || peel_entry(r, 0))
1022+
return -1;
1023+
1024+
hashcpy(sha1, r->u.value.peeled.hash);
1025+
return 0;
1026+
}
1027+
10161028
static int files_peel_ref(struct ref_store *ref_store,
10171029
const char *refname, unsigned char *sha1)
10181030
{
@@ -1043,17 +1055,9 @@ static int files_peel_ref(struct ref_store *ref_store,
10431055
* be expensive and (b) loose references anyway usually do not
10441056
* have REF_KNOWS_PEELED.
10451057
*/
1046-
if (flag & REF_ISPACKED) {
1047-
struct ref_entry *r =
1048-
get_packed_ref(refs->packed_ref_store, refname);
1049-
1050-
if (r) {
1051-
if (peel_entry(r, 0))
1052-
return -1;
1053-
hashcpy(sha1, r->u.value.peeled.hash);
1054-
return 0;
1055-
}
1056-
}
1058+
if (flag & REF_ISPACKED &&
1059+
!packed_peel_ref(refs->packed_ref_store, refname, sha1))
1060+
return 0;
10571061

10581062
return peel_object(base, sha1);
10591063
}

0 commit comments

Comments
 (0)