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 » 29 Oct 2005 10:15

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 » 29 Oct 2005 12:03

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 » 30 Oct 2005 04:05

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 » 24 Nov 2005 08:32

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
TortoiseSVN_Checkout.png
Attachement 1
TortoiseSVN_Checkout.png (7.63 KiB) Viewed 107891 times
TortoiseSVN_Merger.png
Attachement 2
TortoiseSVN_Merger.png (4.32 KiB) Viewed 107901 times

User avatar
Benbo
Transport Coordinator
Transport Coordinator
Posts: 380
Joined: 09 Jan 2006 18:51
Location: UK

Patches...

Post by Benbo » 12 Jan 2006 19:09

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 » 12 Jan 2006 19:24

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 » 12 Jan 2006 20:31

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 » 18 Jan 2006 19:18

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 » 18 Jan 2006 20:34

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 » 18 Jan 2006 20:37

*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 » 19 Jan 2006 08:28

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 » 19 Jan 2006 08:36

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 » 19 Jan 2006 19:35

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 » 19 Jan 2006 19:41

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 » 19 Jan 2006 19:57

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 » 20 Jan 2006 08:45

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 » 20 Jan 2006 10:30

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 » 20 Jan 2006 11:59

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 » 20 Jan 2006 14:48

Well else do I get it then???

MeusH
Tycoon
Tycoon
Posts: 4349
Joined: 25 Oct 2004 15:39
Location: Mississauga

Post by MeusH » 20 Jan 2006 17:38

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: Baidu [Spider], Redirect Left and 6 guests