summaryrefslogtreecommitdiffstats
path: root/t/t4013/diff.format-patch_--inline_--stdout_initial..main^
diff options
context:
space:
mode:
authorElijah Newren <newren@gmail.com>2026-04-21 00:26:11 +0000
committerJunio C Hamano <gitster@pobox.com>2026-04-22 16:22:20 -0700
commit60826fdeb137a61e6ae8b80d70509d2bc094f8a5 (patch)
treec8d778603b46ed6877ba34a835677bab0aafe049 /t/t4013/diff.format-patch_--inline_--stdout_initial..main^
parent61388e3ea34663bf0d403f6510cac509cbd88811 (diff)
downloadgit-60826fdeb137a61e6ae8b80d70509d2bc094f8a5.tar.gz
git-60826fdeb137a61e6ae8b80d70509d2bc094f8a5.zip
cache-tree: fix verify_cache() to catch non-adjacent D/F conflicts
verify_cache() checks that the index does not contain both "path" and "path/file" before writing a tree. It does this by comparing only adjacent entries, relying on the assumption that "path/file" would immediately follow "path" in sorted order. Unfortunately, this assumption does not always hold. For example: docs <-- submodule entry docs-internal/README.md <-- intervening entry docs/requirements.txt <-- D/F conflict, NOT adjacent to "docs" When this happens, verify_cache() silently misses the D/F conflict and write-tree produces a corrupt tree object containing duplicate entries (one for the submodule "docs" and one for the tree "docs"). I could not find any caller in current git that both allows the index to get into this state and then tries to write it out without doing other checks beyond the verify_cache() call in cache_tree_update(), but verify_cache() is documented as a safety net for preventing corrupt trees and should actually provide that guarantee. A downstream consumer that relied solely on cache_tree_update()'s internal checking via verify_cache() to prevent duplicate tree entries was bitten by the gap. Add a test that constructs a corrupt index directly (bypassing the D/F checks in add_index_entry) and verifies that write-tree now rejects it. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t4013/diff.format-patch_--inline_--stdout_initial..main^')
0 files changed, 0 insertions, 0 deletions