summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2017-05-19 13:49:34 +0200
committerPatrick Steinhardt <ps@pks.im>2017-06-06 09:38:44 +0200
commitc71dff7e8a1bde298972c10901802608bd4cbb55 (patch)
tree8696971e9135dc5b159cb6181387385b6121007c
parent83e0392ceadb7e1d9db09a7f013e28759a666e89 (diff)
downloadlibgit2-c71dff7e8a1bde298972c10901802608bd4cbb55.tar.gz
index: fix shared prefix computation when writing index entry
When using compressed index entries, each entry's path is preceded by a varint encoding how long the shared prefix with the previous index entry actually is. We currently encode a length of `(path_len - same_len)`, which is doubly wrong. First, `path_len` is already set to `path_len - same_len` previously. Second, we want to encode the shared prefix rather than the un-shared suffix length. Fix this by using `same_len` as the varint value instead.
-rw-r--r--src/index.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/index.c b/src/index.c
index bff5d7f73..860adaf12 100644
--- a/src/index.c
+++ b/src/index.c
@@ -2661,8 +2661,7 @@ static int write_disk_entry(git_filebuf *file, git_index_entry *entry, const cha
if (last) {
path += git_encode_varint((unsigned char *) path,
- disk_size,
- path_len - same_len);
+ disk_size, same_len);
}
memcpy(path, path_start, path_len);