summaryrefslogtreecommitdiff
path: root/refs
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2017-09-25 08:00:13 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-09-25 09:02:45 (GMT)
commitf3987ab36d74382852c0db03ac25e58f83178225 (patch)
tree2871cc9c572f3fb1e0ffccc5a83961bb12a44d14 /refs
parentd1cf15516feb024f34ae5fbbdad8f538b4e62fce (diff)
downloadgit-f3987ab36d74382852c0db03ac25e58f83178225.zip
git-f3987ab36d74382852c0db03ac25e58f83178225.tar.gz
git-f3987ab36d74382852c0db03ac25e58f83178225.tar.bz2
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>
Diffstat (limited to 'refs')
-rw-r--r--refs/packed-backend.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/refs/packed-backend.c b/refs/packed-backend.c
index abf14a1..be614e7 100644
--- a/refs/packed-backend.c
+++ b/refs/packed-backend.c
@@ -876,18 +876,22 @@ static int packed_read_raw_ref(struct ref_store *ref_store,
{
struct packed_ref_store *refs =
packed_downcast(ref_store, REF_STORE_READ, "read_raw_ref");
-
- struct ref_entry *entry;
+ struct packed_ref_cache *packed_refs = get_packed_ref_cache(refs);
+ const char *rec;
*type = 0;
- entry = get_packed_ref(refs, refname);
- if (!entry) {
+ rec = find_reference_location(packed_refs, refname, 1);
+
+ if (!rec) {
+ /* refname is not a packed reference. */
errno = ENOENT;
return -1;
}
- hashcpy(sha1, entry->u.value.oid.hash);
+ if (get_sha1_hex(rec, sha1))
+ die_invalid_line(refs->path, rec, packed_refs->eof - rec);
+
*type = REF_ISPACKED;
return 0;
}