Skip to content

Commit

Permalink
Replace all die("BUG: ...") calls by BUG() ones
Browse files Browse the repository at this point in the history
In d819374 (usage.c: add BUG() function, 2017-05-12), a new macro
was introduced to use for reporting bugs instead of die(). It was then
subsequently used to convert one single caller in 588a538
(setup_git_env: convert die("BUG") to BUG(), 2017-05-12).

The cover letter of the patch series containing this patch
(cf [email protected]) is not
terribly clear why only one call site was converted, or what the plan
is for other, similar calls to die() to report bugs.

Let's just convert all remaining ones in one fell swoop.

This trick was performed by this invocation:

	sed -i 's/die("BUG: /BUG("/g' $(git grep -l 'die("BUG' \*.c)

Signed-off-by: Johannes Schindelin <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
dscho authored and gitster committed May 6, 2018
1 parent dde74d7 commit 033abf9
Show file tree
Hide file tree
Showing 67 changed files with 190 additions and 190 deletions.
4 changes: 2 additions & 2 deletions apply.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion archive-tar.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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++)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion blame.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
20 changes: 10 additions & 10 deletions builtin/am.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand All @@ -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);

Expand Down Expand Up @@ -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)
Expand All @@ -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");
Expand Down Expand Up @@ -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);
Expand All @@ -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"));

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion builtin/branch.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,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)
Expand Down
4 changes: 2 additions & 2 deletions builtin/cat-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion builtin/clone.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion builtin/commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion builtin/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ static char *normalize_value(const char *key, const char *value)
return xstrdup(v ? "true" : "false");
}

die("BUG: cannot normalize type %d", types);
BUG("cannot normalize type %d", types);
}

static int get_color_found;
Expand Down
2 changes: 1 addition & 1 deletion builtin/fast-export.c
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,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);
Expand Down
2 changes: 1 addition & 1 deletion builtin/fsck.c
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ static struct object *parse_loose_object(const struct object_id *oid,
return NULL;

if (!contents && type != OBJ_BLOB)
die("BUG: read_loose_object streamed a non-blob");
BUG("read_loose_object streamed a non-blob");

obj = parse_object_buffer(oid, type, size, contents, &eaten);

Expand Down
4 changes: 2 additions & 2 deletions builtin/index-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,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;
}
Expand Down Expand Up @@ -1015,7 +1015,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)
Expand Down
2 changes: 1 addition & 1 deletion builtin/init-db.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
2 changes: 1 addition & 1 deletion builtin/ls-files.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down
8 changes: 4 additions & 4 deletions builtin/notes.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions builtin/pack-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -1620,7 +1620,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);

/*
Expand Down Expand Up @@ -1677,7 +1677,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);

/*
Expand Down
2 changes: 1 addition & 1 deletion builtin/pull.c
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,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;
Expand Down
2 changes: 1 addition & 1 deletion builtin/receive-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion builtin/replace.c
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,6 @@ int cmd_replace(int argc, const char **argv, const char *prefix)
return list_replace_refs(argv[0], format);

default:
die("BUG: invalid cmdmode %d", (int)cmdmode);
BUG("invalid cmdmode %d", (int)cmdmode);
}
}
2 changes: 1 addition & 1 deletion builtin/update-index.c
Original file line number Diff line number Diff line change
Expand Up @@ -1164,7 +1164,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) {
Expand Down
2 changes: 1 addition & 1 deletion bulk-checkin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions color.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion column.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

Expand Down
Loading

0 comments on commit 033abf9

Please sign in to comment.