[PATCH GSoC v14 00/13] cat-file: add remote-object-info to batch-command
- From
Pablo Sabater <pabloosabaterr@gmail.com>
- Date
- Jun 25, 2026, 12:13 UTC
- Message-ID
- <20260625-ps-eric-work-rebase-v14-0-09f7ffe21a53@gmail.com>
- In-Reply-To
- <20260619-ps-eric-work-rebase-v13-0-3d4c7315d2f8@gmail.com>
This patch series is a continuation of Eric Ju's (eric.peijian@gmail.com) and Calvin Wan's (calvinwan@google.com) patch series [1] and [2] respectively.
Sometimes it is beneficial to retrieve information about an object without having to download it completely. The server logic for retrieving size has already been implemented and merged in "a2ba162cda (object-info: support for retrieving object info, 2021-04-20)"[3]. This patch series implement the client option for it.
Eric's series adds the `remote-object-info` command to `cat-file --batch-command`. This command allows the client to make an object-info command request to a server that supports protocol v2.
If the server uses protocol v2 but does not support the object-info capability, `cat-file --batch-command` will die.
If a user attempts to use `remote-object-info` with protocol v1, `cat-file --batch-command` will die.
Currently, only the size (%(objectsize)) is supported end to end in this implementation. The type (%(objecttype)) is known by the client's allow-list and request path but is not supported on the server side nor the response parsing. A follow up series will add full end-to-end support for %(objecttype).
The default format for remote-object-info is set to %(objectname) %(objectsize). Once %(objecttype) is supported, the default format will be unified accordingly.
If the batch command format includes unsupported fields such as %(objecttype), %(objectsize:disk), or %(deltabase), the command will return empty strings for each unsupported field.
This series completes Eric's work mainly with the refactor of the validation of the placeholder with an allow-list that filters what the client asks with what the server is capable of provide following Jeff King's idea [4].
GitHub CI: https://github.com/pabloosabaterr/git/actions/runs/28159024232
[1]: https://lore.kernel.org/git/20250221190451.12536-1-eric.peijian@gmail.com/ [2]: https://lore.kernel.org/git/20220728230210.2952731-1-calvinwan@google.com/#t [3]: https://git.kernel.org/pub/scm/git/git.git/commit/?id=a2ba162cda2acc171c3e36acbbc854792b093cb7 [4]: https://lore.kernel.org/git/20250313060250.GH94015@coredump.intra.peff.net/ [5]: https://lore.kernel.org/git/CAN2LT1D3d=yMYVhBjpj5PvyjfTVjwqcFPNViuCJ=f49YbCZuJg@mail.gmail.com/
Changes since v13: - Changed the introduced strtoul_ul to strtoul_szt as a recent patch changed the type of object_info.sizep to size_t. <37d030d8675e94caee2eecb8398691d385d444bd.1781524349.git.gitgitgadget@gmail.com> - Fixed commit typos and style. - "fetch-pack: move function to connect.c" is now 2 different commits: first a cleanup and a second to only move the function. - Fixed old code brought from the rebase to match upstream: use SHA1_LEGACY instead of SHA1 - Remove static declarations from cmd_remote_remote_info() and get_remote_info(). - Add a comment justifying why there will be no overflow on explicit cast.
Signed-off-by: Pablo Sabater <pabloosabaterr@gmail.com>
---
Calvin Wan (3):
fetch-pack: move fetch initialization
serve: advertise object-info feature
transport: add client support for object-infoEric Ju (4):
git-compat-util: add strtoul_szt() with error handling
cat-file: declare loop counter inside for()
t1006: split test utility functions into new "lib-cat-file.sh"
cat-file: add remote-object-info to batch-commandPablo Sabater (6):
transport-helper: fix memory leak of helper on disconnect
fetch-pack: prepare function to be moved
fetch-pack: move function to connect.c
connect: refactor packet writing
cat-file: validate remote atoms with allow_list
cat-file: make remote-object-info allow-list dynamicDocumentation/git-cat-file.adoc | 25 +- Makefile | 1 + builtin/cat-file.c | 222 ++++++++++- connect.c | 34 ++ connect.h | 8 + fetch-object-info.c | 110 ++++++ fetch-object-info.h | 22 ++ fetch-pack.c | 51 +-- fetch-pack.h | 2 + git-compat-util.h | 20 + meson.build | 1 + object-file.c | 10 + odb.h | 3 + serve.c | 5 +- t/lib-cat-file.sh | 16 + t/meson.build | 1 + t/t1006-cat-file.sh | 13 +- t/t1017-cat-file-remote-object-info.sh | 699 +++++++++++++++++++++++++++++++++ transport-helper.c | 13 +- transport.c | 28 +- transport.h | 11 + 21 files changed, 1220 insertions(+), 75 deletions(-) --- base-commit: ab776a62a78576513ee121424adb19597fbb7613 change-id: 20260608-ps-eric-work-rebase-b73ae84ba671
Best regards, -- Pablo Sabater <pabloosabaterr@gmail.com>