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>
This commit is contained in:

committed by
Junio C Hamano

parent
c14b6f83ec
commit
95acf11a3d
21
diffcore.h
21
diffcore.h
@ -65,9 +65,22 @@ void free_filespec(struct diff_filespec *);
|
||||
void fill_filespec(struct diff_filespec *, const struct object_id *,
|
||||
int, unsigned short);
|
||||
|
||||
/*
|
||||
* Prefetch the entries in diff_queued_diff. The parameter is a pointer to a
|
||||
* struct repository.
|
||||
*/
|
||||
void diff_queued_diff_prefetch(void *repository);
|
||||
|
||||
struct diff_populate_filespec_options {
|
||||
unsigned check_size_only : 1;
|
||||
unsigned check_binary : 1;
|
||||
|
||||
/*
|
||||
* If an object is missing, diff_populate_filespec() will invoke this
|
||||
* callback before attempting to read that object again.
|
||||
*/
|
||||
void (*missing_object_cb)(void *);
|
||||
void *missing_object_data;
|
||||
};
|
||||
int diff_populate_filespec(struct repository *, struct diff_filespec *,
|
||||
const struct diff_populate_filespec_options *);
|
||||
@ -185,4 +198,12 @@ int diffcore_count_changes(struct repository *r,
|
||||
unsigned long *src_copied,
|
||||
unsigned long *literal_added);
|
||||
|
||||
/*
|
||||
* If filespec contains an OID and if that object is missing from the given
|
||||
* repository, add that OID to to_fetch.
|
||||
*/
|
||||
void diff_add_if_missing(struct repository *r,
|
||||
struct oid_array *to_fetch,
|
||||
const struct diff_filespec *filespec);
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user