Re: [PATCH] diff: restrict when prefetching occurs
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 31, 2020, 18:15 UTC
- Message-ID
- <xmqqpncs75mu.fsf@gitster.c.googlers.com>
- In-Reply-To
- <20200331020418.55640-1-jonathantanmy@google.com>
Jonathan Tan <jonathantanmy@google.com> writes:
Show 19 quoted lines
> diff --git a/diffcore-rename.c b/diffcore-rename.c
> index e189f407af..962565f066 100644
> --- a/diffcore-rename.c
> +++ b/diffcore-rename.c
> ...
> @@ -448,7 +449,18 @@ static int find_renames(struct diff_score *mx, int dst_cnt, int minimum_score, i
> return count;
> }
>
> +static void add_if_missing(struct repository *r,
> + struct oid_array *to_fetch,
> + const struct diff_filespec *filespec)
> +{
> + if (filespec && filespec->oid_valid &&
> + !S_ISGITLINK(filespec->mode) &&
> + oid_object_info_extended(r, &filespec->oid, NULL,
> + OBJECT_INFO_FOR_PREFETCH))
> + oid_array_append(to_fetch, &filespec->oid);
> +}Do not copy&paste the exact code from elsewhere. It is a sure way to guarantee that they will drift apart over time. Rename the one in diff.c to something a bit more appropriate to be a global name (e.g. diff_prepare_prefetch() or somesuch), make it extern in <diffcore.h> and use it here.
Thanks.