]> git.99rst.org Git - git.git/commit
merge-ort: abort merge when trees have duplicate entries
authorElijah Newren <redacted>
Sun, 14 Jun 2026 06:37:25 +0000 (06:37 +0000)
committerJunio C Hamano <redacted>
Sun, 14 Jun 2026 14:50:47 +0000 (07:50 -0700)
commit43a5fa7f5a9b7c44dd958a21368d690fa55d4f50
treea0d2875755d5105d57a0f25a2b9907e58641bc44
parent83ae606c9838b06bde36479756de2ab75b6fbb96
merge-ort: abort merge when trees have duplicate entries

Trees with duplicate entries are malformed; fsck reports "contains
duplicate file entries" for them.  merge-ort has from the beginning
assumed that we would never hit such trees.  It was written with the
assumption that traverse_trees() calls collect_merge_info_callback() at
most once per path.  The "sanity checks" in that callback (added in
d2bc1994f363 (merge-ort: implement a very basic collect_merge_info(),
2020-12-13)) verify properties of each individual call but not that
invariant.  The strmap_put() in setup_path_info() silently overwrites
the entry from any prior call for the same path, because it assumed
there would be no other path.  Unfortunately, supplemental data
structures for various optimizations could still be tweaked before the
extra paths were overwritten, and those data structures not matching
expected state could trip various assertions.

Change the return type of setup_path_info() from void to int to allow us
to detect this case, and abort the merge with a clear error message when
it occurs.

Signed-off-by: Elijah Newren <redacted>
Signed-off-by: Junio C Hamano <redacted>
merge-ort.c
t/t6422-merge-rename-corner-cases.sh
git clone https://git.99rst.org/PROJECT