Skip to content

Commit

Permalink
for_each_reflog_ent_reverse: turn leftover check into assertion
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jeff King authored and Junio C Hamano committed Dec 5, 2014
1 parent e5e73ff commit 69216bf
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion refs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 69216bf

Please sign in to comment.