]> git.ipfire.org Git - thirdparty/git.git/commitdiff
treewide: replace assert() with ASSERT() in special cases
authorElijah Newren <newren@gmail.com>
Wed, 19 Mar 2025 16:22:58 +0000 (16:22 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 21 Mar 2025 10:32:10 +0000 (03:32 -0700)
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>
diffcore-rename.c
merge-ort.c
merge-recursive.c
object-file.c
parallel-checkout.c
scalar.c
sequencer.c

index 91b77993c7827f9ddc7b444b42f480b8209fd821..624304f0416746fd82c729196d5c9742aba594c5 100644 (file)
@@ -1406,7 +1406,7 @@ void diffcore_rename_extended(struct diff_options *options,
 
        trace2_region_enter("diff", "setup", options->repo);
        info.setup = 0;
-       assert(!dir_rename_count || strmap_empty(dir_rename_count));
+       ASSERT(!dir_rename_count || strmap_empty(dir_rename_count));
        want_copies = (detect_rename == DIFF_DETECT_COPY);
        if (dirs_removed && (break_idx || want_copies))
                BUG("dirs_removed incompatible with break/copy detection");
index 46e78c3ffa68e62dec08e8619800fcae28a9dd9d..d484f16cf2bf2cc5217078453b5c6ec20df60af6 100644 (file)
@@ -791,7 +791,7 @@ static void path_msg(struct merge_options *opt,
        struct strbuf tmp = STRBUF_INIT;
 
        /* Sanity checks */
-       assert(omittable_hint ==
+       ASSERT(omittable_hint ==
               (!starts_with(type_short_descriptions[type], "CONFLICT") &&
                !starts_with(type_short_descriptions[type], "ERROR")) ||
               type == CONFLICT_DIR_RENAME_SUGGESTED);
@@ -1642,7 +1642,7 @@ static int handle_deferred_entries(struct merge_options *opt,
                        ci = strmap_get(&opt->priv->paths, path);
                        VERIFY_CI(ci);
 
-                       assert(renames->deferred[side].trivial_merges_okay &&
+                       ASSERT(renames->deferred[side].trivial_merges_okay &&
                               !strset_contains(&renames->deferred[side].target_dirs,
                                                path));
                        resolve_trivial_directory_merge(ci, side);
index 884ccf99a58d3b41a5d592ddb1167bc011a3d965..4fbbece922c8cf0cc95cdc4be12c937f298ce960 100644 (file)
@@ -1197,7 +1197,7 @@ static void print_commit(struct repository *repo, struct commit *commit)
        struct pretty_print_context ctx = {0};
        ctx.date_mode.type = DATE_NORMAL;
        /* FIXME: Merge this with output_commit_title() */
-       assert(!merge_remote_util(commit));
+       ASSERT(!merge_remote_util(commit));
        repo_format_commit_message(repo, commit, " %h: %m %s", &sb, &ctx);
        fprintf(stderr, "%s\n", sb.buf);
        strbuf_release(&sb);
index 726e41a0475b432a45f8ca193c68e1740bb4ac69..4fb3cd9dcb9baf7c4365fbb63a16c434b8787023 100644 (file)
@@ -2706,7 +2706,7 @@ static int index_stream_convert_blob(struct index_state *istate,
        struct strbuf sbuf = STRBUF_INIT;
 
        assert(path);
-       assert(would_convert_to_git_filter_fd(istate, path));
+       ASSERT(would_convert_to_git_filter_fd(istate, path));
 
        convert_to_git_filter_fd(istate, path, fd, &sbuf,
                                 get_conv_flags(flags));
index 7cc6b3052819ac640968a6dd01c0c7db1c7accb0..57c2dcaa8f60a179333f2b57be3c77c18fcc5ddd 100644 (file)
@@ -277,7 +277,7 @@ static int write_pc_item_to_fd(struct parallel_checkout_item *pc_item, int fd,
        ssize_t wrote;
 
        /* Sanity check */
-       assert(is_eligible_for_parallel_checkout(pc_item->ce, &pc_item->ca));
+       ASSERT(is_eligible_for_parallel_checkout(pc_item->ce, &pc_item->ca));
 
        filter = get_stream_filter_ca(&pc_item->ca, &pc_item->ce->oid);
        if (filter) {
index da42b4be0cc9b6b3fd86861f37d9c8a9cf69bbcf..d359f08bb8e23e1a28e82ee627aafad913872219 100644 (file)
--- a/scalar.c
+++ b/scalar.c
@@ -241,7 +241,7 @@ static int add_or_remove_enlistment(int add)
 
 static int start_fsmonitor_daemon(void)
 {
-       assert(have_fsmonitor_support());
+       ASSERT(have_fsmonitor_support());
 
        if (fsmonitor_ipc__get_state() != IPC_STATE__LISTENING)
                return run_git("fsmonitor--daemon", "start", NULL);
@@ -251,7 +251,7 @@ static int start_fsmonitor_daemon(void)
 
 static int stop_fsmonitor_daemon(void)
 {
-       assert(have_fsmonitor_support());
+       ASSERT(have_fsmonitor_support());
 
        if (fsmonitor_ipc__get_state() == IPC_STATE__LISTENING)
                return run_git("fsmonitor--daemon", "stop", NULL);
index ad0ab75c8d4dd7c91d600276afe01935bdda0922..c625a39111e11b7043f09f9912962cff71033af3 100644 (file)
@@ -4965,7 +4965,7 @@ static int pick_commits(struct repository *r,
 
        ctx->reflog_message = sequencer_reflog_action(opts);
        if (opts->allow_ff)
-               assert(!(opts->signoff || opts->no_commit ||
+               ASSERT(!(opts->signoff || opts->no_commit ||
                         opts->record_origin || should_edit(opts) ||
                         opts->committer_date_is_author_date ||
                         opts->ignore_date));