Skip to content

Commit 6d40f0a

Browse files
avargitster
authored andcommitted
cache-tree.c: use bug() and BUG_if_bug()
Change "BUG" output originally added in a97e407 (Keep rename/rename conflicts of intermediate merges while doing recursive merge, 2007-03-31), and later made to say it was a "BUG" in 19c6a4f (merge-recursive: do not return NULL only to cause segfault, 2010-01-21) to use the new bug() function. This gets the same job done with slightly less code, as we won't need to prefix lines with "BUG: ". More importantly we'll now log the full set of messages via trace2, before this we'd only log the one BUG() invocation. We don't replace the last "BUG()" invocation with "BUG_if_bug()", as in this case we're sure that we called bug() earlier, so there's no need to make it a conditional. While we're at it let's replace "There" with "there" in the message, i.e. not start a message with a capital letter, per the CodingGuidelines. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 07b1d8f commit 6d40f0a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

cache-tree.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -692,14 +692,14 @@ struct tree* write_in_core_index_as_tree(struct repository *repo) {
692692
ret = write_index_as_tree_internal(&o, index_state, was_valid, 0, NULL);
693693
if (ret == WRITE_TREE_UNMERGED_INDEX) {
694694
int i;
695-
fprintf(stderr, "BUG: There are unmerged index entries:\n");
695+
bug("there are unmerged index entries:");
696696
for (i = 0; i < index_state->cache_nr; i++) {
697697
const struct cache_entry *ce = index_state->cache[i];
698698
if (ce_stage(ce))
699-
fprintf(stderr, "BUG: %d %.*s\n", ce_stage(ce),
700-
(int)ce_namelen(ce), ce->name);
699+
bug("%d %.*s", ce_stage(ce),
700+
(int)ce_namelen(ce), ce->name);
701701
}
702-
BUG("unmerged index entries when writing inmemory index");
702+
BUG("unmerged index entries when writing in-core index");
703703
}
704704

705705
return lookup_tree(repo, &index_state->cache_tree->oid);

0 commit comments

Comments
 (0)