https://bugs.winehq.org/show_bug.cgi?id=50720
Bug ID: 50720 Summary: Cannot apply patch series that modifies and then renames a file Product: Wine-Testbot Version: unspecified Hardware: x86-64 OS: Linux Status: NEW Severity: normal Priority: P2 Component: unknown Assignee: wine-bugs@winehq.org Reporter: fgouget@codeweavers.com Distribution: ---
If part 1 of a patch series modifies a file and then part 2 renames that file, git apply misapplies or fails to apply the combined (concatenated) patch used by the TestBot.
See for instance: https://www.winehq.org/pipermail/wine-devel/2021-February/181490.html
When a Git commit renames and modifies a file, the resulting Git diff does both in one operation:
diff --git a/dlls/winegstreamer/gstdemux.c b/dlls/winegstreamer/quartz_parser.c similarity index 97% rename from dlls/winegstreamer/gstdemux.c rename to dlls/winegstreamer/quartz_parser.c index 84e6bcd61e4..e9e7c3a0f9f 100644 --- a/dlls/winegstreamer/gstdemux.c +++ b/dlls/winegstreamer/quartz_parser.c ...
But the combined patches that the TestBot produces for patch series results in multiple "diff --git" entries, one to modify the old file, and then one to rename it. That results in "git apply" either mishandling the patch (apparently it performs a global analysis and renames the file before patching the old file, maybe to handle patches with A->B + B->A renames), or failing to apply it altogether.
Potential fixes: * Use "patch -p1". It handles these combined patches as expected. It may however be somewhat more permissive than "git apply" in other scenarios which may not be desirable.
* Split the combined patch into its individual components before "git applying" them one by one.
* Store the patches in mbox format so that the combined patch is in mbox format too, and use "git am".
This can be tested with the following wtbsuite tests: [2/2] WTBS S10.2 - ...before renaming it in the next part (amstream:amstream). [7/7] WTBS S5.7 - Check for rename+addition+removal conflicts (msi:suminfo).