diff options
author | Masaya Suzuki <masayasuzuki@google.com> | 2018-12-29 13:19:15 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-01-02 13:05:30 -0800 |
commit | 2d103c31c2cfcf03ff1408d639043469b0c93f70 (patch) | |
tree | 17a4e7a35fb5401fad2b8713e17360af0573682e /fetch-pack.c | |
parent | 01f9ec64c8a82a05ba7e5a17b292ede037a469ea (diff) | |
download | git-2d103c31c2cfcf03ff1408d639043469b0c93f70.tar.gz |
pack-protocol.txt: accept error packets in any context
In the Git pack protocol definition, an error packet may appear only in
a certain context. However, servers can face a runtime error (e.g. I/O
error) at an arbitrary timing. This patch changes the protocol to allow
an error packet to be sent instead of any packet.
Without this protocol spec change, when a server cannot process a
request, there's no way to tell that to a client. Since the server
cannot produce a valid response, it would be forced to cut a connection
without telling why. With this protocol spec change, the server can be
more gentle in this situation. An old client may see these error packets
as an unexpected packet, but this is not worse than having an unexpected
EOF.
Following this protocol spec change, the error packet handling code is
moved to pkt-line.c. Implementation wise, this implementation uses
pkt-line to communicate with a subprocess. Since this is not a part of
Git protocol, it's possible that a packet that is not supposed to be an
error packet is mistakenly parsed as an error packet. This error packet
handling is enabled only for the Git pack protocol parsing code
considering this.
Signed-off-by: Masaya Suzuki <masayasuzuki@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'fetch-pack.c')
-rw-r--r-- | fetch-pack.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/fetch-pack.c b/fetch-pack.c index 86790b9bba..3f9626dbf7 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -182,8 +182,6 @@ static enum ack_type get_ack(struct packet_reader *reader, return ACK; } } - if (skip_prefix(reader->line, "ERR ", &arg)) - die(_("remote error: %s"), arg); die(_("git fetch-pack: expected ACK/NAK, got '%s'"), reader->line); } @@ -258,7 +256,8 @@ static int find_common(struct fetch_negotiator *negotiator, die(_("--stateless-rpc requires multi_ack_detailed")); packet_reader_init(&reader, fd[0], NULL, 0, - PACKET_READ_CHOMP_NEWLINE); + PACKET_READ_CHOMP_NEWLINE | + PACKET_READ_DIE_ON_ERR_PACKET); if (!args->no_dependents) { mark_tips(negotiator, args->negotiation_tips); @@ -1358,7 +1357,8 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args, struct fetch_negotiator negotiator; fetch_negotiator_init(&negotiator, negotiation_algorithm); packet_reader_init(&reader, fd[0], NULL, 0, - PACKET_READ_CHOMP_NEWLINE); + PACKET_READ_CHOMP_NEWLINE | + PACKET_READ_DIE_ON_ERR_PACKET); while (state != FETCH_DONE) { switch (state) { |