ls-remote: send server options when using protocol v2
Teach ls-remote to optionally accept server options by specifying them on the cmdline via '-o' or '--server-option'. These server options are sent to the remote end when querying for the remote end's refs using protocol version 2. If communicating using a protocol other than v2 the provided options are ignored and not sent to the remote end. Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
ecc3e5342d
commit
ff473221b4
@ -408,7 +408,8 @@ out:
|
||||
|
||||
struct ref **get_remote_refs(int fd_out, struct packet_reader *reader,
|
||||
struct ref **list, int for_push,
|
||||
const struct argv_array *ref_prefixes)
|
||||
const struct argv_array *ref_prefixes,
|
||||
const struct string_list *server_options)
|
||||
{
|
||||
int i;
|
||||
*list = NULL;
|
||||
@ -419,6 +420,12 @@ struct ref **get_remote_refs(int fd_out, struct packet_reader *reader,
|
||||
if (server_supports_v2("agent", 0))
|
||||
packet_write_fmt(fd_out, "agent=%s", git_user_agent_sanitized());
|
||||
|
||||
if (server_options && server_options->nr &&
|
||||
server_supports_v2("server-option", 1))
|
||||
for (i = 0; i < server_options->nr; i++)
|
||||
packet_write_fmt(fd_out, "server-option=%s",
|
||||
server_options->items[i].string);
|
||||
|
||||
packet_delim(fd_out);
|
||||
/* When pushing we don't want to request the peeled tags */
|
||||
if (!for_push)
|
||||
|
Reference in New Issue
Block a user