]> git.ipfire.org Git - thirdparty/git.git/commitdiff
diff: spell DIFF_INDEX_CACHED out when calling run_diff_index()
authorJunio C Hamano <gitster@pobox.com>
Mon, 21 Aug 2023 20:14:14 +0000 (16:14 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 21 Aug 2023 22:33:23 +0000 (15:33 -0700)
Many callers of run_diff_index() passed literal "1" for the option
flag word, which should better be spelled out as DIFF_INDEX_CACHED
for readablity.  Everybody else passes "0" that can stay as-is.

The other bit in the option flag word is DIFF_INDEX_MERGE_BASE, but
curiously there is only one caller that can pass it, which is "git
diff-index --merge-base" itself---no internal callers uses the
feature.

A bit tricky call to the function is in builtin/submodule--helper.c
where the .cached member in a private struct is set/reset as a plain
Boolean flag, which happens to be "1" and happens to match the value
of DIFF_INDEX_CACHED.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
add-interactive.c
builtin/am.c
builtin/stash.c
builtin/submodule--helper.c
diff-lib.c
wt-status.c

index add9a1ad4364f92833256d5f53dbb3bc85b43ede..7fd00c5e2502d6aa2c151196f87fb20ed0c0c578 100644 (file)
@@ -569,7 +569,7 @@ static int get_modified_files(struct repository *r,
                        copy_pathspec(&rev.prune_data, ps);
 
                if (s.mode == FROM_INDEX)
-                       run_diff_index(&rev, 1);
+                       run_diff_index(&rev, DIFF_INDEX_CACHED);
                else {
                        rev.diffopt.flags.ignore_dirty_submodules = 1;
                        run_diff_files(&rev, 0);
index 8bde034fae68bcdd8fc0f0b9b61837d29608d62b..202040b62e4784a3c1d43cdea3f4cdc6171324f9 100644 (file)
@@ -1430,7 +1430,7 @@ static void write_index_patch(const struct am_state *state)
        rev_info.diffopt.close_file = 1;
        add_pending_object(&rev_info, &tree->object, "");
        diff_setup_done(&rev_info.diffopt);
-       run_diff_index(&rev_info, 1);
+       run_diff_index(&rev_info, DIFF_INDEX_CACHED);
        release_revisions(&rev_info);
 }
 
@@ -1593,7 +1593,7 @@ static int fall_back_threeway(const struct am_state *state, const char *index_pa
                rev_info.diffopt.filter |= diff_filter_bit('M');
                add_pending_oid(&rev_info, "HEAD", &our_tree, 0);
                diff_setup_done(&rev_info.diffopt);
-               run_diff_index(&rev_info, 1);
+               run_diff_index(&rev_info, DIFF_INDEX_CACHED);
                release_revisions(&rev_info);
        }
 
index fe64cde9ce3010e812f789dfbe040c64f16bec45..fe5052f12fd2b6b34e26936ee1fbc078539a0e9f 100644 (file)
@@ -1111,7 +1111,7 @@ static int check_changes_tracked_files(const struct pathspec *ps)
        add_head_to_pending(&rev);
        diff_setup_done(&rev.diffopt);
 
-       result = run_diff_index(&rev, 1);
+       result = run_diff_index(&rev, DIFF_INDEX_CACHED);
        if (diff_result_code(&rev.diffopt, result)) {
                ret = 1;
                goto done;
index f6871efd95dbca6da051f2d1b3b81b3c5c52b0b5..125ea80d217514782f9344c91ce25e9f5b1e113b 100644 (file)
@@ -1141,7 +1141,7 @@ static int compute_summary_module_list(struct object_id *head_oid,
        }
 
        if (diff_cmd == DIFF_INDEX)
-               run_diff_index(&rev, info->cached);
+               run_diff_index(&rev, info->cached ? DIFF_INDEX_CACHED : 0);
        else
                run_diff_files(&rev, 0);
        prepare_submodule_summary(info, &list);
index 6b0c6a7180cc0432a7e919271dfad74405d30096..cfa348911119c625343b7cfe18cfae024461304c 100644 (file)
@@ -682,7 +682,7 @@ int index_differs_from(struct repository *r,
                        rev.diffopt.flags.ignore_submodules = flags->ignore_submodules;
        }
        rev.diffopt.ita_invisible_in_index = ita_invisible_in_index;
-       run_diff_index(&rev, 1);
+       run_diff_index(&rev, DIFF_INDEX_CACHED);
        has_changes = rev.diffopt.flags.has_changes;
        release_revisions(&rev);
        return (has_changes != 0);
index 5b1378965c9aa37505a23cf9c472f1abe4d8503e..bf8687b3574d0c00c6ed44a31163a2d1151a7fe0 100644 (file)
@@ -675,7 +675,7 @@ static void wt_status_collect_changes_index(struct wt_status *s)
        rev.diffopt.flags.recursive = 1;
 
        copy_pathspec(&rev.prune_data, &s->pathspec);
-       run_diff_index(&rev, 1);
+       run_diff_index(&rev, DIFF_INDEX_CACHED);
        release_revisions(&rev);
 }
 
@@ -1156,7 +1156,7 @@ static void wt_longstatus_print_verbose(struct wt_status *s)
                rev.diffopt.a_prefix = "c/";
                rev.diffopt.b_prefix = "i/";
        } /* else use prefix as per user config */
-       run_diff_index(&rev, 1);
+       run_diff_index(&rev, DIFF_INDEX_CACHED);
        if (s->verbose > 1 &&
            wt_status_check_worktree_changes(s, &dirty_submodules)) {
                status_printf_ln(s, c,
@@ -2614,7 +2614,7 @@ int has_uncommitted_changes(struct repository *r,
        }
 
        diff_setup_done(&rev_info.diffopt);
-       result = run_diff_index(&rev_info, 1);
+       result = run_diff_index(&rev_info, DIFF_INDEX_CACHED);
        result = diff_result_code(&rev_info.diffopt, result);
        release_revisions(&rev_info);
        return result;