15b917f78601fe0446dfb40bc5a055893b3804b7
[git.git] / Documentation / SubmittingPatches
1 I started reading over the SubmittingPatches document for Linux
2 kernel, primarily because I wanted to have a document similar to
3 it for the core GIT to make sure people understand what they are
4 doing when they write "Signed-off-by" line.
5
6 But the patch submission requirements are a lot more relaxed
7 here, because the core GIT is thousand times smaller ;-).  So
8 here is only the relevant bits.
9
10
11 (1) Make separate commits for logically separate changes.
12
13 Unless your patch is really trivial, you should not be sending
14 out a patch that was generated between your working tree and
15 your commit head.  Instead, always make a commit with complete
16 commit message and generate a series of patches from your
17 repository.  It is a good discipline.
18
19 Describe the technical detail of the change(s).
20
21 If your description starts to get long, that's a sign that you
22 probably need to split up your commit to finer grained pieces.
23
24
25 (2) Generate your patch using git/cogito out of your commits.
26
27 git diff tools generate unidiff which is the preferred format.
28 You do not have to be afraid to use -M option to "git diff" or
29 "git format-patch", if your patch involves file renames.  The
30 receiving end can handle them just fine.
31
32 Please make sure your patch does not include any extra files
33 which do not belong in a patch submission.  Make sure to review
34 your patch after generating it, to ensure accuracy.  Before
35 sending out, please make sure it cleanly applies to the "master"
36 branch head.
37
38
39 (3) Sending your patches.
40
41 People on the git mailing list needs to be able to read and
42 comment on the changes you are submitting.  It is important for
43 a developer to be able to "quote" your changes, using standard
44 e-mail tools, so that they may comment on specific portions of
45 your code.  For this reason, all patches should be submitting
46 e-mail "inline".  WARNING: Be wary of your MUAs word-wrap
47 corrupting your patch.  Do not cut-n-paste your patch.
48
49 It is common convention to prefix your subject line with
50 [PATCH].  This lets people easily distinguish patches from other
51 e-mail discussions.
52
53 "git format-patch" command follows the best current practice to
54 format the body of an e-mail message.  At the beginning of the
55 patch should come your commit message, ending with the
56 Signed-off-by: lines, and a line that consists of three dashes,
57 followed by the diffstat information and the patch itself.  If
58 you are forwarding a patch from somebody else, optionally, at
59 the beginning of the e-mail message just before the commit
60 message starts, you can put a "From: " line to name that person.
61
62 You often want to add additional explanation about the patch,
63 other than the commit message itself.  Place such "cover letter"
64 material between the three dash lines and the diffstat.
65
66 Do not attach the patch as a MIME attachment, compressed or not.
67 Do not let your e-mail client send quoted-printable.  Many
68 popular e-mail applications will not always transmit a MIME
69 attachment as plain text, making it impossible to comment on
70 your code.  A MIME attachment also takes a bit more time to
71 process.  This does not decrease the likelihood of your
72 MIME-attached change being accepted, but it makes it more likely
73 that it will be postponed.
74
75 Exception:  If your mailer is mangling patches then someone may ask
76 you to re-send them using MIME.
77
78 Note that your maintainer does not subscribe to the git mailing
79 list (he reads it via mail-to-news gateway).  If your patch is
80 for discussion first, send it "To:" the mailing list, and
81 optoinally "cc:" him.  If it is trivially correct or after list
82 discussion reached consensus, send it "To:" the maintainer and
83 optionally "cc:" the list.
84
85
86 (6) Sign your work
87
88 To improve tracking of who did what, we've borrowed the
89 "sign-off" procedure from the Linux kernel project on patches
90 that are being emailed around.  Although core GIT is a lot
91 smaller project it is a good discipline to follow it.
92
93 The sign-off is a simple line at the end of the explanation for
94 the patch, which certifies that you wrote it or otherwise have
95 the right to pass it on as a open-source patch.  The rules are
96 pretty simple: if you can certify the below:
97
98         Developer's Certificate of Origin 1.1
99
100         By making a contribution to this project, I certify that:
101
102         (a) The contribution was created in whole or in part by me and I
103             have the right to submit it under the open source license
104             indicated in the file; or
105
106         (b) The contribution is based upon previous work that, to the best
107             of my knowledge, is covered under an appropriate open source
108             license and I have the right under that license to submit that
109             work with modifications, whether created in whole or in part
110             by me, under the same open source license (unless I am
111             permitted to submit under a different license), as indicated
112             in the file; or
113
114         (c) The contribution was provided directly to me by some other
115             person who certified (a), (b) or (c) and I have not modified
116             it.
117
118         (d) I understand and agree that this project and the contribution
119             are public and that a record of the contribution (including all
120             personal information I submit with it, including my sign-off) is
121             maintained indefinitely and may be redistributed consistent with
122             this project or the open source license(s) involved.
123
124 then you just add a line saying
125
126         Signed-off-by: Random J Developer <random@developer.example.org>
127
128 Some people also put extra tags at the end.  They'll just be ignored for
129 now, but you can do this to mark internal company procedures or just
130 point out some special detail about the sign-off.
131
132
133 ------------------------------------------------
134 MUA specific hints
135
136 Some of patches I receive or pick up from the list share common
137 patterns of breakage.  Please make sure your MUA is set up
138 properly not to corrupt whitespaces.  Here are two common ones
139 I have seen:
140
141 * Empty context lines that do not have _any_ whitespace.
142
143 * Non empty context lines that have one extra whitespace at the
144   beginning.
145
146
147 Pine
148 ----
149
150 (Johannes Schindelin)
151
152 I don't know how many people still use pine, but for those poor
153 souls it may be good to mention that the quell-flowed-text is
154 needed for recent versions.
155
156 ... the "no-strip-whitespace-before-send" option, too. AFAIK it
157 was introduced in 4.60.
158
159 (Linus Torvalds)
160
161 And 4.58 needs at least this.
162
163 ---
164 diff-tree 8326dd8350be64ac7fc805f6563a1d61ad10d32c (from e886a61f76edf5410573e92e38ce22974f9c40f1)
165 Author: Linus Torvalds <torvalds@g5.osdl.org>
166 Date:   Mon Aug 15 17:23:51 2005 -0700
167
168     Fix pine whitespace-corruption bug
169
170     There's no excuse for unconditionally removing whitespace from
171     the pico buffers on close.
172
173 diff --git a/pico/pico.c b/pico/pico.c
174 --- a/pico/pico.c
175 +++ b/pico/pico.c
176 @@ -219,7 +219,9 @@ PICO *pm;
177             switch(pico_all_done){      /* prepare for/handle final events */
178               case COMP_EXIT :          /* already confirmed */
179                 packheader();
180 +#if 0
181                 stripwhitespace();
182 +#endif
183                 c |= COMP_EXIT;
184                 break;
185  
186
187
188 Thunderbird
189 -----------
190
191 (A Large Angry SCM)
192
193 Here are some hints on how to successfully submit patches inline using
194 Thunderbird.
195
196 This recipe appears to work with the current [*1*] Thunderbird from Suse.
197
198 The following Thunderbird extensions are needed:
199         AboutConfig 0.5
200                 http://aboutconfig.mozdev.org/
201         External Editor 0.5.4
202                 http://extensionroom.mozdev.org/more-info/exteditor
203
204 1) Prepare the patch as a text file using your method of choice.
205
206 2) Before opening a compose window, use Edit->Account Settings to
207 uncheck the "Compose messages in HTML format" setting in the
208 "Composition & Addressing" panel of the account to be used to send the
209 patch. [*2*]
210
211 3) In the main Thunderbird window, _before_ you open the compose window
212 for the patch, use Tools->about:config to set the following to the
213 indicated values:
214         mailnews.send_plaintext_flowed  => false
215         mailnews.wraplength             => 999
216
217 4) Open a compose window and click the external editor icon.
218
219 5) In the external editor window, read in the patch file and exit the
220 editor normally.
221
222 6) Back in the compose window: Add whatever other text you wish to the
223 message, complete the addressing and subject fields, and press send.
224
225 7) Optionally, undo the about:config/account settings changes made in
226 steps 2 & 3.
227
228
229 [Footnotes]
230 *1* Version 1.0 (20041207) from the MozillaThunderbird-1.0-5 rpm of Suse
231 9.3 professional updates.
232
233 *2* It may be possible to do this with about:config and the following
234 settings but I haven't tried, yet.
235         mail.html_compose                       => false
236         mail.identity.default.compose_html      => false
237         mail.identity.id?.compose_html          => false
238
239
240