[PATCH GSoC v5 05/10] fetch-object-info: die() on the remaining error path
From: Pablo Sabater <hidden>
Date: 2026-08-07 22:07:22
Subsystem:
the rest · Maintainer:
Linus Torvalds
Every failure in fetch_object_info() dies except one: a short read while parsing the attribute lines returns -1. That -1 is then passed through fetch_object_info_via_pack() and get_remote_info() up to cat-file, only to die() with a generic message. Die in fetch_object_info() instead, consistently with the rest of its error paths, and make fetch_object_info() void. Mentored-by: Karthik Nayak [off-list ref] Mentored-by: Chandra Pratap [off-list ref] Signed-off-by: Pablo Sabater <redacted> --- fetch-object-info.c | 19 +++++++++---------- fetch-object-info.h | 14 +++++++------- transport.c | 12 ++++++------ 3 files changed, 22 insertions(+), 23 deletions(-)
diff --git a/fetch-object-info.c b/fetch-object-info.c
index 46a1289ff3..7a337a6857 100644
--- a/fetch-object-info.c
+++ b/fetch-object-info.c@@ -47,13 +47,13 @@ static int parse_object_size(const char *s, size_t *res) return 0; } -int fetch_object_info(const enum protocol_version version, - const struct string_list *server_options, - struct oid_array *oids, - struct packet_reader *reader, - struct fetch_object_info_results *results, - const int stateless_rpc, - const int fd_out) +void fetch_object_info(const enum protocol_version version, + const struct string_list *server_options, + struct oid_array *oids, + struct packet_reader *reader, + struct fetch_object_info_results *results, + const int stateless_rpc, + const int fd_out) { unsigned ask_size = 0; int size_index = -1;
@@ -89,7 +89,8 @@ int fetch_object_info(const enum protocol_version version, if (packet_reader_read(reader) != PACKET_READ_NORMAL) { check_stateless_delimiter(stateless_rpc, reader, "stateless delimiter expected"); - return -1; + die(_("object-info: expected %" PRIuMAX " attributes, got %" PRIuMAX), + (uintmax_t)wanted, (uintmax_t)i); } if (!strcmp(reader->line, "size")) {
@@ -156,8 +157,6 @@ int fetch_object_info(const enum protocol_version version, (uintmax_t)oids->nr); check_stateless_delimiter(stateless_rpc, reader, "stateless delimiter expected"); - - return 0; } void free_fetch_object_info_results(struct fetch_object_info_results *results)
diff --git a/fetch-object-info.h b/fetch-object-info.h
index 9f72e91155..97ee5314c9 100644
--- a/fetch-object-info.h
+++ b/fetch-object-info.h@@ -24,13 +24,13 @@ struct oid_array; * attribute is not available. * Release them with free_fetch_object_info_results(). */ -int fetch_object_info(enum protocol_version version, - const struct string_list *server_options, - struct oid_array *oids, - struct packet_reader *reader, - struct fetch_object_info_results *results, - int stateless_rpc, - int fd_out); +void fetch_object_info(enum protocol_version version, + const struct string_list *server_options, + struct oid_array *oids, + struct packet_reader *reader, + struct fetch_object_info_results *results, + int stateless_rpc, + int fd_out); void free_fetch_object_info_results(struct fetch_object_info_results *results);
diff --git a/transport.c b/transport.c
index b0e29124d1..35acdf71a2 100644
--- a/transport.c
+++ b/transport.c@@ -448,12 +448,12 @@ static int fetch_object_info_via_pack(struct transport *transport) data->version = discover_version(&reader); transport->hash_algo = reader.hash_algo; - ret = fetch_object_info(data->version, - transport->server_options, - transport->smart_options->object_info_oids, - &reader, - data->options.object_info_results, - transport->stateless_rpc, data->fd[1]); + fetch_object_info(data->version, + transport->server_options, + transport->smart_options->object_info_oids, + &reader, + data->options.object_info_results, + transport->stateless_rpc, data->fd[1]); close(data->fd[0]); if (data->fd[1] >= 0)
--
2.54.0