path: root/split-index.c
diff options
authorThomas Gummerer <>2018-01-07 22:30:14 (GMT)
committerJunio C Hamano <>2018-01-19 18:36:39 (GMT)
commit4bddd98311f249e9ed8a9b6379c7a097201612d1 (patch)
tree7800bc3c00d4a6e33931d81b3c32e07604e4865a /split-index.c
parenta125a223347a8d43fffc1b7ec2bec93d88ec17b7 (diff)
split-index: don't write cache tree with null oid entries
In a96d3cc3f6 ("cache-tree: reject entries with null sha1", 2017-04-21) we made sure that broken cache entries do not get propagated to new trees. Part of that was making sure not to re-use an existing cache tree that includes a null oid. It did so by dropping the cache tree in 'do_write_index()' if one of the entries contains a null oid. In split index mode however, there are two invocations to 'do_write_index()', one for the shared index and one for the split index. The cache tree is only written once, to the split index. As we only loop through the elements that are effectively being written by the current invocation, that may not include the entry with a null oid in the split index (when it is already written to the shared index), where we write the cache tree. Therefore in split index mode we may still end up writing the cache tree, even though there is an entry with a null oid in the index. Fix this by checking for null oids in prepare_to_write_split_index, where we loop the entries of the shared index as well as the entries for the split index. This fixes t7009 with GIT_TEST_SPLIT_INDEX. Also add a new test that's more specifically showing the problem. Signed-off-by: Thomas Gummerer <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'split-index.c')
1 files changed, 2 insertions, 0 deletions
diff --git a/split-index.c b/split-index.c
index 83e39ec..284d04d 100644
--- a/split-index.c
+++ b/split-index.c
@@ -238,6 +238,8 @@ void prepare_to_write_split_index(struct index_state *istate)
ALLOC_GROW(entries, nr_entries+1, nr_alloc);
entries[nr_entries++] = ce;
+ if (is_null_oid(&ce->oid))
+ istate->drop_cache_tree = 1;