Commit 11d0be23 by Patrick Steinhardt

index: set last entry when reading compressed entries

To calculate the path of a compressed index entry, we need to know the
preceding entry's path. While we do actually set the first predecessor
correctly to "", we fail to update this while reading the entries.

Fix the issue by updating `last` inside of the loop. Previously, we've
been passing a double-pointer to `read_entry`, which it didn't update.
As it is more obvious to update the pointer inside the loop itself,
though, we can simply convert it to a normal pointer.
parent febe8c14
......@@ -2287,7 +2287,7 @@ static size_t read_entry(
git_index *index,
const void *buffer,
size_t buffer_size,
const char **last)
const char *last)
{
size_t path_length, entry_size;
const char *path_ptr;
......@@ -2357,7 +2357,7 @@ static size_t read_entry(
size_t varint_len;
size_t strip_len = git_decode_varint((const unsigned char *)path_ptr,
&varint_len);
size_t last_len = strlen(*last);
size_t last_len = strlen(last);
size_t prefix_len = last_len - strip_len;
size_t suffix_len = strlen(path_ptr + varint_len);
size_t path_len;
......@@ -2448,7 +2448,7 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
unsigned int i;
struct index_header header = { 0 };
git_oid checksum_calculated, checksum_expected;
const char **last = NULL;
const char *last = NULL;
const char *empty = "";
#define seek_forward(_increase) { \
......@@ -2472,7 +2472,7 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
index->version = header.version;
if (index->version >= INDEX_VERSION_NUMBER_COMP)
last = ∅
last = empty;
seek_forward(INDEX_HEADER_SIZE);
......@@ -2507,6 +2507,9 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
}
error = 0;
if (index->version >= INDEX_VERSION_NUMBER_COMP)
last = entry->path;
seek_forward(entry_size);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment