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>
This commit is contained in:

committed by
Junio C Hamano

parent
9bc45a2802
commit
8788195c88
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user