Merge branch 'jt/tag-following-with-proto-v2-fix'
authorJunio C Hamano <gitster@pobox.com>
Wed, 15 Aug 2018 22:08:25 +0000 (15:08 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 15 Aug 2018 22:08:25 +0000 (15:08 -0700)
The wire-protocol v2 relies on the client to send "ref prefixes" to
limit the bandwidth spent on the initial ref advertisement. "git
fetch $remote branch:branch" that asks tags that point into the
history leading to the "branch" automatically followed sent to
narrow prefix and broke the tag following, which has been fixed.

* jt/tag-following-with-proto-v2-fix:
fetch: send "refs/tags/" prefix upon CLI refspecs
t5702: test fetch with multiple refspecs at a time

1  2 
builtin/fetch.c
t/t5702-protocol-v2.sh
diff --cc builtin/fetch.c
index 34d2bd123b3303a096edb99ab4f82c52a89b35f5,1f447f1e8cbe0927edab032c6e0d7286a9ef02ce..e03a1db1a392d20bf45eac693ba3dd01f75da044
@@@ -1186,24 -1132,22 +1186,24 @@@ static int do_fetch(struct transport *t
                        goto cleanup;
        }
  
 -      ref_map = get_ref_map(transport, rs, tags, &autotags);
 -      if (!update_head_ok)
 -              check_not_current_branch(ref_map);
 +      if (rs->nr)
 +              refspec_ref_prefixes(rs, &ref_prefixes);
 +      else if (transport->remote && transport->remote->fetch.nr)
 +              refspec_ref_prefixes(&transport->remote->fetch, &ref_prefixes);
  
 -      for (rm = ref_map; rm; rm = rm->next) {
 -              if (rm->peer_ref) {
 -                      struct string_list_item *peer_item =
 -                              string_list_lookup(&existing_refs,
 -                                                 rm->peer_ref->name);
 -                      if (peer_item) {
 -                              struct object_id *old_oid = peer_item->util;
 -                              oidcpy(&rm->peer_ref->old_oid, old_oid);
 -                      }
 -              }
 +      if (ref_prefixes.argc &&
-           (tags == TAGS_SET || (tags == TAGS_DEFAULT && !rs->nr))) {
++          (tags == TAGS_SET || (tags == TAGS_DEFAULT))) {
 +              argv_array_push(&ref_prefixes, "refs/tags/");
        }
  
 +      remote_refs = transport_get_remote_refs(transport, &ref_prefixes);
 +      argv_array_clear(&ref_prefixes);
 +
 +      ref_map = get_ref_map(transport->remote, remote_refs, rs,
 +                            tags, &autotags);
 +      if (!update_head_ok)
 +              check_not_current_branch(ref_map);
 +
        if (tags == TAGS_DEFAULT && autotags)
                transport_set_option(transport, TRANS_OPT_FOLLOWTAGS, "1");
        if (prune) {
Simple merge