Skip to content

Commit 8c96d56

Browse files
committed
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.
1 parent 27cb4e0 commit 8c96d56

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/index.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2744,7 +2744,7 @@ static int write_disk_entry(git_filebuf *file, git_index_entry *entry, const cha
27442744
++same_len;
27452745
}
27462746
path_len -= same_len;
2747-
varint_len = git_encode_varint(NULL, 0, same_len);
2747+
varint_len = git_encode_varint(NULL, 0, strlen(last) - same_len);
27482748
}
27492749

27502750
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
27952795

27962796
if (last) {
27972797
varint_len = git_encode_varint((unsigned char *) path,
2798-
disk_size, same_len);
2798+
disk_size, strlen(last) - same_len);
27992799
assert(varint_len > 0);
28002800
path += varint_len;
28012801
disk_size -= varint_len;

0 commit comments

Comments
 (0)