mirror of
https://git.proxmox.com/git/libgit2
synced 2025-12-08 11:25:11 +00:00
pkt: add the comment type
This is needed for smart HTTP Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
This commit is contained in:
parent
c7c3051328
commit
b76f752279
19
src/pkt.c
19
src/pkt.c
@ -98,6 +98,23 @@ static int pack_pkt(git_pkt **out)
|
|||||||
return GIT_SUCCESS;
|
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.
|
* 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);
|
error = ack_pkt(head, line, len);
|
||||||
else if (!git__prefixcmp(line, "NAK"))
|
else if (!git__prefixcmp(line, "NAK"))
|
||||||
error = nak_pkt(head);
|
error = nak_pkt(head);
|
||||||
|
else if (*line == '#')
|
||||||
|
error = comment_pkt(head, line, len);
|
||||||
else
|
else
|
||||||
error = ref_pkt(head, line, len);
|
error = ref_pkt(head, line, len);
|
||||||
|
|
||||||
|
|||||||
@ -38,6 +38,7 @@ enum git_pkt_type {
|
|||||||
GIT_PKT_ACK,
|
GIT_PKT_ACK,
|
||||||
GIT_PKT_NAK,
|
GIT_PKT_NAK,
|
||||||
GIT_PKT_PACK,
|
GIT_PKT_PACK,
|
||||||
|
GIT_PKT_COMMENT,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Used for multi-ack */
|
/* Used for multi-ack */
|
||||||
@ -74,6 +75,11 @@ typedef struct {
|
|||||||
enum git_ack_status status;
|
enum git_ack_status status;
|
||||||
} git_pkt_ack;
|
} git_pkt_ack;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
enum git_pkt_type type;
|
||||||
|
char comment[GIT_FLEX_ARRAY];
|
||||||
|
} git_pkt_comment;
|
||||||
|
|
||||||
int git_pkt_parse_line(git_pkt **head, const char *line, const char **out, size_t len);
|
int git_pkt_parse_line(git_pkt **head, const char *line, const char **out, size_t len);
|
||||||
int git_pkt_send_flush(int s);
|
int git_pkt_send_flush(int s);
|
||||||
int git_pkt_send_done(int s);
|
int git_pkt_send_done(int s);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user