On Tue, Jul 3, 2018 at 12:41 AM Jonathan Tan <jonathanta...@google.com> wrote:
> +static void add_negotiation_tips(struct git_transport_options *smart_options)
> +{
> +       struct oid_array *oids = xcalloc(1, sizeof(*oids));
> +       int i;
> +
> +       for (i = 0; i < negotiation_tip.nr; i++) {
> +               const char *s = negotiation_tip.items[i].string;
> +               int old_nr;
> +               if (!has_glob_specials(s)) {
> +                       struct object_id oid;
> +                       if (get_oid(s, &oid))
> +                               die("%s is not a valid object", s);

Please _() this string and the warning() below

> +                       oid_array_append(oids, &oid);
> +                       continue;
> +               }
> +               old_nr = oids->nr;
> +               for_each_glob_ref(add_oid, s, oids);
> +               if (old_nr == oids->nr)
> +                       warning("Ignoring --negotiation-tip=%s because it 
> does not match any refs",
> +                               s);
> +       }
> +       smart_options->negotiation_tips = oids;
> +}
> +
>  static struct transport *prepare_transport(struct remote *remote, int deepen)
>  {
>         struct transport *transport;
> @@ -1075,6 +1112,12 @@ static struct transport *prepare_transport(struct 
> remote *remote, int deepen)
>                            filter_options.filter_spec);
>                 set_option(transport, TRANS_OPT_FROM_PROMISOR, "1");
>         }
> +       if (negotiation_tip.nr) {
> +               if (transport->smart_options)
> +                       add_negotiation_tips(transport->smart_options);
> +               else
> +                       warning("Ignoring --negotiation-tip because the 
> protocol does not support it.");
> +       }
>         return transport;
>  }
-- 
Duy

Reply via email to