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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 5 additions & 5 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 10 additions & 10 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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;

0 commit comments

Comments
 (0)