From 8738a8a4df9ee50112b5f5a757c58988166974d3 Mon Sep 17 00:00:00 2001 From: Michael Haggerty Date: Wed, 13 Sep 2017 19:15:55 +0200 Subject: ref_iterator: keep track of whether the iterator output is ordered References are iterated over in order by refname, but reflogs are not. Some consumers of reference iteration care about the difference. Teach each `ref_iterator` to keep track of whether its output is ordered. `overlay_ref_iterator` is one of the picky consumers. Add a sanity check in `overlay_ref_iterator_begin()` to verify that its inputs are ordered. Signed-off-by: Michael Haggerty Signed-off-by: Junio C Hamano --- refs.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'refs.c') diff --git a/refs.c b/refs.c index b0106b816..101c107ee 100644 --- a/refs.c +++ b/refs.c @@ -1309,6 +1309,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; } -- cgit v1.2.1