merge-ort: use STABLE_QSORT instead of QSORT where required
commit72b3091040f8d2784225527ebecfc3c2a56fe196
authorElijah Newren <newren@gmail.com>
Sat, 20 Mar 2021 00:03:44 +0000 (20 00:03 +0000)
committerJunio C Hamano <gitster@pobox.com>
Sat, 20 Mar 2021 19:35:39 +0000 (20 12:35 -0700)
treee6981e254a36a9aa98d8623dc6b2543de08cb099
parent9bd342137eb4dfe3852f657f8afcc637e68b1439
merge-ort: use STABLE_QSORT instead of QSORT where required

rename/rename conflict handling depends on the fact that if both sides
renamed the same path, that the one on the MERGE_SIDE1 will appear first
in the combined diff_queue_struct passed to process_renames().  Since we
add all pairs from MERGE_SIDE1 to combined first, and then all pairs
from MERGE_SIDE2, and then sort based on filename, this will only be
true if the sort used is stable.  This was found due to the fact that
Mac, unlike Linux, apparently has a system-defined qsort that is not
stable.

While we are at it, review the other callers of QSORT and add comments
about why they can remain as calls to QSORT instead of being modified
to call STABLE_QSORT.

Signed-off-by: Elijah Newren <newren@gmail.com>
Reviewed-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
merge-ort.c