]> git.ipfire.org Git - thirdparty/git.git/commit - diff.c
diff: restrict when prefetching occurs
authorJonathan Tan <jonathantanmy@google.com>
Tue, 7 Apr 2020 22:11:43 +0000 (15:11 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 7 Apr 2020 23:09:29 +0000 (16:09 -0700)
commit95acf11a3dc3d18ec999f4913ec6c6a54545c6b7
tree3448ee7b27c3a42dfc07931e7eee15441b1b57c8
parentc14b6f83ec7453d2a93bba04f45caf26905f2bff
diff: restrict when prefetching occurs

Commit 7fbbcb21b1 ("diff: batch fetching of missing blobs", 2019-04-08)
optimized "diff" by prefetching blobs in a partial clone, but there are
some cases wherein blobs do not need to be prefetched. In these cases,
any command that uses the diff machinery will unnecessarily fetch blobs.

diffcore_std() may read blobs when it calls the following functions:
 (1) diffcore_skip_stat_unmatch() (controlled by the config variable
     diff.autorefreshindex)
 (2) diffcore_break() and diffcore_merge_broken() (for break-rewrite
     detection)
 (3) diffcore_rename() (for rename detection)
 (4) diffcore_pickaxe() (for detecting addition/deletion of specified
     string)

Instead of always prefetching blobs, teach diffcore_skip_stat_unmatch(),
diffcore_break(), and diffcore_rename() to prefetch blobs upon the first
read of a missing object. This covers (1), (2), and (3): to cover the
rest, teach diffcore_std() to prefetch if the output type is one that
includes blob data (and hence blob data will be required later anyway),
or if it knows that (4) will be run.

Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff.c
diffcore-break.c
diffcore-rename.c
diffcore.h
t/t4067-diff-partial-clone.sh