mirror of
https://git.proxmox.com/git/libgit2
synced 2025-08-14 11:13:52 +00:00
Skip the optional header in packed-refs files
This commit is contained in:
parent
7064938bd5
commit
7c8a7b9143
20
src/refs.c
20
src/refs.c
@ -507,22 +507,14 @@ static int packed_load(git_repository *repo)
|
|||||||
buffer_start = (const char *)packfile.data;
|
buffer_start = (const char *)packfile.data;
|
||||||
buffer_end = (const char *)(buffer_start) + packfile.len;
|
buffer_end = (const char *)(buffer_start) + packfile.len;
|
||||||
|
|
||||||
/* Does the header look like valid? */
|
while (buffer_start < buffer_end && buffer_start[0] == '#') {
|
||||||
if (git__prefixcmp((const char *)(buffer_start), GIT_PACKEDREFS_HEADER)) {
|
buffer_start = strchr(buffer_start, '\n');
|
||||||
|
if (buffer_start == NULL) {
|
||||||
error = GIT_EPACKEDREFSCORRUPTED;
|
error = GIT_EPACKEDREFSCORRUPTED;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Let's skip the header */
|
|
||||||
buffer_start += strlen(GIT_PACKEDREFS_HEADER);
|
|
||||||
|
|
||||||
if (*buffer_start == '\r')
|
|
||||||
buffer_start++;
|
|
||||||
|
|
||||||
if (*buffer_start != '\n')
|
|
||||||
return GIT_EPACKEDREFSCORRUPTED;
|
|
||||||
|
|
||||||
buffer_start++;
|
buffer_start++;
|
||||||
|
}
|
||||||
|
|
||||||
while (buffer_start < buffer_end) {
|
while (buffer_start < buffer_end) {
|
||||||
reference_oid *ref = NULL;
|
reference_oid *ref = NULL;
|
||||||
@ -810,7 +802,9 @@ static int packed_write(git_repository *repo)
|
|||||||
if ((error = git_filebuf_open(&pack_file, pack_file_path, 0)) < GIT_SUCCESS)
|
if ((error = git_filebuf_open(&pack_file, pack_file_path, 0)) < GIT_SUCCESS)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
/* Packfiles have a header! */
|
/* Packfiles have a header... apparently
|
||||||
|
* This is in fact not required, but we might as well print it
|
||||||
|
* just for kicks */
|
||||||
if ((error = git_filebuf_printf(&pack_file, "%s\n", GIT_PACKEDREFS_HEADER)) < GIT_SUCCESS)
|
if ((error = git_filebuf_printf(&pack_file, "%s\n", GIT_PACKEDREFS_HEADER)) < GIT_SUCCESS)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user