The International Simutrans Forum

Development => Technical Documentation => Topic started by: jamespetts on April 24, 2014, 07:55:38 PM

Title: Applying .diff files in Windows
Post by: jamespetts on April 24, 2014, 07:55:38 PM
I have had some trouble applying .diff files in Windows, and I should be grateful if anyone is able to describe best how to make it work. This is relevant because TurfIt has been very kindly doing some work on Experimental and prefers to produce .diff files rather than a branch on Github.

I have found and installed the Windows port of the Linux patch tool and added it to the path. However, actually running the tool (from the Windows command line) produces a new white on black text window which hangs and does not do anything. However, when I use the --help switch, the window closes as fast as it opens, which, I think, is strictly the correct (albeit not very helpful) behaviour for the tool.

If anyone has any experience of applying .diff files successfully in a Windows environment, I should be very grateful for any pointers.
Title: Re: Applying .diff files in Windows
Post by: Dwachs on April 24, 2014, 08:16:45 PM
the patch command reads from standard input, it usually is invoked by

patch -pn < your.diff

where n is the number of directory prefixes (?) to skip. Svn patches work with -p0, git patches usually -p1.
Title: Re: Applying .diff files in Windows
Post by: prissi on April 24, 2014, 10:49:47 PM
Windows 7 has a protection that a program patch is not executed unless you run some registry fix or run patch as admin. Rename patch.exe to pat.exe is the easiest way out. You can have it more complex: http://stackoverflow.com/questions/7914180/windows-7-exe-filename-starts-with-patch-wont-run
Title: Re: Applying .diff files in Windows
Post by: jamespetts on April 24, 2014, 10:57:47 PM
I think that I have found a better way of doing it than using patch.exe - using the Git BASH shell that comes with an installation of Git for Windows, I am able to use the patch tool built into that. One needs to use the following format: "patch -p0 -i [patch filename].diff", the "-i" indicating that the file should be used. The "p0" might need to be changed to "p1" or some other numerical value if different software was used to create the .diff file.

Thank you both for your help.