diff options
author | Thomas Gummerer <t.gummerer@gmail.com> | 2017-09-07 20:24:12 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-09-08 09:47:45 +0900 |
commit | 0b90b881e0c1de110c724fe63df6d2c3c9680d6a (patch) | |
tree | 6a2e2f83538e72199d025a945e7a1c79e4cb640e /t/t4013-diff-various.sh | |
parent | Add t/helper/test-write-cache to .gitignore (diff) | |
download | tgif-0b90b881e0c1de110c724fe63df6d2c3c9680d6a.tar.xz |
read-cache: fix index corruption with index v4
ce012deb98 ("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. If CE_STRIP_NAME however gets set in the split
index case ce->ce_namelen is set to 0 without changing the actual
ce->name buffer. When index-v4, this results in the first character of
ce->name being written out instead of just a terminating nul charcter.
As index-v4 requires the terminating nul character as terminator of
the name when reading it back, this results in a corrupted index.
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: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t4013-diff-various.sh')
0 files changed, 0 insertions, 0 deletions