summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Wang <mail6543210@yahoo.com.tw>2020-05-26 04:53:09 +0800
committerPatrick Wang <mail6543210@yahoo.com.tw>2020-05-26 05:36:17 +0800
commit8c96d56dd0af7e7186a93915c33eda6758a9da3c (patch)
tree6efef658cf82109331cd68cedd8adaab8ead65cc
parent27cb4e0ec193aa5430d1a32fd90b5dc2d86f5fe1 (diff)
downloadlibgit2-8c96d56dd0af7e7186a93915c33eda6758a9da3c.tar.gz
index: write v4: bugfix: prefix path with strip_len, not same_len
According to index-format.txt of git, the path of an entry is prefixed with N, where N indicates the length of bytes to be stripped.
-rw-r--r--src/index.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/index.c b/src/index.c
index 907bd6d93..36a8bdb7b 100644
--- a/src/index.c
+++ b/src/index.c
@@ -2744,7 +2744,7 @@ static int write_disk_entry(git_filebuf *file, git_index_entry *entry, const cha
++same_len;
}
path_len -= same_len;
- varint_len = git_encode_varint(NULL, 0, same_len);
+ varint_len = git_encode_varint(NULL, 0, strlen(last) - same_len);
}
disk_size = index_entry_size(path_len, varint_len, entry->flags);
@@ -2795,7 +2795,7 @@ static int write_disk_entry(git_filebuf *file, git_index_entry *entry, const cha
if (last) {
varint_len = git_encode_varint((unsigned char *) path,
- disk_size, same_len);
+ disk_size, strlen(last) - same_len);
assert(varint_len > 0);
path += varint_len;
disk_size -= varint_len;