diff options
author | Junio C Hamano <gitster@pobox.com> | 2018-08-03 00:30:43 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-08-03 00:30:43 +0200 |
commit | 30bf8d9f4f06d8e35793612c8611cb03c53a73db (patch) | |
tree | 194baa306b8fb60956fe05d8a6daa42c6cc0bfb4 /fetch-pack.c | |
parent | Merge branch 'en/t6042-insane-merge-rename-testcases' (diff) | |
parent | fetch-pack: support negotiation tip whitelist (diff) | |
download | git-30bf8d9f4f06d8e35793612c8611cb03c53a73db.tar.xz git-30bf8d9f4f06d8e35793612c8611cb03c53a73db.zip |
Merge branch 'jt/fetch-nego-tip'
"git fetch" learned a new option "--negotiation-tip" to limit the
set of commits it tells the other end as "have", to reduce wasted
bandwidth and cycles, which would be helpful when the receiving
repository has a lot of refs that have little to do with the
history at the remote it is fetching from.
* jt/fetch-nego-tip:
fetch-pack: support negotiation tip whitelist
Diffstat (limited to 'fetch-pack.c')
-rw-r--r-- | fetch-pack.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/fetch-pack.c b/fetch-pack.c index 5056e22e6d..0a9d184adb 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -217,6 +217,22 @@ static int next_flush(int stateless_rpc, int count) return count; } +static void mark_tips(struct fetch_negotiator *negotiator, + const struct oid_array *negotiation_tips) +{ + int i; + + if (!negotiation_tips) { + for_each_ref(rev_list_insert_ref_oid, negotiator); + return; + } + + for (i = 0; i < negotiation_tips->nr; i++) + rev_list_insert_ref(negotiator, NULL, + &negotiation_tips->oid[i]); + return; +} + static int find_common(struct fetch_negotiator *negotiator, struct fetch_pack_args *args, int fd[2], struct object_id *result_oid, @@ -234,7 +250,7 @@ static int find_common(struct fetch_negotiator *negotiator, if (args->stateless_rpc && multi_ack == 1) die(_("--stateless-rpc requires multi_ack_detailed")); - for_each_ref(rev_list_insert_ref_oid, negotiator); + mark_tips(negotiator, args->negotiation_tips); for_each_cached_alternate(negotiator, insert_one_alternate_object); fetching = 0; @@ -1332,7 +1348,7 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args, else state = FETCH_SEND_REQUEST; - for_each_ref(rev_list_insert_ref_oid, &negotiator); + mark_tips(&negotiator, args->negotiation_tips); for_each_cached_alternate(&negotiator, insert_one_alternate_object); break; |