]> git.ipfire.org Git - thirdparty/git.git/commitdiff
serve: advertise object-info feature
authorCalvin Wan <calvinwan@google.com>
Fri, 24 Jul 2026 10:54:21 +0000 (12:54 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 24 Jul 2026 15:46:59 +0000 (08:46 -0700)
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.

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>
serve.c

diff --git a/serve.c b/serve.c
index 49a6e39b1dd25cc4341f5fef2ef5c7d623a73801..2b07d922b3dde127f49e66496a5e80654bb80f91 100644 (file)
--- a/serve.c
+++ b/serve.c
@@ -89,7 +89,7 @@ static void session_id_receive(struct repository *r UNUSED,
        trace2_data_string("transfer", NULL, "client-sid", client_sid);
 }
 
-static int object_info_advertise(struct repository *r, struct strbuf *value UNUSED)
+static int object_info_advertise(struct repository *r, struct strbuf *value)
 {
        if (advertise_object_info == -1 &&
            repo_config_get_bool(r, "transfer.advertiseobjectinfo",
@@ -97,6 +97,9 @@ static int object_info_advertise(struct repository *r, struct strbuf *value UNUS
                /* disabled by default */
                advertise_object_info = 0;
        }
+       /* Currently only size is supported */
+       if (value && advertise_object_info)
+               strbuf_addstr(value, "size");
        return advertise_object_info;
 }