summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2022-05-25 23:42:48 (GMT)
committerJunio C Hamano <gitster@pobox.com>2022-05-25 23:42:48 (GMT)
commit9cf4e0c8d259ec822b0e017a1739e75494f5623d (patch)
tree8f98bb333cdc9c3c5715d59e71279b55c1b45dd0
parent18254f14f26845c8a2bc7ca7d934855068eb3257 (diff)
parent7709acf7beca41be2e382eb0e6c13b5003a20c1a (diff)
downloadgit-9cf4e0c8d259ec822b0e017a1739e75494f5623d.zip
git-9cf4e0c8d259ec822b0e017a1739e75494f5623d.tar.gz
git-9cf4e0c8d259ec822b0e017a1739e75494f5623d.tar.bz2
Merge branch 'jt/fetch-peek-optional-section'
"git fetch" unnecessarily failed when an unexpected optional section appeared in the output, which has been corrected. * jt/fetch-peek-optional-section: fetch-pack: make unexpected peek result non-fatal
-rw-r--r--fetch-pack.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/fetch-pack.c b/fetch-pack.c
index 4e1e88e..6d0d271 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -1370,17 +1370,20 @@ static int send_fetch_request(struct fetch_negotiator *negotiator, int fd_out,
static int process_section_header(struct packet_reader *reader,
const char *section, int peek)
{
- int ret;
-
- if (packet_reader_peek(reader) != PACKET_READ_NORMAL)
- die(_("error reading section header '%s'"), section);
+ int ret = 0;
- ret = !strcmp(reader->line, section);
+ if (packet_reader_peek(reader) == PACKET_READ_NORMAL &&
+ !strcmp(reader->line, section))
+ ret = 1;
if (!peek) {
- if (!ret)
- die(_("expected '%s', received '%s'"),
- section, reader->line);
+ if (!ret) {
+ if (reader->line)
+ die(_("expected '%s', received '%s'"),
+ section, reader->line);
+ else
+ die(_("expected '%s'"), section);
+ }
packet_reader_read(reader);
}