Skip to content

Commit 45dbeb9

Browse files
calvin-wan-googlegitster
authored andcommitted
serve: advertise object-info feature
In order for a client to know what object-info components a server can provide, advertise supported object-info features. This allows a client to decide whether to query the server for object-info or fetch as a fallback. While at it, update the object-info section in 'gitprotocol-v2.adoc': - Require full obj-oid explicitly. - Fix parentheses. - Define obj-size explicitly. - Make obj-size optional in obj-info and document the behavior for unrecognized object IDs. Helped-by: Jonathan Tan <jonathantanmy@google.com> Helped-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Calvin Wan <calvinwan@google.com> Signed-off-by: Eric Ju <eric.peijian@gmail.com> Signed-off-by: Pablo Sabater <pabloosabaterr@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent f14d04f commit 45dbeb9

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

Documentation/gitprotocol-v2.adoc

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -568,21 +568,26 @@ An `object-info` request takes the following arguments:
568568
569569
oid <oid>
570570
Indicates to the server an object which the client wants to obtain
571-
information for.
571+
information for. They must be full object IDs.
572572
573573
The response of `object-info` is a list of the requested object ids
574574
and associated requested information, each separated by a single space.
575575
576576
output = info flush-pkt
577577
578-
info = PKT-LINE(attrs) LF)
578+
info = PKT-LINE(attrs LF)
579579
*PKT-LINE(obj-info LF)
580580
581581
attrs = attr | attrs SP attrs
582582
583+
obj-size = 1*DIGIT
584+
583585
attr = "size"
584586
585-
obj-info = obj-id SP obj-size
587+
obj-info = obj-id SP [obj-size]
588+
589+
If the server does not recognize the object id, the response will be
590+
`obj-id SP` regardless of the number of attributes requested.
586591
587592
bundle-uri
588593
~~~~~~~~~~

serve.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,17 @@ static void session_id_receive(struct repository *r UNUSED,
8989
trace2_data_string("transfer", NULL, "client-sid", client_sid);
9090
}
9191

92-
static int object_info_advertise(struct repository *r, struct strbuf *value UNUSED)
92+
static int object_info_advertise(struct repository *r, struct strbuf *value)
9393
{
9494
if (advertise_object_info == -1 &&
9595
repo_config_get_bool(r, "transfer.advertiseobjectinfo",
9696
&advertise_object_info)) {
9797
/* disabled by default */
9898
advertise_object_info = 0;
9999
}
100+
/* Currently only size is supported */
101+
if (value && advertise_object_info)
102+
strbuf_addstr(value, "size");
100103
return advertise_object_info;
101104
}
102105

0 commit comments

Comments
 (0)