mirror of
https://github.com/git/git
synced 2024-08-27 03:29:21 +00:00
receive-pack: Refactor how capabilities are shown to the client
Moving capability advertisement into the packet_write call itself makes it easier to add additional capabilities to the list, be it optional by configuration, or always present in the protocol. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
0c499ea60f
commit
185c04e041
|
@ -31,7 +31,7 @@ static int prefer_ofs_delta = 1;
|
||||||
static int auto_update_server_info;
|
static int auto_update_server_info;
|
||||||
static int auto_gc = 1;
|
static int auto_gc = 1;
|
||||||
static const char *head_name;
|
static const char *head_name;
|
||||||
static char *capabilities_to_send;
|
static int sent_capabilities;
|
||||||
|
|
||||||
static enum deny_action parse_deny_action(const char *var, const char *value)
|
static enum deny_action parse_deny_action(const char *var, const char *value)
|
||||||
{
|
{
|
||||||
|
@ -105,19 +105,21 @@ static int receive_pack_config(const char *var, const char *value, void *cb)
|
||||||
|
|
||||||
static int show_ref(const char *path, const unsigned char *sha1, int flag, void *cb_data)
|
static int show_ref(const char *path, const unsigned char *sha1, int flag, void *cb_data)
|
||||||
{
|
{
|
||||||
if (!capabilities_to_send)
|
if (sent_capabilities)
|
||||||
packet_write(1, "%s %s\n", sha1_to_hex(sha1), path);
|
packet_write(1, "%s %s\n", sha1_to_hex(sha1), path);
|
||||||
else
|
else
|
||||||
packet_write(1, "%s %s%c%s\n",
|
packet_write(1, "%s %s%c%s%s\n",
|
||||||
sha1_to_hex(sha1), path, 0, capabilities_to_send);
|
sha1_to_hex(sha1), path, 0,
|
||||||
capabilities_to_send = NULL;
|
" report-status delete-refs",
|
||||||
|
prefer_ofs_delta ? " ofs-delta" : "");
|
||||||
|
sent_capabilities = 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void write_head_info(void)
|
static void write_head_info(void)
|
||||||
{
|
{
|
||||||
for_each_ref(show_ref, NULL);
|
for_each_ref(show_ref, NULL);
|
||||||
if (capabilities_to_send)
|
if (!sent_capabilities)
|
||||||
show_ref("capabilities^{}", null_sha1, 0, NULL);
|
show_ref("capabilities^{}", null_sha1, 0, NULL);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -670,10 +672,6 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
|
||||||
else if (0 <= receive_unpack_limit)
|
else if (0 <= receive_unpack_limit)
|
||||||
unpack_limit = receive_unpack_limit;
|
unpack_limit = receive_unpack_limit;
|
||||||
|
|
||||||
capabilities_to_send = (prefer_ofs_delta) ?
|
|
||||||
" report-status delete-refs ofs-delta " :
|
|
||||||
" report-status delete-refs ";
|
|
||||||
|
|
||||||
if (advertise_refs || !stateless_rpc) {
|
if (advertise_refs || !stateless_rpc) {
|
||||||
add_alternate_refs();
|
add_alternate_refs();
|
||||||
write_head_info();
|
write_head_info();
|
||||||
|
|
Loading…
Reference in a new issue