Sign in Join
Wiki copytemporary

Creating A Patch: what changed

Revision 3 to 4. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
1-If you want to submit improvements to the FPC or Lazarus code, you need to submit a patch which developers can easily merge.
1+If you want to submit improvements to the FPC or Lazarus code, you need to submit a patch which developers can easily merge.
22
3-Exceptions:
3+Exceptions:
44
5-1. .po translation files should be sent as whole files
6-2. new files should be sent as whole files, with instructions where they should be placed
5+ 1. .po translation files should be sent as whole files
6+ 2. new files should be sent as whole files, with instructions where they should be placed
77
88## Requirements
99
10-You need the **main/development** version of Lazarus (or FPC). You can get Lazarus using either Git or SVN.
11-
12-- Git: [[Getting Lazarus|Getting Lazarus development version]]. This is the native repository.
13-- SVN: Read-only mirror of the official GitLab repository requires some svn gymnastics due to a bug in many versions of svn:
10+You need the **main/development** version of Lazarus (or FPC). You can get Lazarus from GitLab repository. [[Getting Lazarus|Getting Lazarus development version]]. This is the native repository.
1411
15-```text
16-svn checkout --depth files https://github.com/fpc/Lazarus/branches all
17-cd all
18-svn update --set-depth infinity main
19-```
12+[![Warning-icon.png](/wiki-images/b/b2/Warning-icon.png)](</File:Warning-icon.png>)
2013
21-```text
22-svn checkout --depth files https://github.com/fpc/FPCSource/branches all
23-cd all
24-svn update --set-depth infinity main
25-```
14+**Warning:** **If you submit patches, do _not_ base them on stable versions of Lazarus/FPC. Typically the development version is very different from stable versions as many improvements and fixes have been applied by the developers**
2615
27-> **Warning:** **If you submit patches, do not base them on stable versions of Lazarus/FPC. Typically the development version is very different from stable versions as many improvements and fixes have been applied by the developers**
16+[^Note]: The term **"main/development version of Lazarus"** appears to mean minor version number 99 (i.e., currently version 4.99, at the time of this writing), as per <https://wiki.lazarus.freepascal.org/index.php/Version_Numbering#Lazarus_3.0_and_newer>.
2817
2918## Platform differences
3019
31-The instructions later assume you have opened a command prompt and moved (cd) to the directory of the repository. Here are the details :
20+The instructions later assume you have opened a command prompt and moved (cd) to the directory of the repository. Here are the details:
3221
3322### Windows
3423
35-Assuming you checked out Lazarus into C:\lazarus, open command prompt (cmd.exe) and type "cd \lazarus".
24+Assuming you checked out Lazarus into C:\lazarus, open command prompt (cmd.exe) and type "cd \lazarus".
3625
3726### *nix systems
3827
39-Assuming you checked out Lazarus into ~/lazarus, open terminal and type "cd ~/lazarus".
28+Assuming you checked out Lazarus into ~/lazarus, open terminal and type "cd ~/lazarus".
4029
41-## Creating a patch using SVN
30+## Creating a patch using Git
4231
43-``` bash
44-svn diff > mypatch.diff
32+First, develop your code in a separate branch. While your development branch is active, you can create patches of all your local commits by :
4533```
46-
47-This includes all changed files in the whole SVN repository.
48-
49-You can also define the individual files, to make sure no garbage is included, eg. :
50-
51-``` bash
52-svn diff ide/main.pp ideintf/objectinspector.pp > mypatch.diff
34+git format-patch main
5335```
5436
55-> **Note:** If using [TortoiseSVN](http://tortoisesvn.tigris.org/) on Windows, you can select the folder where Lazarus was checked out in Windows Explorer then right click to select TortoiseSVN-\>Create Patch...
56-
57-See also [[TortoiseSvn|TortoiseSvn#Troubleshooting]] if you have problems.
58-
59-## Creating a patch using Git
60-
61-First, develop your code in a separate branch! While your development branch is active, you can create patches of all your local commits by :
37+It creates a set of patches named like "0001-CommitMsg.patch", "0002-CommitMsg.patch" and so on.
6238
63-``` bash
64-git format-patch master
39+If you want all the changes in one patch, either combine the commits using "git rebase -i ..." or use the following command :
6540```
66-
67-It creates a set of patches named like "0001-CommitMsg.patch", "0002-CommitMsg.patch" and so on.
68-
69-If you want all the changes in one patch, either combine the commits using "git rebase -i ..." or use the following command :
70-
71-``` bash
72-git format-patch master --stdout > mypatch.patch
41+git format-patch main --stdout > mypatch.patch
7342```
7443
7544## Submitting the patch
7645
77-Now you have a patch. I'd suggest to look the file over to see if it looks ok (no unexpected changes).
46+Now you have a patch. I'd suggest to look the file over to see if it looks ok (no unexpected changes).
7847
79-The recommended way to submit a patch is through the [bug tracker](http://bugs.freepascal.org), see [[How do I create a bug report]] for details. If there is a report for the issue your patch fixes, use that, otherwise create a new issue. Upload the file to attach it to the issue.
48+The recommended way to submit a patch is through the [bug tracker](<http://bugs.freepascal.org>), see [[How do I create a bug report]] for details. If there is a report for the issue your patch fixes, use that, otherwise create a new issue. Upload the file to attach it to the issue.
8049
8150## Git
8251
83-The GitHub repository [1](https://github.com/graemeg/lazarus) is only a mirror and does not accept pull-requests.
52+The GitHub repository [[1]](<https://github.com/graemeg/lazarus>) is only a mirror and does not accept pull-requests.
8453
8554## Applying a patch
8655
87-This explains how to apply somebody else's patch to your local repository. You can test the patch by using the --dry-run toggle switch like this:
88-
89-``` bash
90-patch --dry-run < somepatch.diff
91-```
92-
93-The output of the patch program will be identical to the actual patching, only it does not alter the sourcecode files. Very handy for testing, without the possibility to screw up your source.
94-
95-### A patch made with "svn diff"
96-
97-To do the final patching, use the following commandline:
98-
99-``` bash
100-patch < somepatch.diff
56+This explains how to apply somebody else's patch to your local repository. You can test the patch by using the --dry-run toggle switch like this:
10157```
102-
103-If that doesn't work because the path layout of your environment is different from the environment where the patch was created, you can tell *patch* to strip out all path information:
104-
105-``` bash
106-patch -p0 < somepatch.diff
58+patch --dry-run < somepatch.diff
10759```
10860
109-Any GUI tool for diffs on Windows can handle these patches, too, including TortoiseMerge.
61+The output of the patch program will be identical to the actual patching, only it does not alter the sourcecode files. Very handy for testing, without the possibility to screw up your source.
11062
11163### A patch made with "git format-patch"
11264
11365#### Git
11466
115-Git itself applies the patch like this :
116-
117-``` bash
67+Git itself applies the patch like this :
68+```
11869git apply 0001-gitpatch.patch
11970```
12071
12172#### patch
12273
123-The "patch" command now supports git format patches with -p1. This is tested with patch v.2.6.1 on Linux, old versions may not support it.
124-
125-``` bash
74+The "patch" command now supports git format patches with -p1. This is tested with patch v.2.6.1 on Linux, old versions may not support it.
75+```
12676patch -p1 < 0001-gitpatch.patch
12777```
12878
129-"patch" is available for Windows, too, but there are also GUI tools for the job.
79+"patch" is available for Windows, too, but there are also GUI tools for the job.
13080
13181#### TortoiseMerge
13282
133-TortoiseMerge supports the Git format patch without problems. It is installed together with Tortoise SVN but is not integrated in explorer. It must be opened from the Start menu.
83+TortoiseMerge supports the Git format patch without problems. It is installed together with Tortoise SVN but is not integrated in explorer. It must be opened from the Start menu.
13484
135-ToDo: add more GUI tools that support Git format patches
85+ToDo: add more GUI tools that support Git format patches
13686
13787### Troubleshooting
13888
139-Finally, patches may have a Unix/Linux line ending (LF) while your local file has Windows (CR+LF) line endings or vice versa. You'll have to convert the patch file before applying on Windows at least, as the supplied patch.exe is picky about line endings.
140-
141-On Windows, the patch.exe supplied with FPC/Lazarus is very picky; you may have better luck with the patch.exe supplied by Git:
89+Finally, patches may have a Unix/Linux line ending (LF) while your local file has Windows (CR+LF) line endings or vice versa. You'll have to convert the patch file before applying on Windows at least, as the supplied patch.exe is picky about line endings.
14290
143-```dos
91+On Windows, the patch.exe supplied with FPC/Lazarus is very picky; you may have better luck with the patch.exe supplied by Git:
92+```
14493"C:\Program Files (x86)\Git\bin\patch.exe" -p0 < mypatch.diff
14594```
14695
147-... or the svn patch command available since SVN 1.7.
148-
14996## See also
15097
151-- [[How do I create a bug report]] general information on submitting bugs, what should be covered in a bug report, and using the bug tracker.
152-- [[Tips on writing bug reports]] detailed information on what should be covered in a bug report.
153-- [[Database bug reporting]] Specific info and sample programs for database bugs
154-- [[Moderating the bug tracker]]
98+ * [[How do I create a bug report]] general information on submitting bugs, what should be covered in a bug report, and using the bug tracker.
99+ * [[Tips on writing bug reports]] detailed information on what should be covered in a bug report.
100+ * [[Database bug reporting]] Specific info and sample programs for database bugs
101+ * [[Moderating the bug tracker]]
155102
156103---
157-*From the Free Pascal wiki, page "Creating A Patch", as it stood on 2022-01-13 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
104+*From the Free Pascal wiki, page "Creating A Patch", as the Internet Archive kept it on 2025-12-20, last changed on 2025-02-23. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history