Howto apply a patch/diff file

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

Post Reply
Bjarni
Tycoon
Tycoon
Posts: 2088
Joined: 08 Mar 2004 13:10

Howto apply a patch/diff file

Post by Bjarni »

Patching (applying a patch/diff file) is done to OpenTTD's sources. This implies that you have to get the sources to apply the patch/diff and compile OpenTTD yourself.


So the first step is acquiring the source code. It can be found in the same place you found the binary under "source".


Now you can start the patching:

first of all: .patch and .diff is the same. It doesn't matter. We could call them .this_is_my_patch_file too if we want to. It's just a name (ok, some app apart from patch might not like it)

on most systems:

Code: Select all

patch -p0 -i file.diff
the -p option means how many leading dirs that you skip when patching. Usually it's 0, but sometimes some odd patch uses a different number. You can learn this by reading the first line of the diff file

Code: Select all

Index: src/video/dedicated_v.cpp
this would be 0

Code: Select all

Index: trunk/src/video/dedicated_v.cpp
this would be 1, because you need to skip the trunk part of it to get to the root dir of your local source folder

-i tells what file you want to patch from, in this case the file named file.diff

There are some other apps to do this on windows. I don't know them, so somebody else have to write how to use them. Patch works in cygwin too.
User avatar
Darkvater
Tycoon
Tycoon
Posts: 3053
Joined: 24 Feb 2003 18:45
Location: Hong Kong

Post by Darkvater »

I usually use

Code: Select all

patch -p0 < file.diff
but it's personal :).
Usually however all patches are made from SVN so you would use TortoiseSVN to apply the diff.

patch.exe also exists on windows (look for gnu-tools); you only need to make sure that the patch file is in windows format. Eg CR/LF line-endings, otherwise patch will crash. You can do this with any decent text-editor like UltraEdit. Use File -> Conversions -> UNIX/MAC to DOS.
TrueLight: "Did you bother to read any of the replies, or you just pressed 'Reply' and started typing?"
<@[R-Dk]FoRbiDDeN> "HELP, this litte arrow thing keeps following my mouse, and I can't make it go away."
Conditional Zenith
Chief Executive
Chief Executive
Posts: 697
Joined: 10 Jun 2003 00:19
Location: Australia

Post by Conditional Zenith »

While there are more answers that just this one, this wiki page has this info.
MeusH
Tycoon
Tycoon
Posts: 4349
Joined: 25 Oct 2004 15:39
Location: Mississauga

Post by MeusH »

If you're using windows, you can download TortoiseSVN, install and do the following:

Download the source files:
Make a new folder
Right click on it
Choose "SVN Checout..." from the menu
Set data fields like on attachement 1
Hit OK, wait 5-20 minutes for all files to download

Choose the diff file:
Right click on folder you've downloaded files to
Choose "TortoiseSVN > Apply Patch..." from the menu
Browse for .patch or .diff file

Apply the changes:
Usually, right clicking on filelist window (attachement 2) and clicking "Patch all" should work, but sometimes there is something wrong (attachement 2 - files marked red):

Don't worry, often application will download other revision and everything will work.
However, if you're experiencing problems (marked red) ask patch developer and tell him what's wrong. Tell him what diff file have you downloaded and what revision have you downloaded using "SVN Checkout"


Happy patching :)
Attachments
Attachement 1
Attachement 1
TortoiseSVN_Checkout.png (7.63 KiB) Viewed 120763 times
Attachement 2
Attachement 2
TortoiseSVN_Merger.png (4.32 KiB) Viewed 120773 times
User avatar
Benbo
Transport Coordinator
Transport Coordinator
Posts: 380
Joined: 09 Jan 2006 18:51
Location: UK

Patches...

Post by Benbo »

I'm kind of new at doing this, (actully, it's my first time...) and I'm asking whether this kind of 'coding' is done in Command? I don't know where to write the stuff into. I presume it is Command.

When I say the 'code', I mean this...

Code: Select all

patch -p0 -i file.diff
User avatar
webfreakz.nl
Director
Director
Posts: 627
Joined: 11 Aug 2005 08:22
Location: Localhost, 127.0.0.1, [The Netherlands: South Holland-> Westland]
Contact:

Post by webfreakz.nl »

You have to type it in the linux commandline (also called Linux Box like Bash) in the current directory, otherwise it won't be able to apply the patch 'file.diff' :)
# Programming is like sex, one mistake and you have to support it for the rest of your life. (Michael Sinz)
egladil
OpenTTD Developer
OpenTTD Developer
Posts: 188
Joined: 07 Nov 2005 17:10
Location: Sweden

Post by egladil »

Or, if you are using windows, just read what MeusH wrote right above your post.
User avatar
Benbo
Transport Coordinator
Transport Coordinator
Posts: 380
Joined: 09 Jan 2006 18:51
Location: UK

Post by Benbo »

I seem to have endless problems with that and I just simply want to know, using Windows do I need to use command to do it or what? What program do I type that code in :?:
egladil
OpenTTD Developer
OpenTTD Developer
Posts: 188
Joined: 07 Nov 2005 17:10
Location: Sweden

Post by egladil »

If you are using windows, you don't type any code in anywhere. As I said, you do as MeusH said and download TortoiseSVN and follow his instructions.
MeusH
Tycoon
Tycoon
Posts: 4349
Joined: 25 Oct 2004 15:39
Location: Mississauga

Post by MeusH »

*deleted*

Egladil was faster ;) Thx
User avatar
Benbo
Transport Coordinator
Transport Coordinator
Posts: 380
Joined: 09 Jan 2006 18:51
Location: UK

Post by Benbo »

See I've been searching the site for the download for Win 98 and I can't find it anywhere. I have downloaded different versions, but they have different problems, so if someone coud point me in the direction of the version for Win 98 and they know that it'll work on Win 98 then i would be very grateful :wink:
egladil
OpenTTD Developer
OpenTTD Developer
Posts: 188
Joined: 07 Nov 2005 17:10
Location: Sweden

Post by egladil »

http://tortoisesvn.tigris.org/download.html wrote:NOTE: If you need to use TortoiseSVN with Windows 95/98/Me/NT4 then you will need to use a pre-1.2 version. The last release on the 1.1.x line was 1.1.7. Read the 1.2 Release Notes to find out why we have had to drop support for these older operating systems.
So either look in their archive, or even better, upgrade your OS if possible.
User avatar
Benbo
Transport Coordinator
Transport Coordinator
Posts: 380
Joined: 09 Jan 2006 18:51
Location: UK

Hmm...

Post by Benbo »

I had read that, and gone through the archives and looked for version 1.2. Couldn't find it. So I decided that the versions before it would work on 98 too. I have tried several versions, and mostly come up with the same problems.

I just tried version 1.1.4 and when I went to install it, it said to me
SVN wrote:The installer needs an NT based OS
What??? I thought that this was supposed to work on 98 too...
Last edited by Benbo on 19 Jan 2006 19:42, edited 1 time in total.
User avatar
webfreakz.nl
Director
Director
Posts: 627
Joined: 11 Aug 2005 08:22
Location: Localhost, 127.0.0.1, [The Netherlands: South Holland-> Westland]
Contact:

Post by webfreakz.nl »

WTF, why do you work on Win98(se)? Just install Win2000 then, much better, more stable and it does have a NT engine.
# Programming is like sex, one mistake and you have to support it for the rest of your life. (Michael Sinz)
MeusH
Tycoon
Tycoon
Posts: 4349
Joined: 25 Oct 2004 15:39
Location: Mississauga

Post by MeusH »

webfreakz.nl, win 98 has its advantages over 2000.

Benbo, we shall look for other SVN clients/tools. Google probably :)
User avatar
bobingabout
Tycoon
Tycoon
Posts: 1850
Joined: 21 May 2005 15:10
Location: Hull, England

Post by bobingabout »

there are s*** of things you can't do in the NT engine.

for example, here at college, we've just had to make a bunch of MS-DOS boot disks to run out logic analyser software, because it doesn't run under windows 2000.

and this isn't exactly something you can just go out and buy a replacement for.
JPG SUX!!! USE PNG!!!
There are times when JPG is useful, TTD screenshots is not one of them. Please use PNG instead.

[/url]
User avatar
Brianetta
Tycoon
Tycoon
Posts: 2566
Joined: 15 Oct 2003 22:00
Location: Jarrow, UK
Contact:

Post by Brianetta »

webfreakz.nl wrote:Just install Win2000 then...
Are you offering to pay? Windows is hardly cheap.
PGP fingerprint: E66A 9D58 AA10 E967 41A6 474E E41D 10AE 082C F3ED
User avatar
webfreakz.nl
Director
Director
Posts: 627
Joined: 11 Aug 2005 08:22
Location: Localhost, 127.0.0.1, [The Netherlands: South Holland-> Westland]
Contact:

Post by webfreakz.nl »

Brianetta wrote:
webfreakz.nl wrote:Just install Win2000 then...
Are you offering to pay? Windows is hardly cheap.
Did I say he has to buy Win2k? :P
# Programming is like sex, one mistake and you have to support it for the rest of your life. (Michael Sinz)
User avatar
Benbo
Transport Coordinator
Transport Coordinator
Posts: 380
Joined: 09 Jan 2006 18:51
Location: UK

Post by Benbo »

Well else do I get it then???
MeusH
Tycoon
Tycoon
Posts: 4349
Joined: 25 Oct 2004 15:39
Location: Mississauga

Post by MeusH »

Warez and illegal software is not tolerated here. I'd google for SVN client...
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 4 guests