summaryrefslogtreecommitdiff
path: root/src/pkt.c
diff options
context:
space:
mode:
authorCarlos Martín Nieto <carlos@cmartin.tk>2012-07-24 17:10:57 +0200
committerCarlos Martín Nieto <carlos@cmartin.tk>2012-07-30 20:28:16 +0200
commit114dc6e14c47ff574b4c97d4519782de3f9d28b2 (patch)
tree85283b30f80129d66017361acf06120bc6379413 /src/pkt.c
parent64d01de8a7802ebec031f921496747bf09426df1 (diff)
downloadlibgit2-114dc6e14c47ff574b4c97d4519782de3f9d28b2.tar.gz
network: implement multi_ack for the git transport
Diffstat (limited to 'src/pkt.c')
-rw-r--r--src/pkt.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/pkt.c b/src/pkt.c
index e003b97e2..e60e30d5b 100644
--- a/src/pkt.c
+++ b/src/pkt.c
@@ -283,20 +283,28 @@ int git_pkt_buffer_flush(git_buf *buf)
static int buffer_want_with_caps(git_remote_head *head, git_transport_caps *caps, git_buf *buf)
{
- char capstr[20];
+ git_buf str = GIT_BUF_INIT;
char oid[GIT_OID_HEXSZ +1] = {0};
unsigned int len;
if (caps->ofs_delta)
- strncpy(capstr, GIT_CAP_OFS_DELTA, sizeof(capstr));
+ git_buf_puts(&str, GIT_CAP_OFS_DELTA " ");
+
+ if (caps->multi_ack)
+ git_buf_puts(&str, GIT_CAP_MULTI_ACK " ");
+
+ if (git_buf_oom(&str))
+ return -1;
len = (unsigned int)
(strlen("XXXXwant ") + GIT_OID_HEXSZ + 1 /* NUL */ +
- strlen(capstr) + 1 /* LF */);
+ git_buf_len(&str) + 1 /* LF */);
git_buf_grow(buf, git_buf_len(buf) + len);
-
git_oid_fmt(oid, &head->oid);
- return git_buf_printf(buf, "%04xwant %s %s\n", len, oid, capstr);
+ git_buf_printf(buf, "%04xwant %s %s\n", len, oid, git_buf_cstr(&str));
+ git_buf_free(&str);
+
+ return git_buf_oom(buf);
}
/*