summaryrefslogtreecommitdiffstats
path: root/refs/ref-cache.c
diff options
context:
space:
mode:
authorJonathan Tan <jonathantanmy@google.com>2021-10-08 23:08:16 +0200
committerJunio C Hamano <gitster@pobox.com>2021-10-09 00:06:06 +0200
commit8788195c8846be949e6cd4bd19c8dc5e6371ffd3 (patch)
tree083f441572e55b2726e2bea2bad031ef317278a6 /refs/ref-cache.c
parentrefs: teach arbitrary repo support to iterators (diff)
downloadgit-8788195c8846be949e6cd4bd19c8dc5e6371ffd3.tar.xz
git-8788195c8846be949e6cd4bd19c8dc5e6371ffd3.zip
refs: peeling non-the_repository iterators is BUG
There is currently no support for peeling the current ref of an iterator iterating over a non-the_repository ref store, and none is needed. Thus, for now, BUG() if that happens. Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs/ref-cache.c')
-rw-r--r--refs/ref-cache.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/refs/ref-cache.c b/refs/ref-cache.c
index 49d732f6db..97a6ac349e 100644
--- a/refs/ref-cache.c
+++ b/refs/ref-cache.c
@@ -435,6 +435,8 @@ struct cache_ref_iterator {
* on from there.)
*/
struct cache_ref_iterator_level *levels;
+
+ struct repository *repo;
};
static int cache_ref_iterator_advance(struct ref_iterator *ref_iterator)
@@ -491,6 +493,11 @@ static int cache_ref_iterator_advance(struct ref_iterator *ref_iterator)
static int cache_ref_iterator_peel(struct ref_iterator *ref_iterator,
struct object_id *peeled)
{
+ struct cache_ref_iterator *iter =
+ (struct cache_ref_iterator *)ref_iterator;
+
+ if (iter->repo != the_repository)
+ BUG("peeling for non-the_repository is not supported");
return peel_object(ref_iterator->oid, peeled) ? -1 : 0;
}
@@ -513,6 +520,7 @@ static struct ref_iterator_vtable cache_ref_iterator_vtable = {
struct ref_iterator *cache_ref_iterator_begin(struct ref_cache *cache,
const char *prefix,
+ struct repository *repo,
int prime_dir)
{
struct ref_dir *dir;
@@ -547,5 +555,7 @@ struct ref_iterator *cache_ref_iterator_begin(struct ref_cache *cache,
level->prefix_state = PREFIX_CONTAINS_DIR;
}
+ iter->repo = repo;
+
return ref_iterator;
}