Author Topic: Applying .diff files in Windows  (Read 1432 times)

0 Members and 1 Guest are viewing this topic.

Offline jamespetts

  • Simitrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 15248
  • Total likes: 361
  • Helpful: 159
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Applying .diff files in Windows
« 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.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4163
  • Total likes: 144
  • Helpful: 147
  • Languages: EN, DE, AT
Re: Applying .diff files in Windows
« Reply #1 on: April 24, 2014, 08:16:45 PM »
the patch command reads from standard input, it usually is invoked by
Code: [Select]
patch -pn < your.diff
where n is the number of directory prefixes (?) to skip. Svn patches work with -p0, git patches usually -p1.
Parsley, sage, rosemary, and maggikraut.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 8698
  • Total likes: 300
  • Helpful: 228
  • Languages: De,EN,JP
Re: Applying .diff files in Windows
« Reply #2 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

Offline jamespetts

  • Simitrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 15248
  • Total likes: 361
  • Helpful: 159
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Applying .diff files in Windows
« Reply #3 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.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.