Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
read-cache: fix index corruption when using split index and version 4
("read-cache: avoid allocating every ondisk entry when writing", 2017-08-21) changed the way cache entries are written to the index file. While previously it wrote the name to an struct that was allocated using xcalloc(), it now uses ce_write() directly. Previously ce_namelen - common bytes were written to the cache entry, which would automatically make it nul terminated, as it was allocated using calloc. Now we are writing ce_namelen - common + 1 bytes directly from the ce->name to the index. When CE_STRIP_NAME was set the ce_namelen was being set to zero but then the + 1 was causing the first byte of the ce->name to be written which was not a nul byte. Fix that by only writing ce_namelen - common bytes directly from ce->name to the index, and adding the nul terminator in an extra call to ce_write. This bug was turned up by setting TEST_GIT_INDEX_VERSION = 4 in config.mak and running the test suite (t1700 specifically broke). Signed-off-by: Kevin Willford <kewillf@microsoft.com>
- Loading branch information