die("bug"): report bugs consistently

The vast majority of error messages in Git's source code which report a
bug use the convention to prefix the message with "BUG:".

As part of cleaning up merge-recursive to stop die()ing except in case of
detected bugs, let's just make the remainder of the bug reports consistent
with the de facto rule.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Johannes Schindelin
2016-07-26 18:05:50 +02:00
committed by Junio C Hamano
parent 3be18b47e4
commit ef1177d18e
9 changed files with 21 additions and 21 deletions

View File

@@ -118,7 +118,8 @@ static void show_killed_files(struct dir_struct *dir)
*/ */
pos = cache_name_pos(ent->name, ent->len); pos = cache_name_pos(ent->name, ent->len);
if (0 <= pos) if (0 <= pos)
die("bug in show-killed-files"); die("BUG: killed-file %.*s not found",
ent->len, ent->name);
pos = -pos - 1; pos = -pos - 1;
while (pos < active_nr && while (pos < active_nr &&
ce_stage(active_cache[pos])) ce_stage(active_cache[pos]))

View File

@@ -1146,7 +1146,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
report(_("Untracked cache enabled for '%s'"), get_git_work_tree()); report(_("Untracked cache enabled for '%s'"), get_git_work_tree());
break; break;
default: default:
die("Bug: bad untracked_cache value: %d", untracked_cache); die("BUG: bad untracked_cache value: %d", untracked_cache);
} }
if (active_cache_changed) { if (active_cache_changed) {

8
grep.c
View File

@@ -693,10 +693,10 @@ static struct grep_expr *prep_header_patterns(struct grep_opt *opt)
for (p = opt->header_list; p; p = p->next) { for (p = opt->header_list; p; p = p->next) {
if (p->token != GREP_PATTERN_HEAD) if (p->token != GREP_PATTERN_HEAD)
die("bug: a non-header pattern in grep header list."); die("BUG: a non-header pattern in grep header list.");
if (p->field < GREP_HEADER_FIELD_MIN || if (p->field < GREP_HEADER_FIELD_MIN ||
GREP_HEADER_FIELD_MAX <= p->field) GREP_HEADER_FIELD_MAX <= p->field)
die("bug: unknown header field %d", p->field); die("BUG: unknown header field %d", p->field);
compile_regexp(p, opt); compile_regexp(p, opt);
} }
@@ -709,7 +709,7 @@ static struct grep_expr *prep_header_patterns(struct grep_opt *opt)
h = compile_pattern_atom(&pp); h = compile_pattern_atom(&pp);
if (!h || pp != p->next) if (!h || pp != p->next)
die("bug: malformed header expr"); die("BUG: malformed header expr");
if (!header_group[p->field]) { if (!header_group[p->field]) {
header_group[p->field] = h; header_group[p->field] = h;
continue; continue;
@@ -1514,7 +1514,7 @@ static int grep_source_1(struct grep_opt *opt, struct grep_source *gs, int colle
case GREP_BINARY_TEXT: case GREP_BINARY_TEXT:
break; break;
default: default:
die("bug: unknown binary handling mode"); die("BUG: unknown binary handling mode");
} }
} }

View File

@@ -511,7 +511,7 @@ static int nfsnprintf(char *buf, int blen, const char *fmt, ...)
va_start(va, fmt); va_start(va, fmt);
if (blen <= 0 || (unsigned)(ret = vsnprintf(buf, blen, fmt, va)) >= (unsigned)blen) if (blen <= 0 || (unsigned)(ret = vsnprintf(buf, blen, fmt, va)) >= (unsigned)blen)
die("Fatal: buffer too small. Please report a bug."); die("BUG: buffer too small. Please report a bug.");
va_end(va); va_end(va);
return ret; return ret;
} }

View File

@@ -268,7 +268,7 @@ struct tree *write_tree_from_memory(struct merge_options *o)
fprintf(stderr, "BUG: %d %.*s\n", ce_stage(ce), fprintf(stderr, "BUG: %d %.*s\n", ce_stage(ce),
(int)ce_namelen(ce), ce->name); (int)ce_namelen(ce), ce->name);
} }
die("Bug in merge-recursive.c"); die("BUG: unmerged index entries in merge-recursive.c");
} }
if (!active_cache_tree) if (!active_cache_tree)
@@ -966,9 +966,8 @@ static struct merge_file_info merge_file_1(struct merge_options *o,
if (!oid_eq(&a->oid, &b->oid)) if (!oid_eq(&a->oid, &b->oid))
result.clean = 0; result.clean = 0;
} else { } else
die(_("unsupported object type in the tree")); die(_("BUG: unsupported object type in the tree"));
}
} }
return result; return result;
@@ -1354,7 +1353,7 @@ static int process_renames(struct merge_options *o,
const char *ren2_dst = ren2->pair->two->path; const char *ren2_dst = ren2->pair->two->path;
enum rename_type rename_type; enum rename_type rename_type;
if (strcmp(ren1_src, ren2_src) != 0) if (strcmp(ren1_src, ren2_src) != 0)
die("ren1_src != ren2_src"); die("BUG: ren1_src != ren2_src");
ren2->dst_entry->processed = 1; ren2->dst_entry->processed = 1;
ren2->processed = 1; ren2->processed = 1;
if (strcmp(ren1_dst, ren2_dst) != 0) { if (strcmp(ren1_dst, ren2_dst) != 0) {
@@ -1388,7 +1387,7 @@ static int process_renames(struct merge_options *o,
ren2 = lookup->util; ren2 = lookup->util;
ren2_dst = ren2->pair->two->path; ren2_dst = ren2->pair->two->path;
if (strcmp(ren1_dst, ren2_dst) != 0) if (strcmp(ren1_dst, ren2_dst) != 0)
die("ren1_dst != ren2_dst"); die("BUG: ren1_dst != ren2_dst");
clean_merge = 0; clean_merge = 0;
ren2->processed = 1; ren2->processed = 1;
@@ -1812,7 +1811,7 @@ static int process_entry(struct merge_options *o,
*/ */
remove_file(o, 1, path, !a_mode); remove_file(o, 1, path, !a_mode);
} else } else
die(_("Fatal merge failure, shouldn't happen.")); die(_("BUG: fatal merge failure, shouldn't happen."));
return clean_merge; return clean_merge;
} }
@@ -1870,7 +1869,7 @@ int merge_trees(struct merge_options *o,
for (i = 0; i < entries->nr; i++) { for (i = 0; i < entries->nr; i++) {
struct stage_data *e = entries->items[i].util; struct stage_data *e = entries->items[i].util;
if (!e->processed) if (!e->processed)
die(_("Unprocessed path??? %s"), die(_("BUG: unprocessed path??? %s"),
entries->items[i].string); entries->items[i].string);
} }

View File

@@ -795,7 +795,7 @@ void close_all_packs(void)
for (p = packed_git; p; p = p->next) for (p = packed_git; p; p = p->next)
if (p->do_not_close) if (p->do_not_close)
die("BUG! Want to close pack marked 'do-not-close'"); die("BUG: want to close pack marked 'do-not-close'");
else else
close_pack(p); close_pack(p);
} }
@@ -2330,7 +2330,7 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset,
case OBJ_OFS_DELTA: case OBJ_OFS_DELTA:
case OBJ_REF_DELTA: case OBJ_REF_DELTA:
if (data) if (data)
die("BUG in unpack_entry: left loop at a valid delta"); die("BUG: unpack_entry: left loop at a valid delta");
break; break;
case OBJ_COMMIT: case OBJ_COMMIT:
case OBJ_TREE: case OBJ_TREE:

View File

@@ -562,7 +562,7 @@ static int git_trailer_config(const char *conf_key, const char *value, void *cb)
warning(_("unknown value '%s' for key '%s'"), value, conf_key); warning(_("unknown value '%s' for key '%s'"), value, conf_key);
break; break;
default: default:
die("internal bug in trailer.c"); die("BUG: trailer.c: unhandled type %d", type);
} }
return 0; return 0;
} }

View File

@@ -566,7 +566,7 @@ void transport_take_over(struct transport *transport,
struct git_transport_data *data; struct git_transport_data *data;
if (!transport->smart_options) if (!transport->smart_options)
die("Bug detected: Taking over transport requires non-NULL " die("BUG: taking over transport requires non-NULL "
"smart_options field."); "smart_options field.");
data = xcalloc(1, sizeof(*data)); data = xcalloc(1, sizeof(*data));

View File

@@ -263,7 +263,7 @@ static const char *wt_status_unmerged_status_string(int stagemask)
case 7: case 7:
return _("both modified:"); return _("both modified:");
default: default:
die("bug: unhandled unmerged status %x", stagemask); die("BUG: unhandled unmerged status %x", stagemask);
} }
} }
@@ -388,7 +388,7 @@ static void wt_status_print_change_data(struct wt_status *s,
status_printf(s, color(WT_STATUS_HEADER, s), "\t"); status_printf(s, color(WT_STATUS_HEADER, s), "\t");
what = wt_status_diff_status_string(status); what = wt_status_diff_status_string(status);
if (!what) if (!what)
die("bug: unhandled diff status %c", status); die("BUG: unhandled diff status %c", status);
len = label_width - utf8_strwidth(what); len = label_width - utf8_strwidth(what);
assert(len >= 0); assert(len >= 0);
if (status == DIFF_STATUS_COPIED || status == DIFF_STATUS_RENAMED) if (status == DIFF_STATUS_COPIED || status == DIFF_STATUS_RENAMED)