summaryrefslogtreecommitdiff
path: root/builtin/archive.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2019-02-05 22:26:11 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-02-05 22:26:11 (GMT)
commit5f8b86db94e789bc07258f98cc5ba25d18273d83 (patch)
treee4f8a21992261176c7ac61a90ac437bd7e4035af /builtin/archive.c
parent33bea7358f68d165d65357c04b465209b56dc8f0 (diff)
parent07c3c2aa16370fd97551b7d1aa6af3d051e7cf8f (diff)
downloadgit-5f8b86db94e789bc07258f98cc5ba25d18273d83.zip
git-5f8b86db94e789bc07258f98cc5ba25d18273d83.tar.gz
git-5f8b86db94e789bc07258f98cc5ba25d18273d83.tar.bz2
Merge branch 'jt/fetch-v2-sideband'
"git fetch" and "git upload-pack" learned to send all exchange over the sideband channel while talking the v2 protocol. * jt/fetch-v2-sideband: tests: define GIT_TEST_SIDEBAND_ALL {fetch,upload}-pack: sideband v2 fetch response sideband: reverse its dependency on pkt-line pkt-line: introduce struct packet_writer pack-protocol.txt: accept error packets in any context Use packet_reader instead of packet_read_line
Diffstat (limited to 'builtin/archive.c')
-rw-r--r--builtin/archive.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/builtin/archive.c b/builtin/archive.c
index d245523..45d1166 100644
--- a/builtin/archive.c
+++ b/builtin/archive.c
@@ -27,10 +27,10 @@ static int run_remote_archiver(int argc, const char **argv,
const char *remote, const char *exec,
const char *name_hint)
{
- char *buf;
int fd[2], i, rv;
struct transport *transport;
struct remote *_remote;
+ struct packet_reader reader;
_remote = remote_get(remote);
if (!_remote->url[0])
@@ -53,18 +53,19 @@ static int run_remote_archiver(int argc, const char **argv,
packet_write_fmt(fd[1], "argument %s\n", argv[i]);
packet_flush(fd[1]);
- buf = packet_read_line(fd[0], NULL);
- if (!buf)
+ packet_reader_init(&reader, fd[0], NULL, 0,
+ PACKET_READ_CHOMP_NEWLINE |
+ PACKET_READ_DIE_ON_ERR_PACKET);
+
+ if (packet_reader_read(&reader) != PACKET_READ_NORMAL)
die(_("git archive: expected ACK/NAK, got a flush packet"));
- if (strcmp(buf, "ACK")) {
- if (starts_with(buf, "NACK "))
- die(_("git archive: NACK %s"), buf + 5);
- if (starts_with(buf, "ERR "))
- die(_("remote error: %s"), buf + 4);
+ if (strcmp(reader.line, "ACK")) {
+ if (starts_with(reader.line, "NACK "))
+ die(_("git archive: NACK %s"), reader.line + 5);
die(_("git archive: protocol error"));
}
- if (packet_read_line(fd[0], NULL))
+ if (packet_reader_read(&reader) != PACKET_READ_FLUSH)
die(_("git archive: expected a flush"));
/* Now, start reading from fd[0] and spit it out to stdout */