Merge branch 'jt/fetch-nego-tip' into ab/fetch-nego
authorJunio C Hamano <gitster@pobox.com>
Wed, 1 Aug 2018 18:07:35 +0000 (11:07 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 1 Aug 2018 18:07:35 +0000 (11:07 -0700)
* jt/fetch-nego-tip:
fetch-pack: support negotiation tip whitelist

1  2 
fetch-pack.c
diff --combined fetch-pack.c
index 786e2ee1b20b992933c6ea1dd2aef276b3da7851,1e50d900826e3e31e5bd5a60f922ab5f07889e61..50773fdde35a75181432f7f85ddf433dd0fb8c67
@@@ -33,7 -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)
@@@ -214,6 -213,22 +214,22 @@@ static int next_flush(int stateless_rpc
        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,
        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;
@@@ -890,7 -905,7 +906,7 @@@ static struct ref *do_fetch_pack(struc
        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);
@@@ -1272,7 -1287,7 +1288,7 @@@ static struct ref *do_fetch_pack_v2(str
        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);
  
                        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;
@@@ -1351,8 -1366,6 +1367,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);
  }