[PATCH GSoC v19 00/13] cat-file: add remote-object-info to batch-command
- From
Pablo Sabater <pabloosabaterr@gmail.com>
- Date
- Jul 17, 2026, 15:05 UTC
- Message-ID
- <20260717-ps-eric-work-rebase-v19-0-d4faee35764b@gmail.com>
- In-Reply-To
- <20260715-ps-eric-work-rebase-v18-0-34d7adb051bb@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 implements 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 placeholders with an allow-list that filters what the client asks with what the server is capable of providing, following Jeff King's idea [4].
Github CI: https://github.com/pabloosabaterr/git/actions/runs/29586719871
[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/
Changes in v19: - Changed the commit structure: - squashed v18 10th and 11th commits into: cat-file: add remote-object-info to batch-command - Moved after the refactor and renamed: connect: use unsigned int for hash_algo_by_name() calls. - Added a new commit: protocol-caps: ...
- protocol-caps: check object existence regardless of the attributes requested; a bare OID request now gets an existence check
Don't lazy-fetch on the server to answer object-info requests (OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK)
- gitprotocol-v2: correct the object-info response grammar to match the implementations
- fetch-object-info: validate that each response line echoes the requested object ID at that position
- cat-file: the remote-object-info default format no longer leaks into subsequent info commands in the same session
- commit message and documentation fixes
---
Calvin Wan (3):
fetch-pack: move fetch initialization
serve: advertise object-info feature
transport: add client support for object-infoEric Ju (3):
cat-file: declare loop counter inside for()
t1006: extract helper functions into new 'lib-cat-file.sh'
cat-file: add remote-object-info to batch-commandPablo Sabater (7):
transport-helper: fix memory leak of helper on disconnect
fetch-pack: drop the static advertise_sid variable
fetch-pack: move write_fetch_command_and_capabilities() to connect.c
connect: use unsigned int for hash_algo_by_name() calls
connect: make write_fetch_command_and_capabilities() more generic
protocol-caps: check object existence regardless of the attributes requested
cat-file: make remote-object-info allow-list adapt to the serverDocumentation/git-cat-file.adoc | 28 +- Documentation/gitprotocol-v2.adoc | 21 +- Makefile | 1 + builtin/cat-file.c | 214 +++++++++- connect.c | 38 +- connect.h | 8 + fetch-object-info.c | 156 +++++++ fetch-object-info.h | 25 ++ fetch-pack.c | 58 +-- meson.build | 1 + object-file.c | 10 + odb.h | 9 + protocol-caps.c | 45 +- serve.c | 5 +- t/lib-cat-file.sh | 16 + t/meson.build | 1 + t/t1006-cat-file.sh | 15 +- t/t1017-cat-file-remote-object-info.sh | 747 +++++++++++++++++++++++++++++++++ t/t5701-git-serve.sh | 63 +++ transport-helper.c | 12 +- transport-internal.h | 8 + transport.c | 44 ++ transport.h | 9 + 23 files changed, 1437 insertions(+), 97 deletions(-)
--- base-commit: 44de1520f08d1dfebc3ab2d9f644208eaa5ac925