summaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-10-03 15:42:50 +0900
committerJunio C Hamano <gitster@pobox.com>2017-10-03 15:42:50 +0900
commit1a2e1a76ec2cbbafe60ffd124f673f62045fb0d3 (patch)
tree91595ea0e1c159a7422b484c698e258de1579d72 /refs.c
parent9124cca61f7edfed70dc5d8bced7fb7cb9fe2221 (diff)
parentcff28ca94cca0fd4712aa37f6ca93430bb3351d8 (diff)
downloadgit-1a2e1a76ec2cbbafe60ffd124f673f62045fb0d3.tar.gz
Merge branch 'mh/mmap-packed-refs'
Operations that do not touch (majority of) packed refs have been optimized by making accesses to packed-refs file lazy; we no longer pre-parse everything, and an access to a single ref in the packed-refs does not touch majority of irrelevant refs, either. * mh/mmap-packed-refs: (21 commits) packed-backend.c: rename a bunch of things and update comments mmapped_ref_iterator: inline into `packed_ref_iterator` ref_cache: remove support for storing peeled values packed_ref_store: get rid of the `ref_cache` entirely ref_store: implement `refs_peel_ref()` generically packed_read_raw_ref(): read the reference from the mmapped buffer packed_ref_iterator_begin(): iterate using `mmapped_ref_iterator` read_packed_refs(): ensure that references are ordered when read packed_ref_cache: keep the `packed-refs` file mmapped if possible packed-backend.c: reorder some definitions mmapped_ref_iterator_advance(): no peeled value for broken refs mmapped_ref_iterator: add iterator over a packed-refs file packed_ref_cache: remember the file-wide peeling state read_packed_refs(): read references with minimal copying read_packed_refs(): make parsing of the header line more robust read_packed_refs(): only check for a header at the top of the file read_packed_refs(): use mmap to read the `packed-refs` file die_unterminated_line(), die_invalid_line(): new functions packed_ref_cache: add a backlink to the associated `packed_ref_store` prefix_ref_iterator: break when we leave the prefix ...
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/refs.c b/refs.c
index 6cfd88ff6b..df075fcd06 100644
--- a/refs.c
+++ b/refs.c
@@ -1285,6 +1285,10 @@ struct ref_iterator *refs_ref_iterator_begin(
if (trim)
iter = prefix_ref_iterator_begin(iter, "", trim);
+ /* Sanity check for subclasses: */
+ if (!iter->ordered)
+ BUG("reference iterator is not ordered");
+
return iter;
}
@@ -1686,7 +1690,23 @@ int refs_pack_refs(struct ref_store *refs, unsigned int flags)
int refs_peel_ref(struct ref_store *refs, const char *refname,
unsigned char *sha1)
{
- return refs->be->peel_ref(refs, refname, sha1);
+ int flag;
+ unsigned char base[20];
+
+ if (current_ref_iter && current_ref_iter->refname == refname) {
+ struct object_id peeled;
+
+ if (ref_iterator_peel(current_ref_iter, &peeled))
+ return -1;
+ hashcpy(sha1, peeled.hash);
+ return 0;
+ }
+
+ if (refs_read_ref_full(refs, refname,
+ RESOLVE_REF_READING, base, &flag))
+ return -1;
+
+ return peel_object(base, sha1);
}
int peel_ref(const char *refname, unsigned char *sha1)