-
Notifications
You must be signed in to change notification settings - Fork 141
Git's rename detection requires a stable sort #352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Git's rename detection requires a stable sort #352
Conversation
77e30d0
to
a95cdf1
Compare
/submit |
Submitted as [email protected] |
…ears/next See gitgitgadget#352 Signed-off-by: Johannes Schindelin <[email protected]>
This branch is now known as |
This patch series was integrated into pu via git@01c240c. |
The `qsort()` function is not guaranteed to be stable, i.e. it does not promise to maintain the order of items it is told to consider equal. In contrast, the `git_sort()` function we carry in `compat/qsort.c` _is_ stable, by virtue of implementing a merge sort algorithm. In preparation for using a stable sort in Git's rename detection, move the stable sort into `libgit.a` so that it is compiled in unconditionally, and rename it to `git_stable_qsort()`. Note: this also makes the hack obsolete that was introduced in fe21c6b (mingw: reencode environment variables on the fly (UTF-16 <-> UTF-8), 2018-10-30), where we included `compat/qsort.c` directly in `compat/mingw.c` to use the stable sort. Signed-off-by: Johannes Schindelin <[email protected]>
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 <[email protected]>
a95cdf1
to
4421404
Compare
/submit |
Submitted as [email protected] |
…ears/next See gitgitgadget#352 Signed-off-by: Johannes Schindelin <[email protected]>
This comment has been minimized.
This comment has been minimized.
This patch series was integrated into pu via git@aaf27a8. |
…ears/next See gitgitgadget#352 Signed-off-by: Johannes Schindelin <[email protected]>
This patch series was integrated into pu via git@016da89. |
This patch series was integrated into pu via git@9c79a23. |
This patch series was integrated into pu via git@b699e49. |
This patch series was integrated into next via git@e02d882. |
This patch series was integrated into pu via git@b8203e1. |
This patch series was integrated into pu via git@fa94da2. |
This patch series was integrated into pu via git@d90b93d. |
This patch series was integrated into pu via git@7be6d77. |
This patch series was integrated into pu via git@772cad0. |
This patch series was integrated into next via git@772cad0. |
This patch series was integrated into master via git@772cad0. |
Closed via 772cad0. |
With the
en/merge-recursive-cleanup
patches already having advanced tonext
, the problem I discovered when rebasing Git for Windows' branch thicket becomes quite relevant now: t3030.35 fails consistently in the MSVC build & test (this part of the Azure Pipeline will be upstreamed later).The solution: use a stable sort.
Note: this patch series is based on top of
en/merge-recursive-cleanup
.Changes since v1:
git_stable_qsort()
, as per Junio's suggestion.