Fix highly embarrassing mistake in patch transformation #6182
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport in 2.2 with #6183
This has sadly been wrong since #3349 was fixed in #3449 (which equates to "it's always been wrong", as that was during 2.0.0's dev cycle).
Patches require transformation to deal with line-endings - patch can cope with patching CRLF files, but the diff needs to have the same line-endings as the files. Prior to applying a patch,
OpamSystem.translate_patch
checks the files to which the diff is being applied and transforms the patch. If no transformations are needed (which is pretty much always - most release tarballs use Unix line-endings, even on Windows), then the patch is simply copied.The process works fine, except for a teeny detail. Owing to a badly made logging transformation in #3449, the transformation was only written to the patch file if debugging mode was enabled 🤦
On Windows, while working on compiler packaging, this manifested itself as:
but the patch is successfully transformed when running with
--debug
. What was happening was the the patch file is opened (ch_out
); nothing is written to it so the patch of course "applies" perfectly but becausech_out
was never closed, the removal fails after trying to apply the patch (as it happens, the removal is skipped when debugging, but would in fact succeed).