]> git.ipfire.org Git - thirdparty/git.git/commit
diffcore_rename(): use a stable sort
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Mon, 30 Sep 2019 17:21:55 +0000 (10:21 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 2 Oct 2019 05:44:54 +0000 (14:44 +0900)
commit2049b8dc65e7371c56452cfda5234182d58b704e
tree50ad08a526b3ef7bd06beceb6255984b78f5af64
parent97fff6101220b66bc293239ab2cf29fc3624072b
diffcore_rename(): use a stable sort

During Git's rename detection, the file names are sorted. At the moment,
this job is performed by `qsort()`. As that function is not guaranteed
to implement a stable sort algorithm, this can lead to inconsistent
and/or surprising behavior: a rename might be detected differently
depending on the platform where Git was run.

The `qsort()` in MS Visual C's runtime does _not_ implement a stable
sort algorithm, and it even leads to an inconsistency leading to a test
failure in t3030.35 "merge-recursive remembers the names of all base
trees": a different code path than on Linux is taken in the rename
detection of an ambiguous rename between either `e` to `a` or
`a~Temporary merge branch 2_0` to `a` during a recursive merge,
unexpectedly resulting in a clean merge.

Let's use the stable sort provided by `git_stable_qsort()` to avoid this
inconsistency.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diffcore-rename.c