diff options
author | Jonathan Tan <jonathantanmy@google.com> | 2018-07-16 11:44:01 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-07-16 14:51:12 -0700 |
commit | 42cc7485a2ec49ecc440c921d2eb0cae4da80549 (patch) | |
tree | 576a4ddf4327faf750dd9017fb2cf70c21ae8bda /fetch-pack.c | |
parent | ec06283844a90c3e9440286401e9ad7d86daa5ae (diff) | |
download | git-42cc7485a2ec49ecc440c921d2eb0cae4da80549.tar.gz |
negotiator/skipping: skip commits during fetch
Introduce a new negotiation algorithm used during fetch that skips
commits in an effort to find common ancestors faster. The skips grow
similarly to the Fibonacci sequence as the commit walk proceeds further
away from the tips. The skips may cause unnecessary commits to be
included in the packfile, but the negotiation step typically ends more
quickly.
Usage of this algorithm is guarded behind the configuration flag
fetch.negotiationAlgorithm.
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'fetch-pack.c')
-rw-r--r-- | fetch-pack.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/fetch-pack.c b/fetch-pack.c index ba12085c4a..786e2ee1b2 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -33,6 +33,7 @@ static int agent_supported; static int server_supports_filtering; static struct lock_file shallow_lock; static const char *alternate_shallow_file; +static char *negotiation_algorithm; /* Remember to update object flag allocation in object.h */ #define COMPLETE (1U << 0) @@ -889,7 +890,7 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args, const char *agent_feature; int agent_len; struct fetch_negotiator negotiator; - fetch_negotiator_init(&negotiator); + fetch_negotiator_init(&negotiator, negotiation_algorithm); sort_ref_list(&ref, ref_compare_name); QSORT(sought, nr_sought, cmp_ref_by_name); @@ -1271,7 +1272,7 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args, int in_vain = 0; int haves_to_send = INITIAL_FLUSH; struct fetch_negotiator negotiator; - fetch_negotiator_init(&negotiator); + fetch_negotiator_init(&negotiator, negotiation_algorithm); packet_reader_init(&reader, fd[0], NULL, 0, PACKET_READ_CHOMP_NEWLINE); @@ -1350,6 +1351,8 @@ static void fetch_pack_config(void) git_config_get_bool("repack.usedeltabaseoffset", &prefer_ofs_delta); git_config_get_bool("fetch.fsckobjects", &fetch_fsck_objects); git_config_get_bool("transfer.fsckobjects", &transfer_fsck_objects); + git_config_get_string("fetch.negotiationalgorithm", + &negotiation_algorithm); git_config(git_default_config, NULL); } |