Skip to content

Commit 033abf9

Browse files
dschogitster
authored andcommitted
Replace all die("BUG: ...") calls by BUG() ones
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]>
1 parent dde74d7 commit 033abf9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+190
-190
lines changed

apply.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -2375,7 +2375,7 @@ static void update_pre_post_images(struct image *preimage,
23752375
if (postlen
23762376
? postlen < new_buf - postimage->buf
23772377
: postimage->len < new_buf - postimage->buf)
2378-
die("BUG: caller miscounted postlen: asked %d, orig = %d, used = %d",
2378+
BUG("caller miscounted postlen: asked %d, orig = %d, used = %d",
23792379
(int)postlen, (int) postimage->len, (int)(new_buf - postimage->buf));
23802380

23812381
/* Fix the length of the whole thing */
@@ -3509,7 +3509,7 @@ static int load_current(struct apply_state *state,
35093509
unsigned mode = patch->new_mode;
35103510

35113511
if (!patch->is_new)
3512-
die("BUG: patch to %s is not a creation", patch->old_name);
3512+
BUG("patch to %s is not a creation", patch->old_name);
35133513

35143514
pos = cache_name_pos(name, strlen(name));
35153515
if (pos < 0)

archive-tar.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ static int write_tar_filter_archive(const struct archiver *ar,
441441
int r;
442442

443443
if (!ar->data)
444-
die("BUG: tar-filter archiver called with no filter defined");
444+
BUG("tar-filter archiver called with no filter defined");
445445

446446
strbuf_addstr(&cmd, ar->data);
447447
if (args->compression_level >= 0)

attr.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ static void all_attrs_init(struct attr_hashmap *map, struct attr_check *check)
157157

158158
size = hashmap_get_size(&map->map);
159159
if (size < check->all_attrs_nr)
160-
die("BUG: interned attributes shouldn't be deleted");
160+
BUG("interned attributes shouldn't be deleted");
161161

162162
/*
163163
* If the number of attributes in the global dictionary has increased
@@ -541,7 +541,7 @@ static void check_vector_remove(struct attr_check *check)
541541
break;
542542

543543
if (i >= check_vector.nr)
544-
die("BUG: no entry found");
544+
BUG("no entry found");
545545

546546
/* shift entries over */
547547
for (; i < check_vector.nr - 1; i++)
@@ -599,11 +599,11 @@ struct attr_check *attr_check_initl(const char *one, ...)
599599
const struct git_attr *attr;
600600
param = va_arg(params, const char *);
601601
if (!param)
602-
die("BUG: counted %d != ended at %d",
602+
BUG("counted %d != ended at %d",
603603
check->nr, cnt);
604604
attr = git_attr(param);
605605
if (!attr)
606-
die("BUG: %s: not a valid attribute name", param);
606+
BUG("%s: not a valid attribute name", param);
607607
check->items[cnt].attr = attr;
608608
}
609609
va_end(params);
@@ -714,7 +714,7 @@ void git_attr_set_direction(enum git_attr_direction new_direction,
714714
struct index_state *istate)
715715
{
716716
if (is_bare_repository() && new_direction != GIT_ATTR_INDEX)
717-
die("BUG: non-INDEX attr direction in a bare repo");
717+
BUG("non-INDEX attr direction in a bare repo");
718718

719719
if (new_direction != direction)
720720
drop_all_attr_stacks();

blame.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1806,7 +1806,7 @@ void setup_scoreboard(struct blame_scoreboard *sb, const char *path, struct blam
18061806
l->item = c;
18071807
if (add_decoration(&sb->revs->children,
18081808
&c->parents->item->object, l))
1809-
die("BUG: not unique item in first-parent chain");
1809+
BUG("not unique item in first-parent chain");
18101810
c = c->parents->item;
18111811
}
18121812

builtin/am.c

+10-10
Original file line numberDiff line numberDiff line change
@@ -403,11 +403,11 @@ static void am_load(struct am_state *state)
403403
struct strbuf sb = STRBUF_INIT;
404404

405405
if (read_state_file(&sb, state, "next", 1) < 0)
406-
die("BUG: state file 'next' does not exist");
406+
BUG("state file 'next' does not exist");
407407
state->cur = strtol(sb.buf, NULL, 10);
408408

409409
if (read_state_file(&sb, state, "last", 1) < 0)
410-
die("BUG: state file 'last' does not exist");
410+
BUG("state file 'last' does not exist");
411411
state->last = strtol(sb.buf, NULL, 10);
412412

413413
if (read_author_script(state) < 0)
@@ -986,7 +986,7 @@ static int split_mail(struct am_state *state, enum patch_format patch_format,
986986
case PATCH_FORMAT_MBOXRD:
987987
return split_mail_mbox(state, paths, keep_cr, 1);
988988
default:
989-
die("BUG: invalid patch_format");
989+
BUG("invalid patch_format");
990990
}
991991
return -1;
992992
}
@@ -1041,7 +1041,7 @@ static void am_setup(struct am_state *state, enum patch_format patch_format,
10411041
str = "b";
10421042
break;
10431043
default:
1044-
die("BUG: invalid value for state->keep");
1044+
BUG("invalid value for state->keep");
10451045
}
10461046

10471047
write_state_text(state, "keep", str);
@@ -1058,7 +1058,7 @@ static void am_setup(struct am_state *state, enum patch_format patch_format,
10581058
str = "t";
10591059
break;
10601060
default:
1061-
die("BUG: invalid value for state->scissors");
1061+
BUG("invalid value for state->scissors");
10621062
}
10631063
write_state_text(state, "scissors", str);
10641064

@@ -1216,7 +1216,7 @@ static int parse_mail(struct am_state *state, const char *mail)
12161216
mi.keep_non_patch_brackets_in_subject = 1;
12171217
break;
12181218
default:
1219-
die("BUG: invalid value for state->keep");
1219+
BUG("invalid value for state->keep");
12201220
}
12211221

12221222
if (state->message_id)
@@ -1232,7 +1232,7 @@ static int parse_mail(struct am_state *state, const char *mail)
12321232
mi.use_scissors = 1;
12331233
break;
12341234
default:
1235-
die("BUG: invalid value for state->scissors");
1235+
BUG("invalid value for state->scissors");
12361236
}
12371237

12381238
mi.input = xfopen(mail, "r");
@@ -1463,7 +1463,7 @@ static int run_apply(const struct am_state *state, const char *index_file)
14631463
int options = 0;
14641464

14651465
if (init_apply_state(&apply_state, NULL))
1466-
die("BUG: init_apply_state() failed");
1466+
BUG("init_apply_state() failed");
14671467

14681468
argv_array_push(&apply_opts, "apply");
14691469
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)
14891489
apply_state.apply_verbosity = verbosity_silent;
14901490

14911491
if (check_apply_state(&apply_state, force_apply))
1492-
die("BUG: check_apply_state() failed");
1492+
BUG("check_apply_state() failed");
14931493

14941494
argv_array_push(&apply_paths, am_path(state, "patch"));
14951495

@@ -2407,7 +2407,7 @@ int cmd_am(int argc, const char **argv, const char *prefix)
24072407
ret = show_patch(&state);
24082408
break;
24092409
default:
2410-
die("BUG: invalid resume value");
2410+
BUG("invalid resume value");
24112411
}
24122412

24132413
am_state_release(&state);

builtin/branch.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ static void copy_or_rename_branch(const char *oldname, const char *newname, int
497497

498498
if (!skip_prefix(oldref.buf, "refs/heads/", &interpreted_oldname) ||
499499
!skip_prefix(newref.buf, "refs/heads/", &interpreted_newname)) {
500-
die("BUG: expected prefix missing for refs");
500+
BUG("expected prefix missing for refs");
501501
}
502502

503503
if (copy)

builtin/cat-file.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
312312
die("could not convert '%s' %s",
313313
oid_to_hex(oid), data->rest);
314314
} else
315-
die("BUG: invalid cmdmode: %c", opt->cmdmode);
315+
BUG("invalid cmdmode: %c", opt->cmdmode);
316316
batch_write(opt, contents, size);
317317
free(contents);
318318
} 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,
387387
(uintmax_t)strlen(obj_name), obj_name);
388388
break;
389389
default:
390-
die("BUG: unknown get_sha1_with_context result %d\n",
390+
BUG("unknown get_sha1_with_context result %d\n",
391391
result);
392392
break;
393393
}

builtin/clone.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ static void write_refspec_config(const char *src_ref_prefix,
823823
} else if (remote_head_points_at) {
824824
const char *head = remote_head_points_at->name;
825825
if (!skip_prefix(head, "refs/heads/", &head))
826-
die("BUG: remote HEAD points at non-head?");
826+
BUG("remote HEAD points at non-head?");
827827

828828
strbuf_addf(&value, "+%s:%s%s", remote_head_points_at->name,
829829
branch_top->buf, head);

builtin/commit.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ static int is_a_merge(const struct commit *current_head)
495495
static void assert_split_ident(struct ident_split *id, const struct strbuf *buf)
496496
{
497497
if (split_ident_line(id, buf->buf, buf->len) || !id->date_begin)
498-
die("BUG: unable to parse our own ident: %s", buf->buf);
498+
BUG("unable to parse our own ident: %s", buf->buf);
499499
}
500500

501501
static void export_one(const char *var, const char *s, const char *e, int hack)

builtin/config.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ static char *normalize_value(const char *key, const char *value)
309309
return xstrdup(v ? "true" : "false");
310310
}
311311

312-
die("BUG: cannot normalize type %d", types);
312+
BUG("cannot normalize type %d", types);
313313
}
314314

315315
static int get_color_found;

builtin/fast-export.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ static void anonymize_ident_line(const char **beg, const char **end)
517517
/* skip "committer", "author", "tagger", etc */
518518
end_of_header = strchr(*beg, ' ');
519519
if (!end_of_header)
520-
die("BUG: malformed line fed to anonymize_ident_line: %.*s",
520+
BUG("malformed line fed to anonymize_ident_line: %.*s",
521521
(int)(*end - *beg), *beg);
522522
end_of_header++;
523523
strbuf_add(out, *beg, end_of_header - *beg);

builtin/fsck.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ static struct object *parse_loose_object(const struct object_id *oid,
519519
return NULL;
520520

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

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

builtin/index-pack.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
866866
if (obj->type == OBJ_COMMIT) {
867867
struct commit *commit = (struct commit *) obj;
868868
if (detach_commit_buffer(commit, NULL) != data)
869-
die("BUG: parse_object_buffer transmogrified our buffer");
869+
BUG("parse_object_buffer transmogrified our buffer");
870870
}
871871
obj->flags |= FLAG_CHECKED;
872872
}
@@ -1015,7 +1015,7 @@ static struct base_data *find_unresolved_deltas_1(struct base_data *base,
10151015

10161016
if (!compare_and_swap_type(&child->real_type, OBJ_REF_DELTA,
10171017
base->obj->real_type))
1018-
die("BUG: child->real_type != OBJ_REF_DELTA");
1018+
BUG("child->real_type != OBJ_REF_DELTA");
10191019

10201020
resolve_delta(child, base, result);
10211021
if (base->ref_first == base->ref_last && base->ofs_last == -1)

builtin/init-db.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ int init_db(const char *git_dir, const char *real_git_dir,
391391
else if (get_shared_repository() == PERM_EVERYBODY)
392392
xsnprintf(buf, sizeof(buf), "%d", OLD_PERM_EVERYBODY);
393393
else
394-
die("BUG: invalid value for shared_repository");
394+
BUG("invalid value for shared_repository");
395395
git_config_set("core.sharedrepository", buf);
396396
git_config_set("receive.denyNonFastforwards", "true");
397397
}

builtin/ls-files.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ static void show_killed_files(const struct index_state *istate,
166166
*/
167167
pos = index_name_pos(istate, ent->name, ent->len);
168168
if (0 <= pos)
169-
die("BUG: killed-file %.*s not found",
169+
BUG("killed-file %.*s not found",
170170
ent->len, ent->name);
171171
pos = -pos - 1;
172172
while (pos < istate->cache_nr &&

builtin/notes.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ static int add(int argc, const char **argv, const char *prefix)
461461
if (d.buf.len || allow_empty) {
462462
write_note_data(&d, &new_note);
463463
if (add_note(t, &object, &new_note, combine_notes_overwrite))
464-
die("BUG: combine_notes_overwrite failed");
464+
BUG("combine_notes_overwrite failed");
465465
commit_notes(t, "Notes added by 'git notes add'");
466466
} else {
467467
fprintf(stderr, _("Removing note for object %s\n"),
@@ -544,7 +544,7 @@ static int copy(int argc, const char **argv, const char *prefix)
544544
}
545545

546546
if (add_note(t, &object, from_note, combine_notes_overwrite))
547-
die("BUG: combine_notes_overwrite failed");
547+
BUG("combine_notes_overwrite failed");
548548
commit_notes(t, "Notes added by 'git notes copy'");
549549
out:
550550
free_notes(t);
@@ -621,7 +621,7 @@ static int append_edit(int argc, const char **argv, const char *prefix)
621621
if (d.buf.len || allow_empty) {
622622
write_note_data(&d, &new_note);
623623
if (add_note(t, &object, &new_note, combine_notes_overwrite))
624-
die("BUG: combine_notes_overwrite failed");
624+
BUG("combine_notes_overwrite failed");
625625
logmsg = xstrfmt("Notes added by 'git notes %s'", argv[0]);
626626
} else {
627627
fprintf(stderr, _("Removing note for object %s\n"),
@@ -831,7 +831,7 @@ static int merge(int argc, const char **argv, const char *prefix)
831831
const char *short_ref = NULL;
832832

833833
if (!skip_prefix(o.local_ref, "refs/notes/", &short_ref))
834-
die("BUG: local ref %s is outside of refs/notes/",
834+
BUG("local ref %s is outside of refs/notes/",
835835
o.local_ref);
836836

837837
strbuf_addf(&merge_key, "notes.%s.mergeStrategy", short_ref);

builtin/pack-objects.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1620,7 +1620,7 @@ static void break_delta_chains(struct object_entry *entry)
16201620
* is a bug.
16211621
*/
16221622
if (cur->dfs_state != DFS_NONE)
1623-
die("BUG: confusing delta dfs state in first pass: %d",
1623+
BUG("confusing delta dfs state in first pass: %d",
16241624
cur->dfs_state);
16251625

16261626
/*
@@ -1677,7 +1677,7 @@ static void break_delta_chains(struct object_entry *entry)
16771677
if (cur->dfs_state == DFS_DONE)
16781678
break;
16791679
else if (cur->dfs_state != DFS_ACTIVE)
1680-
die("BUG: confusing delta dfs state in second pass: %d",
1680+
BUG("confusing delta dfs state in second pass: %d",
16811681
cur->dfs_state);
16821682

16831683
/*

builtin/pull.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ static int run_fetch(const char *repo, const char **refspecs)
539539
argv_array_push(&args, repo);
540540
argv_array_pushv(&args, refspecs);
541541
} else if (*refspecs)
542-
die("BUG: refspecs without repo?");
542+
BUG("refspecs without repo?");
543543
ret = run_command_v_opt(args.argv, RUN_GIT_CMD);
544544
argv_array_clear(&args);
545545
return ret;

builtin/receive-pack.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1378,7 +1378,7 @@ static void warn_if_skipped_connectivity_check(struct command *commands,
13781378
}
13791379
}
13801380
if (!checked_connectivity)
1381-
die("BUG: connectivity check skipped???");
1381+
BUG("connectivity check skipped???");
13821382
}
13831383

13841384
static void execute_commands_non_atomic(struct command *commands,

builtin/replace.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,6 @@ int cmd_replace(int argc, const char **argv, const char *prefix)
501501
return list_replace_refs(argv[0], format);
502502

503503
default:
504-
die("BUG: invalid cmdmode %d", (int)cmdmode);
504+
BUG("invalid cmdmode %d", (int)cmdmode);
505505
}
506506
}

builtin/update-index.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1164,7 +1164,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
11641164
report(_("Untracked cache enabled for '%s'"), get_git_work_tree());
11651165
break;
11661166
default:
1167-
die("BUG: bad untracked_cache value: %d", untracked_cache);
1167+
BUG("bad untracked_cache value: %d", untracked_cache);
11681168
}
11691169

11701170
if (fsmonitor > 0) {

bulk-checkin.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ static int deflate_to_pack(struct bulk_checkin_state *state,
230230
* pack, and write into it.
231231
*/
232232
if (!idx)
233-
die("BUG: should not happen");
233+
BUG("should not happen");
234234
hashfile_truncate(state->f, &checkpoint);
235235
state->offset = checkpoint.offset;
236236
finish_bulk_checkin(state);

color.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ static char *color_output(char *out, int len, const struct color *c, char type)
174174
break;
175175
case COLOR_ANSI:
176176
if (len < 2)
177-
die("BUG: color parsing ran out of space");
177+
BUG("color parsing ran out of space");
178178
*out++ = type;
179179
*out++ = '0' + c->value;
180180
break;
@@ -256,7 +256,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)
256256
#undef OUT
257257
#define OUT(x) do { \
258258
if (dst == end) \
259-
die("BUG: color parsing ran out of space"); \
259+
BUG("color parsing ran out of space"); \
260260
*dst++ = (x); \
261261
} while(0)
262262

column.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ void print_columns(const struct string_list *list, unsigned int colopts,
214214
display_table(list, colopts, &nopts);
215215
break;
216216
default:
217-
die("BUG: invalid layout mode %d", COL_LAYOUT(colopts));
217+
BUG("invalid layout mode %d", COL_LAYOUT(colopts));
218218
}
219219
}
220220

0 commit comments

Comments
 (0)