diff options
| author | Carlos Martín Nieto <carlos@cmartin.tk> | 2012-07-24 19:03:22 +0200 |
|---|---|---|
| committer | Carlos Martín Nieto <carlos@cmartin.tk> | 2012-07-30 20:28:16 +0200 |
| commit | b49c8f71aef574ce6606282a498627f5106220d5 (patch) | |
| tree | b4a9d07716c80b48e68f36d8fb3fb6c142447ac6 /src/pkt.c | |
| parent | 114dc6e14c47ff574b4c97d4519782de3f9d28b2 (diff) | |
| download | libgit2-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.c | 20 |
1 files changed, 17 insertions, 3 deletions
@@ -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; } |
