1 <?xml version="1.0" encoding="UTF-8"?>
\r
2 <!DOCTYPE sect1 SYSTEM "../../../dtd/dblite.dtd">
\r
3 <sect1 id="tsvn-dug-patch">
\r
4 <title>Creating and Applying Patches and Pull Requests</title>
\r
6 <primary>patch</primary>
\r
9 <primary>diff</primary>
\r
12 <primary>unified diff</primary>
\r
15 <primary>pull request</primary>
\r
18 <primary>request pull</primary>
\r
20 <?dbhh topicname="HIDD_FORMAT_PATCH"?>
\r
21 <?dbhh topicname="HIDD_APPLY_PATCH_LIST"?>
\r
22 <?dbhh topicname="HIDD_CREATEPATCH"?>
\r
23 <?dbhh topicname="HIDD_REQUESTPULL"?>
\r
24 <?dbhh topicname="HIDD_SENDMAIL"?>
\r
26 For open source projects (like this one) everyone has read
\r
27 access to the (main/public) repository, and anyone can make a contribution
\r
28 to the project. So how are those contributions controlled?
\r
29 If just anyone could commit changes this this central repository, the project would be permanently
\r
30 unstable and probably permanently broken. In this situation the
\r
31 change is managed by submitting a <firstterm>patch</firstterm> file or a <firstterm>pull request</firstterm>
\r
32 to the development team, who do have write access.
\r
33 They can review the changes first, and then either submit it to the
\r
34 main repository or reject it back to the author.
\r
37 Patch files are simply Unified-Diff files showing the differences
\r
38 between your working tree and the base revision.
\r
41 A pull request is an request to another repository owner to <link linkend="tsvn-dug-pull">pull</link>
\r
42 changes from your repository. I.e. you must have access to a public repository where you can
\r
43 <link linkend="tsvn-dug-push">push</link> your changes (normally a special branch).
\r
45 <sect2 id="tsvn-dug-patch-createpatchserial">
\r
46 <title>Creating a Patch Serial</title>
\r
48 First you need to make <emphasis>and test</emphasis> your changes.
\r
49 Then you commit your changes via
\r
51 <guimenu>TortoiseGit</guimenu>
\r
52 <guimenuitem>Commit...</guimenuitem>
\r
54 on the parent folder, enter a good commit message. After that select
\r
56 <guimenu>TortoiseGit</guimenu>
\r
57 <guimenuitem>Create Patch Serial...</guimenuitem>
\r
59 and choose the correct options to include your changes/commits.
\r
61 <figure id="tsvn-dug-patch-dia-1">
\r
62 <title>The Create Patch dialog</title>
\r
63 <graphic fileref="../images/CreatePatch.png"/>
\r
66 <guilabel>Directory</guilabel> is output directory of patch.
\r
67 Patch file name will be created by commit subject.
\r
70 <guilabel>Since</guilabel> create patch from point. You can click
\r
71 <guibutton>...</guibutton> to launch refbrowse dialog to choose branch or tag.
\r
74 <guilabel>Number Commits</guilabel> is limited how much patch will created.
\r
77 <guilabel>Range</guilabel> is choose range of <guilabel>from</guilabel> commit
\r
78 to <guilabel>to</guilabel>. You can click <guibutton>...</guibutton> to launch
\r
79 log dialog to choose commit.
\r
82 <guilabel>Send Mail after create</guilabel> launch send mail dialog after patches created (see <xref linkend="tsvn-dug-patch-sendpatches"/>).
\r
85 You can find more information at <xref linkend="git-format-patch(1)"/>.
\r
89 Here is different to TortoiseSVN: In TortoiseSVN you directly create a patch instead of committing
\r
90 your changes and create a patch of the commits afterwards. To generate a patch containing the uncommitted,
\r
91 but staged, changes click on <guibutton>Save unified diff since HEAD</guibutton>.
\r
95 <sect2 id="tsvn-dug-patch-sendpatches">
\r
96 <title>Sending patches by mail</title>
\r
98 In order to send patches to the upstream authors, select the patch files and then right click on them and select
\r
100 <guimenu>TortoiseGit</guimenu>
\r
101 <guimenuitem>Send Mail...</guimenuitem>
\r
105 <figure id="tsvn-dug-patch-dia-sendpatches">
\r
106 <title>The Send Patches Dialog</title>
\r
107 <graphic fileref="../images/SendPatch.png"/>
\r
111 First you need to enter the receipient(s) (<guilabel>To</guilabel> and/or <guilabel>CC</guilabel>).
\r
114 Depending on the mail type (<guilabel>Patch as attachment</guilabel> or <guilabel>Combine One Mail</guilabel>)
\r
115 you have to enter a <guilabel>Subject</guilabel> for the mail.
\r
118 <guilabel>Patch as attachment</guilabel> adds the patch(es) as attachment(s) to the mail(s) instead of inlining them.
\r
121 <guilabel>Combine One Mail</guilabel> adds all patches to one mail. You have to enter a <guilabel>Subject</guilabel>
\r
122 for the mail in this case.
\r
125 <guilabel>Use MAPI</guilabel> uses the Windows MAPI interface for sending the mails. This requires a MUA to be configured on your system.
\r
129 If you do not select <guilabel>Use MAPI</guilabel> mails are delivered via SMTP directly to the destination MTA.
\r
130 This might be problematic if your ISP blocks outgoing SMTP connections (port 25) or you have a dialup internet connection.
\r
131 In the ladder case the destination MTA might not accept your mails or marks them as SPAM.
\r
135 <sect2 id="tsvn-dug-patch-applysinglepatch">
\r
136 <title>Applying a single Patch File</title>
\r
138 Patch files are applied to your working tree. This should be done
\r
139 from the same folder level as was used to create the patch.
\r
140 If you are not sure what this is, just look at the first line of
\r
141 the patch file. For example, if the first file being worked on was
\r
142 <filename>doc/source/english/chapter1.xml</filename>
\r
143 and the first line in the patch file is
\r
144 <filename>Index: english/chapter1.xml</filename>
\r
145 then you need to apply the patch to the
\r
146 <filename>doc/source/</filename> folder.
\r
147 However, provided you are in the correct working tree, if you
\r
148 pick the wrong folder level, TortoiseGit will notice and suggest the
\r
152 From the context menu for a patch file (<filename>.patch</filename>
\r
153 or <filename>.diff</filename> extension), click on
\r
155 <guimenu>TortoiseGit</guimenu>
\r
156 <guimenuitem>Review/apply single patch...</guimenuitem>
\r
158 You might be prompted to enter a working tree location:
\r
159 <figure id="tsvn-dug-choose-repository">
\r
160 <title>The Choose Repository Dialog</title>
\r
161 <graphic fileref="../images/ChooseRepository.png"/>
\r
163 If the working tree is found, TortoiseMerge is launched to show and apply differences.
\r
166 <sect2 id="tsvn-dug-patch-applaypatchserial">
\r
167 <title>Applying a Patch Serial</title>
\r
169 Patch files are applied to your working tree. For this copy the patch (or mbox)
\r
170 files to the root of your working tree.
\r
173 From the context menu for that folder (or all marked patch files), click on
\r
175 <guimenu>TortoiseGit</guimenu>
\r
176 <guimenuitem>Apply Patch Serial...</guimenuitem>
\r
178 <figure id="tsvn-dug-apply-patch">
\r
179 <title>The Apply Patch Dialog</title>
\r
180 <graphic fileref="../images/ApplyPatch.png"/>
\r
185 <guibutton>Add</guibutton> Insert patch
\r
188 <guibutton>Up</guibutton> Move chosen patch up.
\r
191 <guibutton>Down</guibutton> Move chosen patch down.
\r
194 <guibutton>Remove</guibutton> Remove the chosen patch.
\r
197 <guibutton>Apply</guibutton> Start applying the patches one by one.
\r
200 You can find more information at <xref linkend="git-am(1)"/>.
\r
203 <sect2 id="tsvn-dug-patch-pullrequest">
\r
204 <title>Creating a pull request</title>
\r
206 Apart from sending patches (or patch serials) to other developers,
\r
207 there are two ways to ask other people to integrate your changes
\r
208 into their repositories.
\r
211 <emphasis>First:</emphasis> After pushing your changes to a (public)
\r
212 repository, you just provide other people the URL of your repository
\r
213 and the name of the branch or the revision id.
\r
214 E.g.: <literal>git://example.com/repo.git BRANCHNAME</literal>
\r
217 <emphasis>Second:</emphasis> After pushing your changes to a (public)
\r
218 repository, you can create a standardized (quite formal) request for other
\r
219 people to pull your changes and integrate them into their repository.
\r
220 The format pull request consists of a list of all commits and provides
\r
221 some statistics about changed files, so that other people can can a quick overview.
\r
224 Select <guibutton>Request pull</guibutton> on the progress dialog after pushing your changes.
\r
225 <figure id="tsvn-dug-request-pull">
\r
226 <title>The Request Pull Dialog</title>
\r
227 <graphic fileref="../images/RequestPull.png"/>
\r
232 <term><guilabel>Start</guilabel></term>
\r
235 This should be the revision on which your changes are based on.
\r
240 <term><guilabel>URL</guilabel></term>
\r
243 The public URL to your repository, which can be access
\r
244 by the people who shall pull your changes.
\r
249 <term><guilabel>End</guilabel></term>
\r
252 This should be the branch name or revision id of the end of your commits.
\r
258 After clicking on <guibutton>OK</guibutton> the pull request is created. Just copy it
\r
259 and pass it to other people who you want to pull your changes.
\r
262 You can find more information at <xref linkend="git-request-pull(1)"/>.
\r