Skip to content

Commit f3987ab

Browse files
mhaggergitster
authored andcommitted
packed_read_raw_ref(): read the reference from the mmapped buffer
Instead of reading the reference from the `ref_cache`, read it directly from the mmapped buffer. Signed-off-by: Michael Haggerty <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d1cf155 commit f3987ab

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

refs/packed-backend.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -876,18 +876,22 @@ static int packed_read_raw_ref(struct ref_store *ref_store,
876876
{
877877
struct packed_ref_store *refs =
878878
packed_downcast(ref_store, REF_STORE_READ, "read_raw_ref");
879-
880-
struct ref_entry *entry;
879+
struct packed_ref_cache *packed_refs = get_packed_ref_cache(refs);
880+
const char *rec;
881881

882882
*type = 0;
883883

884-
entry = get_packed_ref(refs, refname);
885-
if (!entry) {
884+
rec = find_reference_location(packed_refs, refname, 1);
885+
886+
if (!rec) {
887+
/* refname is not a packed reference. */
886888
errno = ENOENT;
887889
return -1;
888890
}
889891

890-
hashcpy(sha1, entry->u.value.oid.hash);
892+
if (get_sha1_hex(rec, sha1))
893+
die_invalid_line(refs->path, rec, packed_refs->eof - rec);
894+
891895
*type = REF_ISPACKED;
892896
return 0;
893897
}

0 commit comments

Comments
 (0)