mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-10 18:28:16 +00:00
Move flush-pkt creation into its own function
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
This commit is contained in:
parent
f7fc68df83
commit
1d27446c60
29
src/pkt.c
29
src/pkt.c
@ -30,6 +30,20 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
static int flush_pkt(git_pkt **out)
|
||||||
|
{
|
||||||
|
git_pkt *pkt;
|
||||||
|
|
||||||
|
pkt = git__malloc(sizeof(git_pkt));
|
||||||
|
if (pkt == NULL)
|
||||||
|
return GIT_ENOMEM;
|
||||||
|
|
||||||
|
pkt->type = GIT_PKT_FLUSH;
|
||||||
|
*out = pkt;
|
||||||
|
|
||||||
|
return GIT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* As per the documentation, the syntax is:
|
* As per the documentation, the syntax is:
|
||||||
*
|
*
|
||||||
@ -54,24 +68,19 @@ int git_pkt_parse_line(git_pkt **head, const char *line, const char **out)
|
|||||||
if (error < GIT_SUCCESS)
|
if (error < GIT_SUCCESS)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
|
line = num_end;
|
||||||
/*
|
/*
|
||||||
* TODO: How do we deal with empty lines? Try again? with the next
|
* TODO: How do we deal with empty lines? Try again? with the next
|
||||||
* line?
|
* line?
|
||||||
*/
|
*/
|
||||||
if (len == 4) {
|
if (len == 4) {
|
||||||
*out = num_end;
|
*out = line;
|
||||||
return GIT_SUCCESS;
|
return GIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len == 0) { /* Flush, should go into its own fn */
|
if (len == 0) { /* Flush pkt */
|
||||||
pkt = git__malloc(sizeof(git_pkt));
|
*out = line;
|
||||||
if (pkt == NULL)
|
return flush_pkt(head);
|
||||||
return GIT_ENOMEM;
|
|
||||||
|
|
||||||
pkt->type = GIT_PKT_FLUSH;
|
|
||||||
*head = pkt;
|
|
||||||
*out = num_end;
|
|
||||||
return GIT_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: Write the rest of this thing */
|
/* TODO: Write the rest of this thing */
|
||||||
|
Loading…
Reference in New Issue
Block a user