treewide: replace assert() with ASSERT() in special cases
When the compiler/linker cannot verify that an assert() invocation is free of side effects for us (e.g. because the assertion includes some kind of function call), replace the use of assert() with ASSERT(). Signed-off-by: Elijah Newren <newren@gmail.com> Acked-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Elijah Newren committed
Mar 19, 2025 at 16:22 UTC
5633aa3af1282cad5161174f17867399e58b2a54
7 files changed
+9
-9
diffcore-rename.c
+1
-1
@@ -1406,7 +1406,7 @@ void diffcore_rename_extended(struct diff_options *options,
1406
1407
trace2_region_enter("diff", "setup", options->repo);
1408
info.setup = 0;
1409
- assert(!dir_rename_count || strmap_empty(dir_rename_count));
1409
+ ASSERT(!dir_rename_count || strmap_empty(dir_rename_count));
1410
want_copies = (detect_rename == DIFF_DETECT_COPY);
1411
if (dirs_removed && (break_idx || want_copies))
1412
BUG("dirs_removed incompatible with break/copy detection");
merge-ort.c
+2
-2
@@ -791,7 +791,7 @@ static void path_msg(struct merge_options *opt,
791
struct strbuf tmp = STRBUF_INIT;
792
793
/* Sanity checks */
794
- assert(omittable_hint ==
794
+ ASSERT(omittable_hint ==
795
(!starts_with(type_short_descriptions[type], "CONFLICT") &&
796
!starts_with(type_short_descriptions[type], "ERROR")) ||
797
type == CONFLICT_DIR_RENAME_SUGGESTED);
@@ -1642,7 +1642,7 @@ static int handle_deferred_entries(struct merge_options *opt,
1642
ci = strmap_get(&opt->priv->paths, path);
1643
VERIFY_CI(ci);
1644
1645
- assert(renames->deferred[side].trivial_merges_okay &&
1645
+ ASSERT(renames->deferred[side].trivial_merges_okay &&
1646
!strset_contains(&renames->deferred[side].target_dirs,
1647
path));
1648
resolve_trivial_directory_merge(ci, side);
merge-recursive.c
+1
-1
@@ -1197,7 +1197,7 @@ static void print_commit(struct repository *repo, struct commit *commit)
1197
struct pretty_print_context ctx = {0};
1198
ctx.date_mode.type = DATE_NORMAL;
1199
/* FIXME: Merge this with output_commit_title() */
1200
- assert(!merge_remote_util(commit));
1200
+ ASSERT(!merge_remote_util(commit));
1201
repo_format_commit_message(repo, commit, " %h: %m %s", &sb, &ctx);
1202
fprintf(stderr, "%s\n", sb.buf);
1203
strbuf_release(&sb);
object-file.c
+1
-1
@@ -2706,7 +2706,7 @@ static int index_stream_convert_blob(struct index_state *istate,
2706
struct strbuf sbuf = STRBUF_INIT;
2707
2708
assert(path);
2709
- assert(would_convert_to_git_filter_fd(istate, path));
2709
+ ASSERT(would_convert_to_git_filter_fd(istate, path));
2710
2711
convert_to_git_filter_fd(istate, path, fd, &sbuf,
2712
get_conv_flags(flags));
parallel-checkout.c
+1
-1
@@ -277,7 +277,7 @@ static int write_pc_item_to_fd(struct parallel_checkout_item *pc_item, int fd,
277
ssize_t wrote;
278
279
/* Sanity check */
280
- assert(is_eligible_for_parallel_checkout(pc_item->ce, &pc_item->ca));
280
+ ASSERT(is_eligible_for_parallel_checkout(pc_item->ce, &pc_item->ca));
281
282
filter = get_stream_filter_ca(&pc_item->ca, &pc_item->ce->oid);
283
if (filter) {
scalar.c
+2
-2
@@ -241,7 +241,7 @@ static int add_or_remove_enlistment(int add)
241
242
static int start_fsmonitor_daemon(void)
243
{
244
- assert(have_fsmonitor_support());
244
+ ASSERT(have_fsmonitor_support());
245
246
if (fsmonitor_ipc__get_state() != IPC_STATE__LISTENING)
247
return run_git("fsmonitor--daemon", "start", NULL);
@@ -251,7 +251,7 @@ static int start_fsmonitor_daemon(void)
251
252
static int stop_fsmonitor_daemon(void)
253
{
254
- assert(have_fsmonitor_support());
254
+ ASSERT(have_fsmonitor_support());
255
256
if (fsmonitor_ipc__get_state() == IPC_STATE__LISTENING)
257
return run_git("fsmonitor--daemon", "stop", NULL);
sequencer.c
+1
-1
@@ -4965,7 +4965,7 @@ static int pick_commits(struct repository *r,
4965
4966
ctx->reflog_message = sequencer_reflog_action(opts);
4967
if (opts->allow_ff)
4968
- assert(!(opts->signoff || opts->no_commit ||
4968
+ ASSERT(!(opts->signoff || opts->no_commit ||
4969
opts->record_origin || should_edit(opts) ||
4970
opts->committer_date_is_author_date ||
4971
opts->ignore_date));