summaryrefslogtreecommitdiff
path: root/src/pkt.c
diff options
context:
space:
mode:
authorVicent Martí <tanoku@gmail.com>2012-04-30 14:38:15 -0700
committerVicent Martí <tanoku@gmail.com>2012-04-30 14:38:15 -0700
commitced9da5412f38eea6d032586d45eba6ebfd34554 (patch)
treeb7f144f2f0e441909f1deae92136f6ee2d7d85ce /src/pkt.c
parent0dc8e95e1940017a9d6e8f5b13cf9a9ad644fc08 (diff)
parent39e6af6a7c526823b06f2c7bfe97c0c7bf9501d5 (diff)
downloadlibgit2-ced9da5412f38eea6d032586d45eba6ebfd34554.tar.gz
Merge pull request #654 from carlosmn/pkt-err
Recognize and report server-side error messages
Diffstat (limited to 'src/pkt.c')
-rw-r--r--src/pkt.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/pkt.c b/src/pkt.c
index 6cf4dac8e..00836bc34 100644
--- a/src/pkt.c
+++ b/src/pkt.c
@@ -97,6 +97,25 @@ static int comment_pkt(git_pkt **out, const char *line, size_t len)
return 0;
}
+static int err_pkt(git_pkt **out, const char *line, size_t len)
+{
+ git_pkt_err *pkt;
+
+ /* Remove "ERR " from the line */
+ line += 4;
+ len -= 4;
+ pkt = git__malloc(sizeof(git_pkt_err) + len + 1);
+ GITERR_CHECK_ALLOC(pkt);
+
+ pkt->type = GIT_PKT_ERR;
+ memcpy(pkt->error, line, len);
+ pkt->error[len] = '\0';
+
+ *out = (git_pkt *) pkt;
+
+ return 0;
+}
+
/*
* Parse an other-ref line.
*/
@@ -234,6 +253,8 @@ int git_pkt_parse_line(
ret = ack_pkt(head, line, len);
else if (!git__prefixcmp(line, "NAK"))
ret = nak_pkt(head);
+ else if (!git__prefixcmp(line, "ERR "))
+ ret = err_pkt(head, line, len);
else if (*line == '#')
ret = comment_pkt(head, line, len);
else