summaryrefslogtreecommitdiff
path: root/src/pkt.c
diff options
context:
space:
mode:
authorCarlos Martín Nieto <carlos@cmartin.tk>2012-07-24 19:03:22 +0200
committerCarlos Martín Nieto <carlos@cmartin.tk>2012-07-30 20:28:16 +0200
commitb49c8f71aef574ce6606282a498627f5106220d5 (patch)
treeb4a9d07716c80b48e68f36d8fb3fb6c142447ac6 /src/pkt.c
parent114dc6e14c47ff574b4c97d4519782de3f9d28b2 (diff)
downloadlibgit2-b49c8f71aef574ce6606282a498627f5106220d5.tar.gz
remote: use the same code to control git and http
This allows us to add capabilitites to both at the same time, keeps them in sync and removes a lot of code. gitno_buffer now uses a callback to fill its buffer, allowing us to use the same interface for git and http (which uses callbacks).
Diffstat (limited to 'src/pkt.c')
-rw-r--r--src/pkt.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/pkt.c b/src/pkt.c
index e60e30d5b..8c916fff0 100644
--- a/src/pkt.c
+++ b/src/pkt.c
@@ -42,15 +42,29 @@ static int flush_pkt(git_pkt **out)
/* the rest of the line will be useful for multi_ack */
static int ack_pkt(git_pkt **out, const char *line, size_t len)
{
- git_pkt *pkt;
+ git_pkt_ack *pkt;
GIT_UNUSED(line);
GIT_UNUSED(len);
- pkt = git__malloc(sizeof(git_pkt));
+ pkt = git__calloc(1, sizeof(git_pkt_ack));
GITERR_CHECK_ALLOC(pkt);
pkt->type = GIT_PKT_ACK;
- *out = pkt;
+ line += 3;
+ len -= 3;
+
+ if (len >= GIT_OID_HEXSZ) {
+ git_oid_fromstr(&pkt->oid, line + 1);
+ line += GIT_OID_HEXSZ + 1;
+ len -= GIT_OID_HEXSZ + 1;
+ }
+
+ if (len >= 7) {
+ if (!git__prefixcmp(line + 1, "continue"))
+ pkt->status = GIT_ACK_CONTINUE;
+ }
+
+ *out = (git_pkt *) pkt;
return 0;
}