]> git.ipfire.org Git - thirdparty/git.git/commitdiff
merge,diff: remove the_repository check before prefetching blobs
authorElijah Newren <newren@gmail.com>
Sat, 21 Feb 2026 23:59:48 +0000 (23:59 +0000)
committerJunio C Hamano <gitster@pobox.com>
Sun, 22 Feb 2026 02:34:06 +0000 (18:34 -0800)
Prefetching of blobs from promisor remotes was added to diff in
7fbbcb21b162 (diff: batch fetching of missing blobs, 2019-04-05).  In
that commit,

  https://lore.kernel.org/git/20190405170934.20441-1-jonathantanmy@google.com/

was squashed into

  https://lore.kernel.org/git/44de02e584f449481e6fb00cf35d74adf0192e9d.1553895166.git.jonathantanmy@google.com/

without the extra explanation about the squashed changes being added to
the commit message; in particular, this explanation from that first link
is absent:

> Also, prefetch only if the repository being diffed is the_repository
> (because we do not support lazy fetching for any other repository
>  anyway).

Then, later, this checking was spread from diff.c to diffcore-rename.c
and diffcore-break.c by 95acf11a3dc3 (diff: restrict when prefetching
occurs, 2020-04-07) and then further split in d331dd3b0c82
(diffcore-rename: allow different missing_object_cb functions,
2021-06-22).  I also copied the logic from prefetching blobs from
diff.c to merge-ort.c in 2bff554b23e8 (merge-ort: add prefetching for
content merges, 2021-06-22).

The reason for all these checks was noted above -- we only supported
lazy fetching for the_repository.  However, that changed with
ef830cc43412 (promisor-remote: teach lazy-fetch in any repo,
2021-06-17), so these checks are now unnecessary.  Remove them.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff.c
diffcore-break.c
diffcore-rename.c
merge-ort.c

diff --git a/diff.c b/diff.c
index 35b903a9a0966a7333c5316ac1c98a1fcc5a1345..9091e041b79fee572149c07799cba31d0aa17cf4 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -7176,7 +7176,7 @@ void diffcore_std(struct diff_options *options)
         * If no prefetching occurs, diffcore_rename() will prefetch if it
         * decides that it needs inexact rename detection.
         */
-       if (options->repo == the_repository && repo_has_promisor_remote(the_repository) &&
+       if (repo_has_promisor_remote(options->repo) &&
            (options->output_format & output_formats_to_prefetch ||
             options->pickaxe_opts & DIFF_PICKAXE_KINDS_MASK))
                diff_queued_diff_prefetch(options->repo);
index c4c2173f3096bcd4f5935ec16ba9c18b9732f9e6..91ae5e8dbb4950a4057d53e1411d390f553d03b1 100644 (file)
@@ -69,7 +69,7 @@ static int should_break(struct repository *r,
            oideq(&src->oid, &dst->oid))
                return 0; /* they are the same */
 
-       if (r == the_repository && repo_has_promisor_remote(the_repository)) {
+       if (repo_has_promisor_remote(r)) {
                options.missing_object_cb = diff_queued_diff_prefetch;
                options.missing_object_data = r;
        }
index d9476db35acbf7023bb4555254f367cf4564fd91..c797d8ed2f54ddd2137f61579ba052264403c166 100644 (file)
@@ -987,7 +987,7 @@ static int find_basename_matches(struct diff_options *options,
                        strintmap_set(&dests, base, i);
        }
 
-       if (options->repo == the_repository && repo_has_promisor_remote(the_repository)) {
+       if (repo_has_promisor_remote(options->repo)) {
                dpf_options.missing_object_cb = basename_prefetch;
                dpf_options.missing_object_data = &prefetch_options;
        }
@@ -1574,7 +1574,7 @@ void diffcore_rename_extended(struct diff_options *options,
 
        /* Finish setting up dpf_options */
        prefetch_options.skip_unmodified = skip_unmodified;
-       if (options->repo == the_repository && repo_has_promisor_remote(the_repository)) {
+       if (repo_has_promisor_remote(options->repo)) {
                dpf_options.missing_object_cb = inexact_prefetch;
                dpf_options.missing_object_data = &prefetch_options;
        }
index 0a59d1e596200e0625472988b9596c15615a79b5..27a58a735d69bb5299498e7322e37f91b93fe360 100644 (file)
@@ -4438,7 +4438,7 @@ static void prefetch_for_content_merges(struct merge_options *opt,
        struct string_list_item *e;
        struct oid_array to_fetch = OID_ARRAY_INIT;
 
-       if (opt->repo != the_repository || !repo_has_promisor_remote(the_repository))
+       if (!repo_has_promisor_remote(opt->repo))
                return;
 
        for (e = &plist->items[plist->nr-1]; e >= plist->items; --e) {