diff options
author | Junio C Hamano <gitster@pobox.com> | 2018-05-30 14:04:07 +0900 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-05-30 14:04:07 +0900 |
commit | 50f08db5941755b69012378bfc86f6b8ee98edf4 (patch) | |
tree | d403a1dbf522fdaab4cf6b9b508a08b3965828e2 | |
parent | Merge branch 'rs/no-null-ptr-arith-in-fast-export' (diff) | |
parent | BUG_exit_code: fix sparse "symbol not declared" warning (diff) | |
download | tgif-50f08db5941755b69012378bfc86f6b8ee98edf4.tar.xz |
Merge branch 'js/use-bug-macro'
Developer support update, by using BUG() macro instead of die() to
mark codepaths that should not happen more clearly.
* js/use-bug-macro:
BUG_exit_code: fix sparse "symbol not declared" warning
Convert remaining die*(BUG) messages
Replace all die("BUG: ...") calls by BUG() ones
run-command: use BUG() to report bugs, not die()
test-tool: help verifying BUG() code paths
69 files changed, 214 insertions, 206 deletions
@@ -2375,7 +2375,7 @@ static void update_pre_post_images(struct image *preimage, if (postlen ? postlen < new_buf - postimage->buf : postimage->len < new_buf - postimage->buf) - die("BUG: caller miscounted postlen: asked %d, orig = %d, used = %d", + BUG("caller miscounted postlen: asked %d, orig = %d, used = %d", (int)postlen, (int) postimage->len, (int)(new_buf - postimage->buf)); /* Fix the length of the whole thing */ @@ -3509,7 +3509,7 @@ static int load_current(struct apply_state *state, unsigned mode = patch->new_mode; if (!patch->is_new) - die("BUG: patch to %s is not a creation", patch->old_name); + BUG("patch to %s is not a creation", patch->old_name); pos = cache_name_pos(name, strlen(name)); if (pos < 0) diff --git a/archive-tar.c b/archive-tar.c index f93409324f..b6f58ddf38 100644 --- a/archive-tar.c +++ b/archive-tar.c @@ -441,7 +441,7 @@ static int write_tar_filter_archive(const struct archiver *ar, int r; if (!ar->data) - die("BUG: tar-filter archiver called with no filter defined"); + BUG("tar-filter archiver called with no filter defined"); strbuf_addstr(&cmd, ar->data); if (args->compression_level >= 0) @@ -157,7 +157,7 @@ static void all_attrs_init(struct attr_hashmap *map, struct attr_check *check) size = hashmap_get_size(&map->map); if (size < check->all_attrs_nr) - die("BUG: interned attributes shouldn't be deleted"); + BUG("interned attributes shouldn't be deleted"); /* * If the number of attributes in the global dictionary has increased @@ -541,7 +541,7 @@ static void check_vector_remove(struct attr_check *check) break; if (i >= check_vector.nr) - die("BUG: no entry found"); + BUG("no entry found"); /* shift entries over */ for (; i < check_vector.nr - 1; i++) @@ -599,11 +599,11 @@ struct attr_check *attr_check_initl(const char *one, ...) const struct git_attr *attr; param = va_arg(params, const char *); if (!param) - die("BUG: counted %d != ended at %d", + BUG("counted %d != ended at %d", check->nr, cnt); attr = git_attr(param); if (!attr) - die("BUG: %s: not a valid attribute name", param); + BUG("%s: not a valid attribute name", param); check->items[cnt].attr = attr; } va_end(params); @@ -714,7 +714,7 @@ void git_attr_set_direction(enum git_attr_direction new_direction, struct index_state *istate) { if (is_bare_repository() && new_direction != GIT_ATTR_INDEX) - die("BUG: non-INDEX attr direction in a bare repo"); + BUG("non-INDEX attr direction in a bare repo"); if (new_direction != direction) drop_all_attr_stacks(); @@ -1806,7 +1806,7 @@ void setup_scoreboard(struct blame_scoreboard *sb, const char *path, struct blam l->item = c; if (add_decoration(&sb->revs->children, &c->parents->item->object, l)) - die("BUG: not unique item in first-parent chain"); + BUG("not unique item in first-parent chain"); c = c->parents->item; } diff --git a/builtin/am.c b/builtin/am.c index d834f9e62b..3dc2ef4259 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -403,11 +403,11 @@ static void am_load(struct am_state *state) struct strbuf sb = STRBUF_INIT; if (read_state_file(&sb, state, "next", 1) < 0) - die("BUG: state file 'next' does not exist"); + BUG("state file 'next' does not exist"); state->cur = strtol(sb.buf, NULL, 10); if (read_state_file(&sb, state, "last", 1) < 0) - die("BUG: state file 'last' does not exist"); + BUG("state file 'last' does not exist"); state->last = strtol(sb.buf, NULL, 10); if (read_author_script(state) < 0) @@ -986,7 +986,7 @@ static int split_mail(struct am_state *state, enum patch_format patch_format, case PATCH_FORMAT_MBOXRD: return split_mail_mbox(state, paths, keep_cr, 1); default: - die("BUG: invalid patch_format"); + BUG("invalid patch_format"); } return -1; } @@ -1041,7 +1041,7 @@ static void am_setup(struct am_state *state, enum patch_format patch_format, str = "b"; break; default: - die("BUG: invalid value for state->keep"); + BUG("invalid value for state->keep"); } write_state_text(state, "keep", str); @@ -1058,7 +1058,7 @@ static void am_setup(struct am_state *state, enum patch_format patch_format, str = "t"; break; default: - die("BUG: invalid value for state->scissors"); + BUG("invalid value for state->scissors"); } write_state_text(state, "scissors", str); @@ -1216,7 +1216,7 @@ static int parse_mail(struct am_state *state, const char *mail) mi.keep_non_patch_brackets_in_subject = 1; break; default: - die("BUG: invalid value for state->keep"); + BUG("invalid value for state->keep"); } if (state->message_id) @@ -1232,7 +1232,7 @@ static int parse_mail(struct am_state *state, const char *mail) mi.use_scissors = 1; break; default: - die("BUG: invalid value for state->scissors"); + BUG("invalid value for state->scissors"); } mi.input = xfopen(mail, "r"); @@ -1463,7 +1463,7 @@ static int run_apply(const struct am_state *state, const char *index_file) int options = 0; if (init_apply_state(&apply_state, NULL)) - die("BUG: init_apply_state() failed"); + BUG("init_apply_state() failed"); argv_array_push(&apply_opts, "apply"); argv_array_pushv(&apply_opts, state->git_apply_opts.argv); @@ -1489,7 +1489,7 @@ static int run_apply(const struct am_state *state, const char *index_file) apply_state.apply_verbosity = verbosity_silent; if (check_apply_state(&apply_state, force_apply)) - die("BUG: check_apply_state() failed"); + BUG("check_apply_state() failed"); argv_array_push(&apply_paths, am_path(state, "patch")); @@ -2407,7 +2407,7 @@ int cmd_am(int argc, const char **argv, const char *prefix) ret = show_patch(&state); break; default: - die("BUG: invalid resume value"); + BUG("invalid resume value"); } am_state_release(&state); diff --git a/builtin/branch.c b/builtin/branch.c index efc9ac1922..5bb5123e72 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -500,7 +500,7 @@ static void copy_or_rename_branch(const char *oldname, const char *newname, int if (!skip_prefix(oldref.buf, "refs/heads/", &interpreted_oldname) || !skip_prefix(newref.buf, "refs/heads/", &interpreted_newname)) { - die("BUG: expected prefix missing for refs"); + BUG("expected prefix missing for refs"); } if (copy) diff --git a/builtin/cat-file.c b/builtin/cat-file.c index b8ecbea98e..665b581949 100644 --- a/builtin/cat-file.c +++ b/builtin/cat-file.c @@ -312,7 +312,7 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d die("could not convert '%s' %s", oid_to_hex(oid), data->rest); } else - die("BUG: invalid cmdmode: %c", opt->cmdmode); + BUG("invalid cmdmode: %c", opt->cmdmode); batch_write(opt, contents, size); free(contents); } else if (stream_blob_to_fd(1, oid, NULL, 0) < 0) @@ -387,7 +387,7 @@ static void batch_one_object(const char *obj_name, struct batch_options *opt, (uintmax_t)strlen(obj_name), obj_name); break; default: - die("BUG: unknown get_sha1_with_context result %d\n", + BUG("unknown get_sha1_with_context result %d\n", result); break; } diff --git a/builtin/clone.c b/builtin/clone.c index 84f1473d19..ecd8495dab 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -823,7 +823,7 @@ static void write_refspec_config(const char *src_ref_prefix, } else if (remote_head_points_at) { const char *head = remote_head_points_at->name; if (!skip_prefix(head, "refs/heads/", &head)) - die("BUG: remote HEAD points at non-head?"); + BUG("remote HEAD points at non-head?"); strbuf_addf(&value, "+%s:%s%s", remote_head_points_at->name, branch_top->buf, head); diff --git a/builtin/commit.c b/builtin/commit.c index 5240f11225..5205d3a408 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -495,7 +495,7 @@ static int is_a_merge(const struct commit *current_head) static void assert_split_ident(struct ident_split *id, const struct strbuf *buf) { if (split_ident_line(id, buf->buf, buf->len) || !id->date_begin) - die("BUG: unable to parse our own ident: %s", buf->buf); + BUG("unable to parse our own ident: %s", buf->buf); } static void export_one(const char *var, const char *s, const char *e, int hack) diff --git a/builtin/config.c b/builtin/config.c index 69e7270356..1e31aa9f8d 100644 --- a/builtin/config.c +++ b/builtin/config.c @@ -398,7 +398,7 @@ static char *normalize_value(const char *key, const char *value) return xstrdup(value); } - die("BUG: cannot normalize type %d", type); + BUG("cannot normalize type %d", type); } static int get_color_found; diff --git a/builtin/fast-export.c b/builtin/fast-export.c index 07d20f446f..f9568ddba0 100644 --- a/builtin/fast-export.c +++ b/builtin/fast-export.c @@ -516,7 +516,7 @@ static void anonymize_ident_line(const char **beg, const char **end) /* skip "committer", "author", "tagger", etc */ end_of_header = strchr(*beg, ' '); if (!end_of_header) - die("BUG: malformed line fed to anonymize_ident_line: %.*s", + BUG("malformed line fed to anonymize_ident_line: %.*s", (int)(*end - *beg), *beg); end_of_header++; strbuf_add(out, *beg, end_of_header - *beg); diff --git a/builtin/index-pack.c b/builtin/index-pack.c index 59130e8ecb..b3a5abcf2b 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -869,7 +869,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry, if (obj->type == OBJ_COMMIT) { struct commit *commit = (struct commit *) obj; if (detach_commit_buffer(commit, NULL) != data) - die("BUG: parse_object_buffer transmogrified our buffer"); + BUG("parse_object_buffer transmogrified our buffer"); } obj->flags |= FLAG_CHECKED; } @@ -1018,7 +1018,7 @@ static struct base_data *find_unresolved_deltas_1(struct base_data *base, if (!compare_and_swap_type(&child->real_type, OBJ_REF_DELTA, base->obj->real_type)) - die("BUG: child->real_type != OBJ_REF_DELTA"); + BUG("child->real_type != OBJ_REF_DELTA"); resolve_delta(child, base, result); if (base->ref_first == base->ref_last && base->ofs_last == -1) diff --git a/builtin/init-db.c b/builtin/init-db.c index 2542c5244e..5a5844c153 100644 --- a/builtin/init-db.c +++ b/builtin/init-db.c @@ -391,7 +391,7 @@ int init_db(const char *git_dir, const char *real_git_dir, else if (get_shared_repository() == PERM_EVERYBODY) xsnprintf(buf, sizeof(buf), "%d", OLD_PERM_EVERYBODY); else - die("BUG: invalid value for shared_repository"); + BUG("invalid value for shared_repository"); git_config_set("core.sharedrepository", buf); git_config_set("receive.denyNonFastforwards", "true"); } diff --git a/builtin/ls-files.c b/builtin/ls-files.c index a71f6bd088..967b2b3380 100644 --- a/builtin/ls-files.c +++ b/builtin/ls-files.c @@ -166,7 +166,7 @@ static void show_killed_files(const struct index_state *istate, */ pos = index_name_pos(istate, ent->name, ent->len); if (0 <= pos) - die("BUG: killed-file %.*s not found", + BUG("killed-file %.*s not found", ent->len, ent->name); pos = -pos - 1; while (pos < istate->cache_nr && diff --git a/builtin/notes.c b/builtin/notes.c index e5bf80eef1..da279cdd34 100644 --- a/builtin/notes.c +++ b/builtin/notes.c @@ -461,7 +461,7 @@ static int add(int argc, const char **argv, const char *prefix) if (d.buf.len || allow_empty) { write_note_data(&d, &new_note); if (add_note(t, &object, &new_note, combine_notes_overwrite)) - die("BUG: combine_notes_overwrite failed"); + BUG("combine_notes_overwrite failed"); commit_notes(t, "Notes added by 'git notes add'"); } else { fprintf(stderr, _("Removing note for object %s\n"), @@ -544,7 +544,7 @@ static int copy(int argc, const char **argv, const char *prefix) } if (add_note(t, &object, from_note, combine_notes_overwrite)) - die("BUG: combine_notes_overwrite failed"); + BUG("combine_notes_overwrite failed"); commit_notes(t, "Notes added by 'git notes copy'"); out: free_notes(t); @@ -621,7 +621,7 @@ static int append_edit(int argc, const char **argv, const char *prefix) if (d.buf.len || allow_empty) { write_note_data(&d, &new_note); if (add_note(t, &object, &new_note, combine_notes_overwrite)) - die("BUG: combine_notes_overwrite failed"); + BUG("combine_notes_overwrite failed"); logmsg = xstrfmt("Notes added by 'git notes %s'", argv[0]); } else { fprintf(stderr, _("Removing note for object %s\n"), @@ -831,7 +831,7 @@ static int merge(int argc, const char **argv, const char *prefix) const char *short_ref = NULL; if (!skip_prefix(o.local_ref, "refs/notes/", &short_ref)) - die("BUG: local ref %s is outside of refs/notes/", + BUG("local ref %s is outside of refs/notes/", o.local_ref); strbuf_addf(&merge_key, "notes.%s.mergeStrategy", short_ref); diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 3df0bf0f6f..53a0fb6ef2 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -1668,7 +1668,7 @@ static void break_delta_chains(struct object_entry *entry) * is a bug. */ if (cur->dfs_state != DFS_NONE) - die("BUG: confusing delta dfs state in first pass: %d", + BUG("confusing delta dfs state in first pass: %d", cur->dfs_state); /* @@ -1725,7 +1725,7 @@ static void break_delta_chains(struct object_entry *entry) if (cur->dfs_state == DFS_DONE) break; else if (cur->dfs_state != DFS_ACTIVE) - die("BUG: confusing delta dfs state in second pass: %d", + BUG("confusing delta dfs state in second pass: %d", cur->dfs_state); /* diff --git a/builtin/pull.c b/builtin/pull.c index c719a4f9d7..25f7db5b3a 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -543,7 +543,7 @@ static int run_fetch(const char *repo, const char **refspecs) argv_array_push(&args, repo); argv_array_pushv(&args, refspecs); } else if (*refspecs) - die("BUG: refspecs without repo?"); + BUG("refspecs without repo?"); ret = run_command_v_opt(args.argv, RUN_GIT_CMD); argv_array_clear(&args); return ret; diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c index 132a5339a3..d5f15cd4f6 100644 --- a/builtin/receive-pack.c +++ b/builtin/receive-pack.c @@ -1378,7 +1378,7 @@ static void warn_if_skipped_connectivity_check(struct command *commands, } } if (!checked_connectivity) - die("BUG: connectivity check skipped???"); + BUG("connectivity check skipped???"); } static void execute_commands_non_atomic(struct command *commands, diff --git a/builtin/update-index.c b/builtin/update-index.c index 6598bc06ad..a8709a26ec 100644 --- a/builtin/update-index.c +++ b/builtin/update-index.c @@ -1174,7 +1174,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix) report(_("Untracked cache enabled for '%s'"), get_git_work_tree()); break; default: - die("BUG: bad untracked_cache value: %d", untracked_cache); + BUG("bad untracked_cache value: %d", untracked_cache); } if (fsmonitor > 0) { diff --git a/bulk-checkin.c b/bulk-checkin.c index c0bc8de107..b7e131c47a 100644 --- a/bulk-checkin.c +++ b/bulk-checkin.c @@ -230,7 +230,7 @@ static int deflate_to_pack(struct bulk_checkin_state *state, * pack, and write into it. */ if (!idx) - die("BUG: should not happen"); + BUG("should not happen"); hashfile_truncate(state->f, &checkpoint); state->offset = checkpoint.offset; finish_bulk_checkin(state); @@ -174,7 +174,7 @@ static char *color_output(char *out, int len, const struct color *c, char type) break; case COLOR_ANSI: if (len < 2) - die("BUG: color parsing ran out of space"); + BUG("color parsing ran out of space"); *out++ = type; *out++ = '0' + c->value; break; @@ -256,7 +256,7 @@ int color_parse_mem(const char *value, int value_len, char *dst) #undef OUT #define OUT(x) do { \ if (dst == end) \ - die("BUG: color parsing ran out of space"); \ + BUG("color parsing ran out of space"); \ *dst++ = (x); \ } while(0) @@ -214,7 +214,7 @@ void print_columns(const struct string_list *list, unsigned int colopts, display_table(list, colopts, &nopts); break; default: - die("BUG: invalid layout mode %d", COL_LAYOUT(colopts)); + BUG("invalid layout mode %d", COL_LAYOUT(colopts)); } } @@ -103,7 +103,7 @@ static int config_buf_ungetc(int c, struct config_source *conf) if (conf->u.buf.pos > 0) { conf->u.buf.pos--; if (conf->u.buf.buf[conf->u.buf.pos] != c) - die("BUG: config_buf can only ungetc the same character"); + BUG("config_buf can only ungetc the same character"); return c; } @@ -190,7 +190,7 @@ static int prepare_include_condition_pattern(struct strbuf *pat) strbuf_realpath(&path, cf->path, 1); slash = find_last_dir_sep(path.buf); if (!slash) - die("BUG: how is this possible?"); + BUG("how is this possible?"); strbuf_splice(pat, 0, 1, path.buf, slash - path.buf); prefix = slash - path.buf + 1 /* slash */; } else if (!is_absolute_path(pat->buf)) @@ -1814,7 +1814,7 @@ static int configset_add_value(struct config_set *cs, const char *key, const cha l_item->value_index = e->value_list.nr - 1; if (!cf) - die("BUG: configset_add_value has no source"); + BUG("configset_add_value has no source"); if (cf->name) { kv_info->filename = strintern(cf->name); kv_info->linenr = cf->linenr; @@ -3208,7 +3208,7 @@ const char *current_config_origin_type(void) else if(cf) type = cf->origin_type; else - die("BUG: current_config_origin_type called outside config callback"); + BUG("current_config_origin_type called outside config callback"); switch (type) { case CONFIG_ORIGIN_BLOB: @@ -3222,7 +3222,7 @@ const char *current_config_origin_type(void) case CONFIG_ORIGIN_CMDLINE: return "command line"; default: - die("BUG: unknown config origin type"); + BUG("unknown config origin type"); } } @@ -3234,7 +3234,7 @@ const char *current_config_name(void) else if (cf) name = cf->name; else - die("BUG: current_config_name called outside config callback"); + BUG("current_config_name called outside config callback"); return name ? name : ""; } @@ -185,7 +185,7 @@ struct date_mode *date_mode_from_type(enum date_mode_type type) { static struct date_mode mode; if (type == DATE_STRFTIME) - die("BUG: cannot create anonymous strftime date_mode struct"); + BUG("cannot create anonymous strftime date_mode struct"); mode.type = type; mode.local = 0; return &mode; @@ -1184,7 +1184,7 @@ static void emit_diff_symbol_from_struct(struct diff_options *o, fputs(o->stat_sep, o->file); break; default: - die("BUG: unknown diff symbol"); + BUG("unknown diff symbol"); } strbuf_release(&sb); } @@ -1343,7 +1343,7 @@ static struct diff_tempfile *claim_diff_tempfile(void) { for (i = 0; i < ARRAY_SIZE(diff_temp); i++) if (!diff_temp[i].name) return diff_temp + i; - die("BUG: diff is failing to clean up its tempfiles"); + BUG("diff is failing to clean up its tempfiles"); } static void remove_tempfile(void) @@ -3841,7 +3841,7 @@ static const char *diff_abbrev_oid(const struct object_id *oid, int abbrev) if (abbrev < 0) abbrev = FALLBACK_DEFAULT_ABBREV; if (abbrev > GIT_SHA1_HEXSZ) - die("BUG: oid abbreviation out of range: %d", abbrev); + BUG("oid abbreviation out of range: %d", abbrev); if (abbrev) hex[abbrev] = '\0'; return hex; @@ -4335,7 +4335,7 @@ static int stat_opt(struct diff_options *options, const char **av) int argcount = 1; if (!skip_prefix(arg, "--stat", &arg)) - die("BUG: stat option does not begin with --stat: %s", arg); + BUG("stat option does not begin with --stat: %s", arg); end = (char *)arg; switch (*arg) { @@ -5520,7 +5520,7 @@ static void diff_flush_patch_all_file_pairs(struct diff_options *o) struct diff_queue_struct *q = &diff_queued_diff; if (WSEH_NEW & WS_RULE_MASK) - die("BUG: WS rules bit mask overlaps with diff symbol flags"); + BUG("WS rules bit mask overlaps with diff symbol flags"); if (o->color_moved) o->emitted_symbols = &esm; @@ -6054,7 +6054,7 @@ size_t fill_textconv(struct userdiff_driver *driver, } if (!driver->textconv) - die("BUG: fill_textconv called with non-textconv driver"); + BUG("fill_textconv called with non-textconv driver"); if (driver->textconv_cache && df->oid_valid) { *outbuf = notes_cache_get(driver->textconv_cache, diff --git a/dir-iterator.c b/dir-iterator.c index 34182a9a1c..f2dcd82fde 100644 --- a/dir-iterator.c +++ b/dir-iterator.c @@ -188,7 +188,7 @@ struct dir_iterator *dir_iterator_begin(const char *path) struct dir_iterator *dir_iterator = &iter->base; if (!path || !*path) - die("BUG: empty path passed to dir_iterator_begin()"); + BUG("empty path passed to dir_iterator_begin()"); strbuf_init(&iter->base.path, PATH_MAX); strbuf_addstr(&iter->base.path, path); diff --git a/git-compat-util.h b/git-compat-util.h index 94a108c03e..9a64998b24 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -1074,7 +1074,7 @@ int git_qsort_s(void *base, size_t nmemb, size_t size, #define QSORT_S(base, n, compar, ctx) do { \ if (qsort_s((base), (n), sizeof(*(base)), compar, ctx)) \ - die("BUG: qsort_s() failed"); \ + BUG("qsort_s() failed"); \ } while (0) #ifndef REG_STARTEND @@ -1133,6 +1133,9 @@ static inline int regexec_buf(const regex_t *preg, const char *buf, size_t size, #define HAVE_VARIADIC_MACROS 1 #endif +/* usage.c: only to be used for testing BUG() implementation (see test-tool) */ +extern int BUG_exit_code; + #ifdef HAVE_VARIADIC_MACROS __attribute__((format (printf, 3, 4))) NORETURN void BUG_fl(const char *file, int line, const char *fmt, ...); @@ -404,7 +404,7 @@ static void compile_pcre1_regexp(struct grep_pat *p, const struct grep_opt *opt) die("Couldn't allocate PCRE JIT stack"); pcre_assign_jit_stack(p->pcre1_extra_info, NULL, p->pcre1_jit_stack); } else if (p->pcre1_jit_on != 0) { - die("BUG: The pcre1_jit_on variable should be 0 or 1, not %d", + BUG("The pcre1_jit_on variable should be 0 or 1, not %d", p->pcre1_jit_on); } #endif @@ -550,7 +550,7 @@ static void compile_pcre2_pattern(struct grep_pat *p, const struct grep_opt *opt die("Couldn't allocate PCRE2 match context"); pcre2_jit_stack_assign(p->pcre2_match_context, NULL, p->pcre2_jit_stack); } else if (p->pcre2_jit_on != 0) { - die("BUG: The pcre2_jit_on variable should be 0 or 1, not %d", + BUG("The pcre2_jit_on variable should be 0 or 1, not %d", p->pcre1_jit_on); } } @@ -917,10 +917,10 @@ static struct grep_expr *prep_header_patterns(struct grep_opt *opt) for (p = opt->header_list; p; p = p->next) { if (p->token != GREP_PATTERN_HEAD) - die("BUG: a non-header pattern in grep header list."); + BUG("a non-header pattern in grep header list."); if (p->field < GREP_HEADER_FIELD_MIN || GREP_HEADER_FIELD_MAX <= p->field) - die("BUG: unknown header field %d", p->field); + BUG("unknown header field %d", p->field); compile_regexp(p, opt); } @@ -933,7 +933,7 @@ static struct grep_expr *prep_header_patterns(struct grep_opt *opt) h = compile_pattern_atom(&pp); if (!h || pp != p->next) - die("BUG: malformed header expr"); + BUG("malformed header expr"); if (!header_group[p->field]) { header_group[p->field] = h; continue; @@ -1652,7 +1652,7 @@ static int fill_textconv_grep(struct userdiff_driver *driver, fill_filespec(df, &null_oid, 0, 0100644); break; default: - die("BUG: attempt to textconv something without a path?"); + BUG("attempt to textconv something without a path?"); } /* @@ -1748,7 +1748,7 @@ static int grep_source_1(struct grep_opt *opt, struct grep_source *gs, int colle case GREP_BINARY_TEXT: break; default: - die("BUG: unknown binary handling mode"); + BUG("unknown binary handling mode"); } } @@ -2072,7 +2072,7 @@ static int grep_source_load(struct grep_source *gs) case GREP_SOURCE_BUF: return gs->buf ? 0 : -1; } - die("BUG: invalid grep_source type to load"); + BUG("invalid grep_source type to load"); } void grep_source_load_driver(struct grep_source *gs) @@ -1846,7 +1846,7 @@ static int update_url_from_redirect(struct strbuf *base, return 0; if (!skip_prefix(asked, base->buf, &tail)) - die("BUG: update_url_from_redirect: %s is not a superset of %s", + BUG("update_url_from_redirect: %s is not a superset of %s", asked, base->buf); new_len = got->len; @@ -1894,7 +1894,7 @@ static int http_request_reauth(const char *url, strbuf_reset(result); break; default: - die("BUG: HTTP_KEEP_ERROR is only supported with strbufs"); + BUG("HTTP_KEEP_ERROR is only supported with strbufs"); } } @@ -2105,7 +2105,7 @@ int finish_http_pack_request(struct http_pack_request *preq) *lst = (*lst)->next; if (!strip_suffix(preq->tmpfile, ".pack.temp", &len)) - die("BUG: pack tmpfile does not end in .pack.temp?"); + BUG("pack tmpfile does not end in .pack.temp?"); tmp_idx = xstrfmt("%.*s.idx.temp", (int)len, preq->tmpfile); argv_array_push(&ip.args, "index-pack"); @@ -2201,7 +2201,7 @@ static size_t fwrite_sha1_file(char *ptr, size_t eltsize, size_t nmemb, CURLcode c = curl_easy_getinfo(slot->curl, CURLINFO_HTTP_CODE, &slot->http_code); if (c != CURLE_OK) - die("BUG: curl_easy_getinfo for HTTP code failed: %s", + BUG("curl_easy_getinfo for HTTP code failed: %s", curl_easy_strerror(c)); if (slot->http_code >= 300) return size; diff --git a/imap-send.c b/imap-send.c index 3573cbfb0f..b4eb886e2a 100644 --- a/imap-send.c +++ b/imap-send.c @@ -511,7 +511,7 @@ static int nfsnprintf(char *buf, int blen, const char *fmt, ...) va_start(va, fmt); if (blen <= 0 || (unsigned)(ret = vsnprintf(buf, blen, fmt, va)) >= (unsigned)blen) - die("BUG: buffer too small. Please report a bug."); + BUG("buffer too small. Please report a bug."); va_end(va); return ret; } diff --git a/lockfile.c b/lockfile.c index efcb7d7dfe..8e8ab4f29f 100644 --- a/lockfile.c +++ b/lockfile.c @@ -193,7 +193,7 @@ char *get_locked_file_path(struct lock_file *lk) strbuf_addstr(&ret, get_tempfile_path(lk->tempfile)); if (ret.len <= LOCK_SUFFIX_LEN || strcmp(ret.buf + ret.len - LOCK_SUFFIX_LEN, LOCK_SUFFIX)) - die("BUG: get_locked_file_path() called for malformed lock object"); + BUG("get_locked_file_path() called for malformed lock object"); /* remove ".lock": */ strbuf_setlen(&ret, ret.len - LOCK_SUFFIX_LEN); return strbuf_detach(&ret, NULL); diff --git a/mailinfo.c b/mailinfo.c index d04142ccc7..3281a37d51 100644 --- a/mailinfo.c +++ b/mailinfo.c @@ -716,7 +716,7 @@ static void flush_inbody_header_accum(struct mailinfo *mi) if (!mi->inbody_header_accum.len) return; if (!check_header(mi, &mi->inbody_header_accum, mi->s_hdr_data, 0)) - die("BUG: inbody_header_accum, if not empty, must always contain a valid in-body header"); + BUG("inbody_header_accum, if not empty, must always contain a valid in-body header"); strbuf_reset(&mi->inbody_header_accum); } diff --git a/merge-recursive.c b/merge-recursive.c index 8d96e94bd5..e64b4b9d03 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -392,7 +392,7 @@ struct tree *write_tree_from_memory(struct merge_options *o) fprintf(stderr, "BUG: %d %.*s\n", ce_stage(ce), (int)ce_namelen(ce), ce->name); } - die("BUG: unmerged index entries in merge-recursive.c"); + BUG("unmerged index entries in merge-recursive.c"); } if (!active_cache_tree) @@ -1166,7 +1166,7 @@ static int merge_file_1(struct merge_options *o, break; } } else - die("BUG: unsupported object type in the tree"); + BUG("unsupported object type in the tree"); } if (result->merge) @@ -2419,7 +2419,7 @@ static int process_renames(struct merge_options *o, const char *ren2_dst = ren2->pair->two->path; enum rename_type rename_type; if (strcmp(ren1_src, ren2_src) != 0) - die("BUG: ren1_src != ren2_src"); + BUG("ren1_src != ren2_src"); ren2->dst_entry->processed = 1; ren2->processed = 1; if (strcmp(ren1_dst, ren2_dst) != 0) { @@ -2453,7 +2453,7 @@ static int process_renames(struct merge_options *o, ren2 = lookup->util; ren2_dst = ren2->pair->two->path; if (strcmp(ren1_dst, ren2_dst) != 0) - die("BUG: ren1_dst != ren2_dst"); + BUG("ren1_dst != ren2_dst"); clean_merge = 0; ren2->processed = 1; @@ -3057,7 +3057,7 @@ static int process_entry(struct merge_options *o, */ remove_file(o, 1, path, !a_mode); } else - die("BUG: fatal merge failure, shouldn't happen."); + BUG("fatal merge failure, shouldn't happen."); return clean_merge; } @@ -3135,7 +3135,7 @@ int merge_trees(struct merge_options *o, for (i = 0; i < entries->nr; i++) { struct stage_data *e = entries->items[i].util; if (!e->processed) - die("BUG: unprocessed path??? %s", + BUG("unprocessed path??? %s", entries->items[i].string); } diff --git a/notes-merge.c b/notes-merge.c index e06d71ea47..d613e06574 100644 --- a/notes-merge.c +++ b/notes-merge.c @@ -442,7 +442,7 @@ static int merge_one_change(struct notes_merge_options *o, printf("Using remote notes for %s\n", oid_to_hex(&p->obj)); if (add_note(t, &p->obj, &p->remote, combine_notes_overwrite)) - die("BUG: combine_notes_overwrite failed"); + BUG("combine_notes_overwrite failed"); return 0; case NOTES_MERGE_RESOLVE_UNION: if (o->verbosity >= 2) @@ -490,7 +490,7 @@ static int merge_changes(struct notes_merge_options *o, trace_printf("\t\t\tno local change, adopted remote\n"); if (add_note(t, &p->obj, &p->remote, combine_notes_overwrite)) - die("BUG: combine_notes_overwrite failed"); + BUG("combine_notes_overwrite failed"); } else { /* need file-level merge between local and remote */ trace_printf("\t\t\tneed content-level merge\n"); diff --git a/pack-bitmap-write.c b/pack-bitmap-write.c index 72d9daec7e..7b2dc3e7dc 100644 --- a/pack-bitmap-write.c +++ b/pack-bitmap-write.c @@ -477,7 +477,7 @@ static void write_selected_commits_v1(struct hashfile *f, sha1_pos(stored->commit->object.oid.hash, index, index_nr, sha1_access); if (commit_pos < 0) - die("BUG: trying to write commit not in index"); + BUG("trying to write commit not in index"); hashwrite_be32(f, commit_pos); hashwrite_u8(f, stored->xor_offset); diff --git a/pack-bitmap.c b/pack-bitmap.c index c9e90d1bb5..06771113fb 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -255,7 +255,7 @@ static char *pack_bitmap_filename(struct packed_git *p) size_t len; if (!strip_suffix(p->pack_name, ".pack", &len)) - die("BUG: pack_name does not end in .pack"); + BUG("pack_name does not end in .pack"); return xstrfmt("%.*s.bitmap", (int)len, p->pack_name); } @@ -723,13 +723,13 @@ int prepare_bitmap_walk(struct rev_info *revs) revs->ignore_missing_links = 0; if (haves_bitmap == NULL) - die("BUG: failed to perform bitmap walk"); + BUG("failed to perform bitmap walk"); } wants_bitmap = find_objects(revs, wants, haves_bitmap); if (!wants_bitmap) - die("BUG: failed to perform bitmap walk"); + BUG("failed to perform bitmap walk"); if (haves_bitmap) bitmap_and_not(wants_bitmap, haves_bitmap); diff --git a/pack-objects.c b/pack-objects.c index e0c4600568..92708522e7 100644 --- a/pack-objects.c +++ b/pack-objects.c @@ -60,7 +60,7 @@ static void rehash_objects(struct packing_data *pdata) &found); if (found) - die("BUG: Duplicate object in hash"); + BUG("Duplicate object in hash"); pdata->index[ix] = i + 1; entry++; diff --git a/packfile.c b/packfile.c index 9e7e693fb5..d625481b7a 100644 --- a/packfile.c +++ b/packfile.c @@ -188,7 +188,7 @@ int open_pack_index(struct packed_git *p) return 0; if (!strip_suffix(p->pack_name, ".pack", &len)) - die("BUG: pack_name does not end in .pack"); + BUG("pack_name does not end in .pack"); idx_name = xstrfmt("%.*s.idx", (int)len, p->pack_name); ret = check_packed_git_idx(idx_name, p); free(idx_name); @@ -317,7 +317,7 @@ void close_all_packs(struct raw_object_store *o) for (p = o->packed_git; p; p = p->next) if (p->do_not_close) - die("BUG: want to close pack marked 'do-not-close'"); + BUG("want to close pack marked 'do-not-close'"); else close_pack(p); } @@ -1567,7 +1567,7 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset, case OBJ_OFS_DELTA: case OBJ_REF_DELTA: if (data) - die("BUG: unpack_entry: left loop at a valid delta"); + BUG("unpack_entry: left loop at a valid delta"); break; case OBJ_COMMIT: case OBJ_TREE: diff --git a/pathspec.c b/pathspec.c index 82eb39cd67..27cd606786 100644 --- a/pathspec.c +++ b/pathspec.c @@ -198,7 +198,7 @@ static void parse_pathspec_attr_match(struct pathspec_item *item, const char *va } if (item->attr_check->nr != item->attr_match_nr) - die("BUG: should have same number of entries"); + BUG("should have same number of entries"); string_list_clear(&list, 0); } @@ -422,7 +422,7 @@ static void init_pathspec_item(struct pathspec_item *item, unsigned flags, if (pathspec_prefix >= 0 && (prefixlen || (prefix && *prefix))) - die("BUG: 'prefix' magic is supposed to be used at worktree's root"); + BUG("'prefix' magic is supposed to be used at worktree's root"); if ((magic & PATHSPEC_LITERAL) && (magic & PATHSPEC_GLOB)) die(_("%s: 'literal' and 'glob' are incompatible"), elt); @@ -486,7 +486,7 @@ static void init_pathspec_item(struct pathspec_item *item, unsigned flags, /* sanity checks, pathspec matchers assume these are sane */ if (item->nowildcard_len > item->len || item->prefix > item->len) { - die ("BUG: error initializing pathspec_item"); + BUG("error initializing pathspec_item"); } } @@ -545,7 +545,7 @@ void parse_pathspec(struct pathspec *pathspec, if ((flags & PATHSPEC_PREFER_CWD) && (flags & PATHSPEC_PREFER_FULL)) - die("BUG: PATHSPEC_PREFER_CWD and PATHSPEC_PREFER_FULL are incompatible"); + BUG("PATHSPEC_PREFER_CWD and PATHSPEC_PREFER_FULL are incompatible"); /* No arguments with prefix -> prefix pathspec */ if (!entry) { @@ -553,7 +553,7 @@ void parse_pathspec(struct pathspec *pathspec, return; if (!(flags & PATHSPEC_PREFER_CWD)) - die("BUG: PATHSPEC_PREFER_CWD requires arguments"); + BUG("PATHSPEC_PREFER_CWD requires arguments"); pathspec->items = item = xcalloc(1, sizeof(*item)); item->match = xstrdup(prefix); @@ -609,7 +609,7 @@ void parse_pathspec(struct pathspec *pathspec, if (pathspec->magic & PATHSPEC_MAXDEPTH) { if (flags & PATHSPEC_KEEP_ORDER) - die("BUG: PATHSPEC_MAXDEPTH_VALID and PATHSPEC_KEEP_ORDER are incompatible"); + BUG("PATHSPEC_MAXDEPTH_VALID and PATHSPEC_KEEP_ORDER are incompatible"); QSORT(pathspec->items, pathspec->nr, pathspec_item_cmp); } } diff --git a/pkt-line.c b/pkt-line.c index 555eb2a507..a593c08aad 100644 --- a/pkt-line.c +++ b/pkt-line.c @@ -277,7 +277,7 @@ static int get_packet_data(int fd, char **src_buf, size_t *src_size, ssize_t ret; if (fd >= 0 && src_buf && *src_buf) - die("BUG: multiple sources given to packet_read"); + BUG("multiple sources given to packet_read"); /* Read up to "size" bytes from our source, whatever it is. */ if (src_buf && *src_buf) { diff --git a/prio-queue.c b/prio-queue.c index 126d096727..a078451872 100644 --- a/prio-queue.c +++ b/prio-queue.c @@ -20,7 +20,7 @@ void prio_queue_reverse(struct prio_queue *queue) int i, j; if (queue->compare != NULL) - die("BUG: prio_queue_reverse() on non-LIFO queue"); + BUG("prio_queue_reverse() on non-LIFO queue"); for (i = 0; i < (j = (queue->nr - 1) - i); i++) swap(queue, i, j); } diff --git a/ref-filter.c b/ref-filter.c index dba826e718..01c1a82075 100644 --- a/ref-filter.c +++ b/ref-filter.c @@ -824,7 +824,7 @@ static int grab_objectname(const char *name, const struct object_id *oid, v->s = xstrdup(find_unique_abbrev(oid, atom->u.objectname.length)); return 1; } else - die("BUG: unknown %%(objectname) option"); + BUG("unknown %%(objectname) option"); } return 0; } @@ -1372,7 +1372,7 @@ static void fill_remote_ref_details(struct used_atom *atom, const char *refname, else *s = ""; } else - die("BUG: unhandled RR_* enum"); + BUG("unhandled RR_* enum"); } char *get_head_description(void) @@ -962,10 +962,10 @@ void ref_transaction_free(struct ref_transaction *transaction) /* OK */ break; case REF_TRANSACTION_PREPARED: - die("BUG: free called on a prepared reference transaction"); + BUG("free called on a prepared reference transaction"); break; default: - die("BUG: unexpected reference transaction state"); + BUG("unexpected reference transaction state"); break; } @@ -987,7 +987,7 @@ struct ref_update *ref_transaction_add_update( struct ref_update *update; if (transaction->state != REF_TRANSACTION_OPEN) - die("BUG: update called for transaction that is not open"); + BUG("update called for transaction that is not open"); FLEX_ALLOC_STR(update, refname, refname); ALLOC_GROW(transaction->updates, transaction->nr + 1, transaction->alloc); @@ -1037,7 +1037,7 @@ int ref_transaction_create(struct ref_transaction *transaction, struct strbuf *err) { if (!new_oid || is_null_oid(new_oid)) - die("BUG: create called without valid new_oid"); + BUG("create called without valid new_oid"); return ref_transaction_update(transaction, refname, new_oid, &null_oid, flags, msg, err); } @@ -1049,7 +1049,7 @@ int ref_transaction_delete(struct ref_transaction *transaction, struct strbuf *err) { if (old_oid && is_null_oid(old_oid)) - die("BUG: delete called with old_oid set to zeros"); + BUG("delete called with old_oid set to zeros"); return ref_transaction_update(transaction, refname, &null_oid, old_oid, flags, msg, err); @@ -1062,7 +1062,7 @@ int ref_transaction_verify(struct ref_transaction *transaction, struct strbuf *err) { if (!old_oid) - die("BUG: verify called with old_oid set to NULL"); + BUG("verify called with old_oid set to NULL"); return ref_transaction_update(transaction, refname, NULL, old_oid, flags, NULL, err); @@ -1660,7 +1660,7 @@ static struct ref_store *ref_store_init(const char *gitdir, struct ref_store *refs; if (!be) - die("BUG: reference backend %s is unknown", be_name); + BUG("reference backend %s is unknown", be_name); refs = be->init(gitdir, flags); return refs; @@ -1691,7 +1691,7 @@ static void register_ref_store_map(struct hashmap *map, hashmap_init(map, ref_store_hash_cmp, NULL, 0); if (hashmap_put(map, alloc_ref_store_hash_entry(name, refs))) - die("BUG: %s ref_store '%s' initialized twice", type, name); + BUG("%s ref_store '%s' initialized twice", type, name); } struct ref_store *get_submodule_ref_store(const char *submodule) @@ -1837,7 +1837,7 @@ int ref_update_reject_duplicates(struct string_list *refnames, refnames->items[i].string); return 1; } else if (cmp > 0) { - die("BUG: ref_update_reject_duplicates() received unsorted list"); + BUG("ref_update_reject_duplicates() received unsorted list"); } } return 0; @@ -1853,13 +1853,13 @@ int ref_transaction_prepare(struct ref_transaction *transaction, /* Good. */ break; case REF_TRANSACTION_PREPARED: - die("BUG: prepare called twice on reference transaction"); + BUG("prepare called twice on reference transaction"); break; case REF_TRANSACTION_CLOSED: - die("BUG: prepare called on a closed reference transaction"); + BUG("prepare called on a closed reference transaction"); break; default: - die("BUG: unexpected reference transaction state"); + BUG("unexpected reference transaction state"); break; } @@ -1886,10 +1886,10 @@ int ref_transaction_abort(struct ref_transaction *transaction, ret = refs->be->transaction_abort(refs, transaction, err); break; case REF_TRANSACTION_CLOSED: - die("BUG: abort called on a closed reference transaction"); + BUG("abort called on a closed reference transaction"); break; default: - die("BUG: unexpected reference transaction state"); + BUG("unexpected reference transaction state"); break; } @@ -1914,10 +1914,10 @@ int ref_transaction_commit(struct ref_transaction *transaction, /* Fall through to finish. */ break; case REF_TRANSACTION_CLOSED: - die("BUG: commit called on a closed reference transaction"); + BUG("commit called on a closed reference transaction"); break; default: - die("BUG: unexpected reference transaction state"); + BUG("unexpected reference transaction state"); break; } @@ -1998,7 +1998,7 @@ int refs_verify_refname_available(struct ref_store *refs, } if (ok != ITER_DONE) - die("BUG: error while iterating over references"); + BUG("error while iterating over references"); extra_refname = find_descendant_ref(dirname.buf, extras, skip); if (extra_refname) diff --git a/refs/files-backend.c b/refs/files-backend.c index 03fb8649c7..a9a066dcfb 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -121,7 +121,7 @@ static void files_assert_main_repository(struct files_ref_store *refs, if (refs->store_flags & REF_STORE_MAIN) return; - die("BUG: operation %s only allowed for main ref store", caller); + BUG("operation %s only allowed for main ref store", caller); } /* @@ -137,13 +137,13 @@ static struct files_ref_store *files_downcast(struct ref_store *ref_store, struct files_ref_store *refs; if (ref_store->be != &refs_be_files) - die("BUG: ref_store is type \"%s\" not \"files\" in %s", + BUG("ref_store is type \"%s\" not \"files\" in %s", ref_store->be->name, caller); refs = (struct files_ref_store *)ref_store; if ((refs->store_flags & required_flags) != required_flags) - die("BUG: operation %s requires abilities 0x%x, but only have 0x%x", + BUG("operation %s requires abilities 0x%x, but only have 0x%x", caller, required_flags, refs->store_flags); return refs; @@ -162,7 +162,7 @@ static void files_reflog_path(struct files_ref_store *refs, strbuf_addf(sb, "%s/logs/%s", refs->gitcommondir, refname); break; default: - die("BUG: unknown ref type %d of ref %s", + BUG("unknown ref type %d of ref %s", ref_type(refname), refname); } } @@ -180,7 +180,7 @@ static void files_ref_path(struct files_ref_store *refs, strbuf_addf(sb, "%s/%s", refs->gitcommondir, refname); break; default: - die("BUG: unknown ref type %d of ref %s", + BUG("unknown ref type %d of ref %s", ref_type(refname), refname); } } @@ -2006,7 +2006,7 @@ static int files_for_each_reflog_ent_reverse(struct ref_store *ref_store, } if (!ret && sb.len) - die("BUG: reverse reflog parser had leftover data"); + BUG("reverse reflog parser had leftover data"); fclose(logfp); strbuf_release(&sb); @@ -2084,7 +2084,7 @@ static int files_reflog_iterator_advance(struct ref_iterator *ref_iterator) static int files_reflog_iterator_peel(struct ref_iterator *ref_iterator, struct object_id *peeled) { - die("BUG: ref_iterator_peel() called for reflog_iterator"); + BUG("ref_iterator_peel() called for reflog_iterator"); } static int files_reflog_iterator_abort(struct ref_iterator *ref_iterator) @@ -2869,7 +2869,7 @@ static int files_initial_transaction_commit(struct ref_store *ref_store, assert(err); if (transaction->state != REF_TRANSACTION_OPEN) - die("BUG: commit called for transaction that is not open"); + BUG("commit called for transaction that is not open"); /* Fail if a refname appears more than once in the transaction: */ for (i = 0; i < transaction->nr; i++) @@ -2895,7 +2895,7 @@ static int files_initial_transaction_commit(struct ref_store *ref_store, */ if (refs_for_each_rawref(&refs->base, ref_present, &affected_refnames)) - die("BUG: initial ref transaction called with existing refs"); + BUG("initial ref transaction called with existing refs"); packed_transaction = ref_store_transaction_begin(refs->packed_ref_store, err); if (!packed_transaction) { @@ -2908,7 +2908,7 @@ static int files_initial_transaction_commit(struct ref_store *ref_store, if ((update->flags & REF_HAVE_OLD) && !is_null_oid(&update->old_oid)) - die("BUG: initial ref transaction with old_sha1 set"); + BUG("initial ref transaction with old_sha1 set"); if (refs_verify_refname_available(&refs->base, update->refname, &affected_refnames, NULL, err)) { diff --git a/refs/iterator.c b/refs/iterator.c index bd35da4e62..2ac91ac340 100644 --- a/refs/iterator.c +++ b/refs/iterator.c @@ -54,7 +54,7 @@ static int empty_ref_iterator_advance(struct ref_iterator *ref_iterator) static int empty_ref_iterator_peel(struct ref_iterator *ref_iterator, struct object_id *peeled) { - die("BUG: peel called for empty iterator"); + BUG("peel called for empty iterator"); } static int empty_ref_iterator_abort(struct ref_iterator *ref_iterator) @@ -177,7 +177,7 @@ static int merge_ref_iterator_peel(struct ref_iterator *ref_iterator, (struct merge_ref_iterator *)ref_iterator; if (!iter->current) { - die("BUG: peel called before advance for merge iterator"); + BUG("peel called before advance for merge iterator"); } return ref_iterator_peel(*iter->current, peeled); } @@ -338,7 +338,7 @@ static int prefix_ref_iterator_advance(struct ref_iterator *ref_iterator) * trimming, report it as a bug: */ if (strlen(iter->iter0->refname) <= iter->trim) - die("BUG: attempt to trim too many characters"); + BUG("attempt to trim too many characters"); iter->base.refname = iter->iter0->refname + iter->trim; } else { iter->base.refname = iter->iter0->refname; diff --git a/refs/packed-backend.c b/refs/packed-backend.c index 369c34f886..cec3fb9e00 100644 --- a/refs/packed-backend.c +++ b/refs/packed-backend.c @@ -221,13 +221,13 @@ static struct packed_ref_store *packed_downcast(struct ref_store *ref_store, struct packed_ref_store *refs; if (ref_store->be != &refs_be_packed) - die("BUG: ref_store is type \"%s\" not \"packed\" in %s", + BUG("ref_store is type \"%s\" not \"packed\" in %s", ref_store->be->name, caller); refs = (struct packed_ref_store *)ref_store; if ((refs->store_flags & required_flags) != required_flags) - die("BUG: unallowed operation (%s), requires %x, has %x\n", + BUG("unallowed operation (%s), requires %x, has %x\n", caller, required_flags, refs->store_flags); return refs; @@ -1036,7 +1036,7 @@ void packed_refs_unlock(struct ref_store *ref_store) "packed_refs_unlock"); if (!is_lock_file_locked(&refs->lock)) - die("BUG: packed_refs_unlock() called when not locked"); + BUG("packed_refs_unlock() called when not locked"); rollback_lock_file(&refs->lock); } @@ -1089,7 +1089,7 @@ static int write_with_updates(struct packed_ref_store *refs, char *packed_refs_path; if (!is_lock_file_locked(&refs->lock)) - die("BUG: write_with_updates() called while unlocked"); + BUG("write_with_updates() called while unlocked"); /* * If packed-refs is a symlink, we want to overwrite the @@ -1563,21 +1563,21 @@ static int packed_create_symref(struct ref_store *ref_store, const char *refname, const char *target, const char *logmsg) { - die("BUG: packed reference store does not support symrefs"); + BUG("packed reference store does not support symrefs"); } static int packed_rename_ref(struct ref_store *ref_store, const char *oldrefname, const char *newrefname, const char *logmsg) { - die("BUG: packed reference store does not support renaming references"); + BUG("packed reference store does not support renaming references"); } static int packed_copy_ref(struct ref_store *ref_store, const char *oldrefname, const char *newrefname, const char *logmsg) { - die("BUG: packed reference store does not support copying references"); + BUG("packed reference store does not support copying references"); } static struct ref_iterator *packed_reflog_iterator_begin(struct ref_store *ref_store) @@ -1610,7 +1610,7 @@ static int packed_create_reflog(struct ref_store *ref_store, const char *refname, int force_create, struct strbuf *err) { - die("BUG: packed reference store does not support reflogs"); + BUG("packed reference store does not support reflogs"); } static int packed_delete_reflog(struct ref_store *ref_store, diff --git a/refs/ref-cache.c b/refs/ref-cache.c index e90bd3e727..9b110c8494 100644 --- a/refs/ref-cache.c +++ b/refs/ref-cache.c @@ -23,7 +23,7 @@ struct ref_dir *get_ref_dir(struct ref_entry *entry) dir = &entry->u.subdir; if (entry->flag & REF_INCOMPLETE) { if (!dir->cache->fill_ref_dir) - die("BUG: incomplete ref_store without fill_ref_dir function"); + BUG("incomplete ref_store without fill_ref_dir function"); dir->cache->fill_ref_dir(dir->cache->ref_store, dir, entry->name); entry->flag &= ~REF_INCOMPLETE; @@ -1819,7 +1819,7 @@ static const char *branch_get_push_1(struct branch *branch, struct strbuf *err) } } - die("BUG: unhandled push situation"); + BUG("unhandled push situation"); } const char *branch_get_push(struct branch *branch, struct strbuf *err) diff --git a/revision.c b/revision.c index 4e0e193e57..dc756918e8 100644 --- a/revision.c +++ b/revision.c @@ -2108,7 +2108,7 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg revs->ignore_missing = 1; } else if (!strcmp(arg, "--exclude-promisor-objects")) { if (fetch_if_missing) - die("BUG: exclude_promisor_objects can only be used when fetch_if_missing is 0"); + BUG("exclude_promisor_objects can only be used when fetch_if_missing is 0"); revs->exclude_promisor_objects = 1; } else { int opts = diff_opt_parse(&revs->diffopt, argv, argc, revs->prefix); @@ -2174,7 +2174,7 @@ static int handle_revision_pseudo_opt(const char *submodule, * supported right now, so stick to single worktree. */ if (!revs->single_worktree) - die("BUG: --single-worktree cannot be used together with submodule"); + BUG("--single-worktree cannot be used together with submodule"); refs = get_submodule_ref_store(submodule); } else refs = get_main_ref_store(the_repository); diff --git a/run-command.c b/run-command.c index 12c94c1dbe..84b883c213 100644 --- a/run-command.c +++ b/run-command.c @@ -245,7 +245,7 @@ int sane_execvp(const char *file, char * const argv[]) static const char **prepare_shell_cmd(struct argv_array *out, const char **argv) { if (!argv[0]) - die("BUG: shell command is empty"); + BUG("shell command is empty"); if (strcspn(argv[0], "|&;<>()$`\\\"' \t\n*?[#~=%") != strlen(argv[0])) { #ifndef GIT_WINDOWS_NATIVE @@ -383,7 +383,7 @@ static void child_err_spew(struct child_process *cmd, struct child_err *cerr) static void prepare_cmd(struct argv_array *out, const struct child_process *cmd) { if (!cmd->argv[0]) - die("BUG: command is empty"); + BUG("command is empty"); /* * Add SHELL_PATH so in the event exec fails with ENOEXEC we can @@ -471,15 +471,12 @@ struct atfork_state { sigset_t old; }; -#ifndef NO_PTHREADS -static void bug_die(int err, const char *msg) -{ - if (err) { - errno = err; - die_errno("BUG: %s", msg); - } -} -#endif +#define CHECK_BUG(err, msg) \ + do { \ + int e = (err); \ + if (e) \ + BUG("%s: %s", msg, strerror(e)); \ + } while(0) static void atfork_prepare(struct atfork_state *as) { @@ -491,9 +488,9 @@ static void atfork_prepare(struct atfork_state *as) if (sigprocmask(SIG_SETMASK, &all, &as->old)) die_errno("sigprocmask"); #else - bug_die(pthread_sigmask(SIG_SETMASK, &all, &as->old), + CHECK_BUG(pthread_sigmask(SIG_SETMASK, &all, &as->old), "blocking all signals"); - bug_die(pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &as->cs), + CHECK_BUG(pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &as->cs), "disabling cancellation"); #endif } @@ -504,9 +501,9 @@ static void atfork_parent(struct atfork_state *as) if (sigprocmask(SIG_SETMASK, &as->old, NULL)) die_errno("sigprocmask"); #else - bug_die(pthread_setcancelstate(as->cs, NULL), + CHECK_BUG(pthread_setcancelstate(as->cs, NULL), "re-enabling cancellation"); - bug_die(pthread_sigmask(SIG_SETMASK, &as->old, NULL), + CHECK_BUG(pthread_sigmask(SIG_SETMASK, &as->old, NULL), "restoring signal mask"); #endif } @@ -967,7 +964,7 @@ int run_command(struct child_process *cmd) int code; if (cmd->out < 0 || cmd->err < 0) - die("BUG: run_command with a pipe can cause deadlock"); + BUG("run_command with a pipe can cause deadlock"); code = start_command(cmd); if (code) @@ -1557,7 +1554,7 @@ static void pp_init(struct parallel_processes *pp, pp->data = data; if (!get_next_task) - die("BUG: you need to specify a get_next_task function"); + BUG("you need to specify a get_next_task function"); pp->get_next_task = get_next_task; pp->start_failure = start_failure ? start_failure : default_start_failure; @@ -1619,7 +1616,7 @@ static int pp_start_one(struct parallel_processes *pp) if (pp->children[i].state == GIT_CP_FREE) break; if (i == pp->max_processes) - die("BUG: bookkeeping is hard"); + BUG("bookkeeping is hard"); code = pp->get_next_task(&pp->children[i].process, &pp->children[i].err, @@ -539,7 +539,7 @@ void read_gitfile_error_die(int error_code, const char *path, const char *dir) case READ_GITFILE_ERR_NOT_A_REPO: die(_("not a git repository: %s"), dir); default: - die("BUG: unknown error code"); + BUG("unknown error code"); } } @@ -1086,7 +1086,7 @@ const char *setup_git_directory_gently(int *nongit_ok) "Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set)."), dir.buf); default: - die("BUG: unhandled setup_git_directory_1() result"); + BUG("unhandled setup_git_directory_1() result"); } if (prefix) diff --git a/sha1-lookup.c b/sha1-lookup.c index 8d0b1db3e2..796ab68da8 100644 --- a/sha1-lookup.c +++ b/sha1-lookup.c @@ -81,7 +81,7 @@ int sha1_pos(const unsigned char *sha1, void *table, size_t nr, mi = (nr - 1) * (miv - lov) / (hiv - lov); if (lo <= mi && mi < hi) break; - die("BUG: assertion failed in binary search"); + BUG("assertion failed in binary search"); } } } diff --git a/sha1-name.c b/sha1-name.c index 80030b159a..60b8a935cc 100644 --- a/sha1-name.c +++ b/sha1-name.c @@ -384,7 +384,7 @@ static int get_short_oid(const char *name, int len, struct object_id *oid, return -1; if (HAS_MULTI_BITS(flags & GET_OID_DISAMBIGUATORS)) - die("BUG: multiple get_short_oid disambiguator flags"); + BUG("multiple get_short_oid disambiguator flags"); if (flags & GET_OID_COMMIT) ds.fn = disambiguate_commit_only; @@ -1729,6 +1729,6 @@ void maybe_die_on_misspelt_object_name(const char *name, const char *prefix) int get_oid_with_context(const char *str, unsigned flags, struct object_id *oid, struct object_context *oc) { if (flags & GET_OID_FOLLOW_SYMLINKS && flags & GET_OID_ONLY_TO_DIE) - die("BUG: incompatible flags for get_sha1_with_context"); + BUG("incompatible flags for get_sha1_with_context"); return get_oid_with_context_1(str, flags, NULL, oid, oc); } @@ -20,7 +20,7 @@ static char *alternate_shallow_file; void set_alternate_shallow_file(const char *path, int override) { if (is_shallow != -1) - die("BUG: is_repository_shallow must not be called before set_alternate_shallow_file"); + BUG("is_repository_shallow must not be called before set_alternate_shallow_file"); if (alternate_shallow_file && !override) return; free(alternate_shallow_file); @@ -218,7 +218,7 @@ struct commit_list *get_shallow_commits_by_rev_list(int ac, const char **av, static void check_shallow_file_for_update(void) { if (is_shallow == -1) - die("BUG: shallow must be initialized by now"); + BUG("shallow must be initialized by now"); if (!stat_validity_check(&shallow_stat, git_path_shallow())) die("shallow file has changed since we read it"); @@ -446,7 +446,7 @@ static uint32_t *paint_alloc(struct paint_info *info) void *p; if (!info->pool_count || size > info->end - info->free) { if (size > POOL_SIZE) - die("BUG: pool size too small for %d in paint_alloc()", + BUG("pool size too small for %d in paint_alloc()", size); info->pool_count++; REALLOC_ARRAY(info->pools, info->pool_count); diff --git a/sigchain.c b/sigchain.c index 2ac43bbd28..022677b6ab 100644 --- a/sigchain.c +++ b/sigchain.c @@ -13,7 +13,7 @@ static struct sigchain_signal signals[SIGCHAIN_MAX_SIGNALS]; static void check_signum(int sig) { if (sig < 1 || sig >= SIGCHAIN_MAX_SIGNALS) - die("BUG: signal out of range: %d", sig); + BUG("signal out of range: %d", sig); } int sigchain_push(int sig, sigchain_fun f) @@ -334,12 +334,12 @@ void strbuf_vaddf(struct strbuf *sb, const char *fmt, va_list ap) len = vsnprintf(sb->buf + sb->len, sb->alloc - sb->len, fmt, cp); va_end(cp); if (len < 0) - die("BUG: your vsnprintf is broken (returned %d)", len); + BUG("your vsnprintf is broken (returned %d)", len); if (len > strbuf_avail(sb)) { strbuf_grow(sb, len); len = vsnprintf(sb->buf + sb->len, sb->alloc - sb->len, fmt, ap); if (len > strbuf_avail(sb)) - die("BUG: your vsnprintf is broken (insatiable)"); + BUG("your vsnprintf is broken (insatiable)"); } strbuf_setlen(sb, sb->len + len); } diff --git a/submodule.c b/submodule.c index 8fd8e5d178..eb08cf0782 100644 --- a/submodule.c +++ b/submodule.c @@ -1400,7 +1400,7 @@ unsigned is_submodule_modified(const char *path, int ignore_untracked) buf.buf[0] == '2') { /* T = line type, XY = status, SSSS = submodule state */ if (buf.len < strlen("T XY SSSS")) - die("BUG: invalid status --porcelain=2 line %s", + BUG("invalid status --porcelain=2 line %s", buf.buf); if (buf.buf[5] == 'S' && buf.buf[8] == 'U') @@ -1609,7 +1609,7 @@ int submodule_move_head(const char *path, sub = submodule_from_path(the_repository, &null_oid, path); if (!sub) - die("BUG: could not get submodule information for '%s'", path); + BUG("could not get submodule information for '%s'", path); if (old_head && !(flags & SUBMODULE_MOVE_HEAD_FORCE)) { /* Check if the submodule has a dirty index. */ @@ -1967,7 +1967,7 @@ void absorb_git_dir_into_superproject(const char *prefix, struct strbuf sb = STRBUF_INIT; if (flags & ~ABSORB_GITDIR_RECURSE_SUBMODULES) - die("BUG: we don't know how to pass the flags down?"); + BUG("we don't know how to pass the flags down?"); strbuf_addstr(&sb, get_super_prefix_or_empty()); strbuf_addstr(&sb, path); @@ -2045,7 +2045,7 @@ const char *get_superproject_working_tree(void) if (super_sub_len > cwd_len || strcmp(&cwd[cwd_len - super_sub_len], super_sub)) - die (_("BUG: returned path string doesn't match cwd?")); + BUG("returned path string doesn't match cwd?"); super_wt = xstrdup(cwd); super_wt[cwd_len - super_sub_len] = '\0'; diff --git a/t/helper/test-example-decorate.c b/t/helper/test-example-decorate.c index 081115bf8e..a20a6161e4 100644 --- a/t/helper/test-example-decorate.c +++ b/t/helper/test-example-decorate.c @@ -30,10 +30,10 @@ int cmd__example_decorate(int argc, const char **argv) two = lookup_unknown_object(two_oid.hash); ret = add_decoration(&n, one, &decoration_a); if (ret) - die("BUG: when adding a brand-new object, NULL should be returned"); + BUG("when adding a brand-new object, NULL should be returned"); ret = add_decoration(&n, two, NULL); if (ret) - die("BUG: when adding a brand-new object, NULL should be returned"); + BUG("when adding a brand-new object, NULL should be returned"); /* * When re-adding an already existing object, the old decoration is @@ -41,10 +41,10 @@ int cmd__example_decorate(int argc, const char **argv) */ ret = add_decoration(&n, one, NULL); if (ret != &decoration_a) - die("BUG: when readding an already existing object, existing decoration should be returned"); + BUG("when readding an already existing object, existing decoration should be returned"); ret = add_decoration(&n, two, &decoration_b); if (ret) - die("BUG: when readding an already existing object, existing decoration should be returned"); + BUG("when readding an already existing object, existing decoration should be returned"); /* * Lookup returns the added declarations, or NULL if the object was @@ -52,14 +52,14 @@ int cmd__example_decorate(int argc, const char **argv) */ ret = lookup_decoration(&n, one); if (ret) - die("BUG: lookup should return added declaration"); + BUG("lookup should return added declaration"); ret = lookup_decoration(&n, two); if (ret != &decoration_b) - die("BUG: lookup should return added declaration"); + BUG("lookup should return added declaration"); three = lookup_unknown_object(three_oid.hash); ret = lookup_decoration(&n, three); if (ret) - die("BUG: lookup for unknown object should return NULL"); + BUG("lookup for unknown object should return NULL"); /* * The user can also loop through all entries. @@ -69,7 +69,7 @@ int cmd__example_decorate(int argc, const char **argv) objects_noticed++; } if (objects_noticed != 2) - die("BUG: should have 2 objects"); + BUG("should have 2 objects"); return 0; } diff --git a/t/helper/test-tool.c b/t/helper/test-tool.c index 87066ced62..805a45de9c 100644 --- a/t/helper/test-tool.c +++ b/t/helper/test-tool.c @@ -48,6 +48,7 @@ int cmd_main(int argc, const char **argv) { int i; + BUG_exit_code = 99; if (argc < 2) die("I need a test name!"); diff --git a/tmp-objdir.c b/tmp-objdir.c index fea3f55545..91c00567f4 100644 --- a/tmp-objdir.c +++ b/tmp-objdir.c @@ -127,7 +127,7 @@ struct tmp_objdir *tmp_objdir_create(void) struct tmp_objdir *t; if (the_tmp_objdir) - die("BUG: only one tmp_objdir can be used at a time"); + BUG("only one tmp_objdir can be used at a time"); t = xmalloc(sizeof(*t)); strbuf_init(&t->path, 0); @@ -298,7 +298,7 @@ static void apply_arg_if_exists(struct trailer_item *in_tok, free_arg_item(arg_tok); break; default: - die("BUG: trailer.c: unhandled value %d", + BUG("trailer.c: unhandled value %d", arg_tok->conf.if_exists); } } @@ -323,7 +323,7 @@ static void apply_arg_if_missing(struct list_head *head, list_add(&to_add->list, head); break; default: - die("BUG: trailer.c: unhandled value %d", + BUG("trailer.c: unhandled value %d", arg_tok->conf.if_missing); } } @@ -557,7 +557,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); break; default: - die("BUG: trailer.c: unhandled type %d", type); + BUG("trailer.c: unhandled type %d", type); } return 0; } diff --git a/transport.c b/transport.c index 2c4de32b33..6785fcceed 100644 --- a/transport.c +++ b/transport.c @@ -737,7 +737,7 @@ void transport_take_over(struct transport *transport, struct git_transport_data *data; if (!transport->smart_options) - die("BUG: taking over transport requires non-NULL " + BUG("taking over transport requires non-NULL " "smart_options field."); data = xcalloc(1, sizeof(*data)); @@ -862,7 +862,7 @@ int is_transport_allowed(const char *type, int from_user) return from_user; } - die("BUG: invalid protocol_allow_config type"); + BUG("invalid protocol_allow_config type"); } void transport_check_allowed(const char *type) diff --git a/unpack-trees.c b/unpack-trees.c index 0f01be6004..7051fcf7d8 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -398,7 +398,7 @@ static int check_updates(struct unpack_trees_options *o) if (ce->ce_flags & CE_UPDATE) { if (ce->ce_flags & CE_WT_REMOVE) - die("BUG: both update and delete flags are set on %s", + BUG("both update and delete flags are set on %s", ce->name); display_progress(progress, ++cnt); ce->ce_flags &= ~CE_UPDATE; @@ -210,6 +210,9 @@ void warning(const char *warn, ...) va_end(params); } +/* Only set this, ever, from t/helper/, when verifying that bugs are caught. */ +int BUG_exit_code; + static NORETURN void BUG_vfl(const char *file, int line, const char *fmt, va_list params) { char prefix[256]; @@ -221,6 +224,8 @@ static NORETURN void BUG_vfl(const char *file, int line, const char *fmt, va_lis snprintf(prefix, sizeof(prefix), "BUG: "); vreportf(prefix, fmt, params); + if (BUG_exit_code) + exit(BUG_exit_code); abort(); } diff --git a/vcs-svn/fast_export.c b/vcs-svn/fast_export.c index 3fd047a8b8..b5b8913cb0 100644 --- a/vcs-svn/fast_export.c +++ b/vcs-svn/fast_export.c @@ -320,7 +320,8 @@ const char *fast_export_read_path(const char *path, uint32_t *mode_out) err = fast_export_ls(path, mode_out, &buf); if (err) { if (errno != ENOENT) - die_errno("BUG: unexpected fast_export_ls error"); + BUG("unexpected fast_export_ls error: %s", + strerror(errno)); /* Treat missing paths as directories. */ *mode_out = S_IFDIR; return NULL; @@ -338,7 +339,8 @@ void fast_export_copy(uint32_t revision, const char *src, const char *dst) err = fast_export_ls_rev(revision, src, &mode, &data); if (err) { if (errno != ENOENT) - die_errno("BUG: unexpected fast_export_ls_rev error"); + BUG("unexpected fast_export_ls_rev error: %s", + strerror(errno)); fast_export_delete(dst); return; } diff --git a/worktree.c b/worktree.c index 28989cf06e..97cda5f97b 100644 --- a/worktree.c +++ b/worktree.c @@ -338,7 +338,7 @@ void update_worktree_location(struct worktree *wt, const char *path_) struct strbuf path = STRBUF_INIT; if (is_main_worktree(wt)) - die("BUG: can't relocate main worktree"); + BUG("can't relocate main worktree"); strbuf_realpath(&path, path_, 1); if (fspathcmp(wt->path, path.buf)) { @@ -643,9 +643,9 @@ int xsnprintf(char *dst, size_t max, const char *fmt, ...) va_end(ap); if (len < 0) - die("BUG: your snprintf is broken"); + BUG("your snprintf is broken"); if (len >= max) - die("BUG: attempt to snprintf into too-small buffer"); + BUG("attempt to snprintf into too-small buffer"); return len; } diff --git a/wt-status.c b/wt-status.c index 32f3bcaebd..0cf1bed995 100644 --- a/wt-status.c +++ b/wt-status.c @@ -264,7 +264,7 @@ static const char *wt_status_unmerged_status_string(int stagemask) case 7: return _("both modified:"); default: - die("BUG: unhandled unmerged status %x", stagemask); + BUG("unhandled unmerged status %x", stagemask); } } @@ -377,7 +377,7 @@ static void wt_longstatus_print_change_data(struct wt_status *s, status = d->worktree_status; break; default: - die("BUG: unhandled change_type %d in wt_longstatus_print_change_data", + BUG("unhandled change_type %d in wt_longstatus_print_change_data", change_type); } @@ -395,7 +395,7 @@ static void wt_longstatus_print_change_data(struct wt_status *s, status_printf(s, color(WT_STATUS_HEADER, s), "\t"); what = wt_status_diff_status_string(status); if (!what) - die("BUG: unhandled diff status %c", status); + BUG("unhandled diff status %c", status); len = label_width - utf8_strwidth(what); assert(len >= 0); if (one_name != two_name) @@ -470,7 +470,7 @@ static void wt_status_collect_changed_cb(struct diff_queue_struct *q, case DIFF_STATUS_COPIED: case DIFF_STATUS_RENAMED: if (d->rename_status) - die("BUG: multiple renames on the same target? how?"); + BUG("multiple renames on the same target? how?"); d->rename_source = xstrdup(p->one->path); d->rename_score = p->score * 100 / MAX_SCORE; d->rename_status = p->status; @@ -484,7 +484,7 @@ static void wt_status_collect_changed_cb(struct diff_queue_struct *q, break; default: - die("BUG: unhandled diff-files status '%c'", p->status); + BUG("unhandled diff-files status '%c'", p->status); break; } @@ -547,7 +547,7 @@ static void wt_status_collect_updated_cb(struct diff_queue_struct *q, case DIFF_STATUS_COPIED: case DIFF_STATUS_RENAMED: if (d->rename_status) - die("BUG: multiple renames on the same target? how?"); + BUG("multiple renames on the same target? how?"); d->rename_source = xstrdup(p->one->path); d->rename_score = p->score * 100 / MAX_SCORE; d->rename_status = p->status; @@ -569,7 +569,7 @@ static void wt_status_collect_updated_cb(struct diff_queue_struct *q, break; default: - die("BUG: unhandled diff-index status '%c'", p->status); + BUG("unhandled diff-index status '%c'", p->status); break; } } @@ -2154,7 +2154,7 @@ static void wt_porcelain_v2_print_unmerged_entry( case 6: key = "AA"; break; /* both added */ case 7: key = "UU"; break; /* both modified */ default: - die("BUG: unhandled unmerged status %x", d->stagemask); + BUG("unhandled unmerged status %x", d->stagemask); } /* @@ -2181,7 +2181,7 @@ static void wt_porcelain_v2_print_unmerged_entry( sum |= (1 << (stage - 1)); } if (sum != d->stagemask) - die("BUG: observed stagemask 0x%x != expected stagemask 0x%x", sum, d->stagemask); + BUG("observed stagemask 0x%x != expected stagemask 0x%x", sum, d->stagemask); if (s->null_termination) path_index = it->string; @@ -2285,7 +2285,7 @@ void wt_status_print(struct wt_status *s) wt_porcelain_v2_print(s); break; case STATUS_FORMAT_UNSPECIFIED: - die("BUG: finalize_deferred_config() should have been called"); + BUG("finalize_deferred_config() should have been called"); break; case STATUS_FORMAT_NONE: case STATUS_FORMAT_LONG: @@ -52,9 +52,9 @@ static void zlib_post_call(git_zstream *s) bytes_consumed = s->z.next_in - s->next_in; bytes_produced = s->z.next_out - s->next_out; if (s->z.total_out != s->total_out + bytes_produced) - die("BUG: total_out mismatch"); + BUG("total_out mismatch"); if (s->z.total_in != s->total_in + bytes_consumed) - die("BUG: total_in mismatch"); + BUG("total_in mismatch"); s->total_out = s->z.total_out; s->total_in = s->z.total_in; |