Coding Hints:Using Diff
From Wine-Wiki
Contents |
Introduction
Patches or Code Fixes are requested to be sent with diff. Indeed as it was explained to one developer: Because the man with the keys to cvs is very busy, he requests patches be sent as a diff.[...] D.Paun: Try to separate the changes, and submit a diff. I'm afraid things will go to /dev/null without one.
Diff Files should be generated from the top level Wine directory.
M. McCormack explained why to one developer: [by changing into the root wine directory and making a diff from there].. That makes it easier to apply the patch, because whoever applies it doesn't have to figure out that it's against a file in [for example] dlls/comctl32.
A. Julliard: [Apr 06] Please generate patches from the top-level directory, otherwise they are a pain to apply. wine archive
There has been a change recently with GIT usage reported since 0.9.45 by one user: Can someone fix this problem? (It looks like problem is related to binary files) It would be great if both patches were fixed and re-uploaded.
A. julliard [sept/Oct 07 wine devel]: The patches are fine, but they are in git format, so you need to use git-apply instead of patch to apply the binary changes properly.
According to the official Documentation: When submitting patches, Include a ChangeLog entry with your [real] name, email address and a description of what your patch does."
However when submitting a ChangeLog entry this does not mean you need to provide a ChangeLog patch.
J. Earnst: In the e-mail you send the patch with, just write something like:
- Changelog:
- - fixes null pointer
R. Shearman explained : on projects as big as Wine patching the ChangeLog is not practical as it would result in a lot of conflicts. Therefore, Alexandre Julliard automatically generates ChangeLog entries from CVS just before each release.
T. Wickline [Aug 05]: Only Alexandre does the changelog. Only patches that are accepted can be included into the changelog, and he has to accept it first..Wine Archive
You can list tips and tricks for using and troubleshooting Diff here
Generate a Patch Using Diff
Flags for generating Diff
The developers use the -pu flags. V. Margolen: "-p" to diff [is] we can see what function [the] changes are to.
M. McCormack: [mar 06] gave an example for the comctl32 file rebar.c wine archive
- cd wine
- diff -urp dlls/comctl32/rebar.c.cvs dlls/comctl32/rebar.c > attach.diff
Existing Files
M. Jung [May 05]: please use the -pu flags when generating [a] diff. This makes the diffs more robust and more easily readable for humans [...] You should create as well as apply the patches in the top level wine directory. When you apply a patch use
patch -p0 < foobar.diff
--- wine/configure 2005-04-09 21:33:30.000000000 -0600 +++ wine.new/configure 2005-04-09 21:32:53.000000000 -0600
Creating a Diff for a New File
M.cCormack gave a handy tip [Nov 05]: When you submit a new [file] please use diff -u /dev/null to generate the diff, something like this:
diff -u /dev/null programs/wcmd/Ko.rc > wcmd-ko.diff
Which Files to Diff
--- a/AUTHORS 2006-07-10 18:01:06.000000000 +0200 +++ b/AUTHORS
2006-10-08 11:34:59.000000000 +0200 @@ -873,3 +873,4 @@
Rizsanyi Zsolt
Per Ångström
Peter Åstrand
+{Name redacted]
R. Shearman [Oct 06]: This list is sorted by surname, but more importantly is regenerated by Alexandre using a script every 6 months or so. I think you'd do better crediting yourself in the copyright lines in rpc_transport.c. wine archive
M. McCormack:You don't need to diff configure, only configure.ac
diff -urN wine/dlls/Makefile.in wine.new/dlls/Makefile.in
You can probably omit dlls/Makefile.in too, as it is also automatically generated (by make_dlls). Wine Archive Link
Apply a patch using Diff
The font you are using may make this example hard to read.
A user admitted some confusion: I have the code saved on my desktop but have no idea what to do next. I've never replaced code before. Can anyone help?
Another user replied: Download the patch and copy it to the folder with the wine source code (Important ! Where you copy the patch is important it should be in the same directory as the extracted wine)
open a terminal open the directory (where ou have extract the wine ) and give this command (patch [minus p one]) like so
patch -p1 < x11drv_fbconfig_fix-0001.bin
dlls/... is print on terminal write it to patch the opengl.c file. to compile the wine download all requirements libs and give to terninal. [ammended to show text for patch args]
./configure
always check the last few lines of the ./configure output for missing dependencies errors etc. If configure reports any problems then in most cases you will need to resolve the problem reported before continuing with the installation. With the release of 0.9.12 configure may complain about a couple of missing font programs. I tried installing these but whether you really need them I don't know.
make depend
make
(// Time to make a coffee)
The next command requires root privileges. Although you should never run Wine as root, you will need to install it this way.
su
then enter the root password [and then]
make install
Exit superuser or root, then type .. (for ubuntu sudo make install)
(he copy the above lines from winehq site How to install wine so that World of Warcraft Works !) [wine user Sept 2006]
The Git Difference
A part time developer noted: when I tried to apply the patches for the recent Wine versions, [...] in all patches released in the last weeks, the dir names do not match the names in the source code tar archives. So, for example, if the source code had been unpacked into Wine-0.9.18, the patch to upgrade it to v0.9.19 would use 'a' and 'b' instead of 'Wine-0.9.18' and 'Wine-0.9.19' as dir names.
Another developer explained: There has been a recent shift in the last couple of months from using CVS as the primary revision control system, to using git. And apparently that is how git does things (I certainly am not with git, though). And the developers have clearly stated that in the future, all revision control will be done with git, so you might as well get used to it
You don't need to rename directories. Copy a patch of that format into the top level directory of the Wine tree you want to patch, and execute:
patch -p 1 < thepatch
The "-p 1" says to ignore the leading 'a' or 'b' or whatever.
Troubleshooting Diff
Applying patches
A user asked why this command didn't work:
patch -p 1 -R < /home/stefan/Desktop/shell32.diff can't find file to patch at input line 8 Perhaps you used the wrong -p or --strip option?
Dimi Paun : patch -p0 -R < ....
M. Jung : You should create as well as apply the patches in the top level wine directory. When you apply a patch use
patch -p0 < foobar.diff
I don't see the reason to do this, but if you would like to apply the patch in dlls/shell32, you have to call
patch -p2 < foobar.diff
This will remove the first two sub-directories from every file name in the diff.
Diff Feedback, Suggestions and Comments
342a343,344
{"PHT",
{'P','h','i','l','i','p','p','i','n','e',' ','T','i','m','e','\0'}, -480, 0},
K. Blin: Please stick to the diff -u format. It doesn't matter much for a patch of this size, but larger patches are much more readable.
Links
Unofficial Wine-Wiki Links
External Links
http://www.winehq.org/site/sending_patches http://wiki.winehq.org/DeveloperFaq http://winehq.org/site/docs/winedev-guide/codingpractice

