for_each_reflog_ent_reverse: turn leftover check into assertion
authorJeff King <peff@peff.net>
Fri, 5 Dec 2014 01:32:44 +0000 (20:32 -0500)
committerJunio C Hamano <gitster@pobox.com>
Fri, 5 Dec 2014 19:11:52 +0000 (11:11 -0800)
Our loop should always process all lines, even if we hit the
beginning of the file. We have a conditional after the loop
ends to double-check that there is nothing left and to
process it. But this should never happen, and is a sign of a
logic bug in the loop. Let's turn it into a BUG assertion.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs.c
diff --git a/refs.c b/refs.c
index 8ed9aee939a2a5a3e1f67be91e8a5ba6049e2eb6..a421d43211f9d610c8b81ed83893ee4dde02520f 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -3136,7 +3136,7 @@ int for_each_reflog_ent_reverse(const char *refname, each_reflog_ent_fn fn, void
 
        }
        if (!ret && sb.len)
-               ret = show_one_reflog_ent(&sb, fn, cb_data);
+               die("BUG: reverse reflog parser had leftover data");
 
        fclose(logfp);
        strbuf_release(&sb);