Skip to content
Snippets Groups Projects
Commit 50f08db5 authored by Junio C Hamano's avatar Junio C Hamano
Browse files

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
parents bef896e4 746ea4ad
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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 */
Loading
Loading
@@ -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)
Loading
Loading
Loading
Loading
@@ -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)
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
@@ -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++)
Loading
Loading
@@ -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);
Loading
Loading
@@ -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();
Loading
Loading
Loading
Loading
@@ -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;
}
 
Loading
Loading
Loading
Loading
@@ -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)
Loading
Loading
@@ -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;
}
Loading
Loading
@@ -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);
Loading
Loading
@@ -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);
 
Loading
Loading
@@ -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)
Loading
Loading
@@ -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");
Loading
Loading
@@ -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);
Loading
Loading
@@ -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"));
 
Loading
Loading
@@ -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);
Loading
Loading
Loading
Loading
@@ -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)
Loading
Loading
Loading
Loading
@@ -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)
Loading
Loading
@@ -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;
}
Loading
Loading
Loading
Loading
@@ -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);
Loading
Loading
Loading
Loading
@@ -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)
Loading
Loading
Loading
Loading
@@ -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;
Loading
Loading
Loading
Loading
@@ -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);
Loading
Loading
Loading
Loading
@@ -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;
}
Loading
Loading
@@ -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)
Loading
Loading
Loading
Loading
@@ -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");
}
Loading
Loading
Loading
Loading
@@ -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 &&
Loading
Loading
Loading
Loading
@@ -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"),
Loading
Loading
@@ -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);
Loading
Loading
@@ -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"),
Loading
Loading
@@ -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);
Loading
Loading
Loading
Loading
@@ -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);
 
/*
Loading
Loading
@@ -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);
 
/*
Loading
Loading
Loading
Loading
@@ -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;
Loading
Loading
Loading
Loading
@@ -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,
Loading
Loading
Loading
Loading
@@ -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) {
Loading
Loading
Loading
Loading
@@ -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);
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment