aboutsummaryrefslogtreecommitdiffstats
path: root/read-cache.c
diff options
context:
space:
mode:
authorTaylor Blau <me@ttaylorr.com>2024-10-22 14:40:38 -0400
committerTaylor Blau <me@ttaylorr.com>2024-10-22 14:40:38 -0400
commit6ca9a05e63608a386f9dec50110725954c41216a (patch)
tree7c565796809f4621f165740f6e9735ab540996b1 /read-cache.c
parentThe third batch (diff)
parentunpack-trees: detect mismatching number of cache-tree/index entries (diff)
downloadgit-6ca9a05e63608a386f9dec50110725954c41216a.tar.gz
git-6ca9a05e63608a386f9dec50110725954c41216a.zip
Merge branch 'ps/cache-tree-w-broken-index-entry'
Fail gracefully instead of crashing when attempting to write the contents of a corrupt in-core index as a tree object. * ps/cache-tree-w-broken-index-entry: unpack-trees: detect mismatching number of cache-tree/index entries cache-tree: detect mismatching number of index entries cache-tree: refactor verification to return error codes
Diffstat (limited to 'read-cache.c')
-rw-r--r--read-cache.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/read-cache.c b/read-cache.c
index 1148a55873..01d0b3ad22 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -3335,8 +3335,9 @@ int write_locked_index(struct index_state *istate, struct lock_file *lock,
int new_shared_index, ret, test_split_index_env;
struct split_index *si = istate->split_index;
- if (git_env_bool("GIT_TEST_CHECK_CACHE_TREE", 0))
- cache_tree_verify(the_repository, istate);
+ if (git_env_bool("GIT_TEST_CHECK_CACHE_TREE", 0) &&
+ cache_tree_verify(the_repository, istate) < 0)
+ return -1;
if ((flags & SKIP_IF_UNCHANGED) && !istate->cache_changed) {
if (flags & COMMIT_LOCK)