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 <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty committed
Sep 25, 2017 at 10:00 UTC
f3987ab36d74382852c0db03ac25e58f83178225
1 file changed
+9
-5
refs/packed-backend.c
+9
-5
@@ -876,18 +876,22 @@ static int packed_read_raw_ref(struct ref_store *ref_store,
876
{
877
struct packed_ref_store *refs =
878
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;
881
882
*type = 0;
883
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. */
888
errno = ENOENT;
889
return -1;
890
}
891
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
+
895
*type = REF_ISPACKED;
896
return 0;
897
}