mirror of
https://github.com/git/git.git
synced 2026-08-08 17:11:48 +00:00
fetch-object-info: die() on the remaining error path
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 <karthik.188@gmail.com> Mentored-by: Chandra Pratap <chandrapratap3519@gmail.com> Signed-off-by: Pablo Sabater <pabloosabaterr@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
1d3d7f19ac
commit
1157343e48
@@ -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(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)
|
||||
{
|
||||
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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
12
transport.c
12
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)
|
||||
|
||||
Reference in New Issue
Block a user