summaryrefslogtreecommitdiff
path: root/src/pkt.c
diff options
context:
space:
mode:
authorCarlos Martín Nieto <carlos@cmartin.tk>2011-09-04 21:28:11 +0200
committerCarlos Martín Nieto <carlos@cmartin.tk>2011-09-09 13:12:11 +0200
commitb76f7522790992f0c54a1d68c761cb1fdba24412 (patch)
treeb7869598795ee35901a8ba1b3a88057683f66f7b /src/pkt.c
parentc7c3051328f605255c485cc49f58d16c7556d8f2 (diff)
downloadlibgit2-b76f7522790992f0c54a1d68c761cb1fdba24412.tar.gz
pkt: add the comment type
This is needed for smart HTTP Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
Diffstat (limited to 'src/pkt.c')
-rw-r--r--src/pkt.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/pkt.c b/src/pkt.c
index f97246a09..48daeaf4b 100644
--- a/src/pkt.c
+++ b/src/pkt.c
@@ -98,6 +98,23 @@ static int pack_pkt(git_pkt **out)
return GIT_SUCCESS;
}
+static int comment_pkt(git_pkt **out, const char *line, size_t len)
+{
+ git_pkt_comment *pkt;
+
+ pkt = git__malloc(sizeof(git_pkt_comment) + len + 1);
+ if (pkt == NULL)
+ return GIT_ENOMEM;
+
+ pkt->type = GIT_PKT_COMMENT;
+ memcpy(pkt->comment, line, len);
+ pkt->comment[len] = '\0';
+
+ *out = (git_pkt *) pkt;
+
+ return GIT_SUCCESS;
+}
+
/*
* Parse an other-ref line.
*/
@@ -242,6 +259,8 @@ int git_pkt_parse_line(git_pkt **head, const char *line, const char **out, size_
error = ack_pkt(head, line, len);
else if (!git__prefixcmp(line, "NAK"))
error = nak_pkt(head);
+ else if (*line == '#')
+ error = comment_pkt(head, line, len);
else
error = ref_pkt(head, line, len);