blob: 82d2c253d1c9523441483e0b047633c3e739ac0a [file] [log] [blame]
Git Development Community1a6964c2009-09-29 16:47:03 -07001Short Version:
2
3 - Make small logical changes.
4 - Provide a meaningful commit message.
5
6 - Include your Signed-Off-By line to note you agree with the
7 Developer's Certificate of Origin (see below).
8 - Make sure all code is under the proper license:
9
10 3-clause BSD
11
12 - Use a subject prefix of "[PATCH JGIT ...]" when sending any
13 patches directly by email.
14
15 - Send by email to the maintainers, cc'ing the git mailing list
16 which is currently used for both Git and JGit:
17
18 maintainers : "Shawn O. Pearce" <spearce@spearce.org>
19 Robin Rosenberg <robin.rosenberg@dewire.com>
20
21 git list : git@vger.kernel.org
22
23 git list info : http://vger.kernel.org/vger-lists.html#git
24
25Long Version:
26
27I wanted a file describing how to submit patches for JGit,
28so I started with the one found in the core Git distribution
29(Documentation/SubmittingPatches), which itself was based on the
30patch submission guidelines for the Linux kernel.
31
32However there are some differences, so please review and familiarize
33yourself with the following relevant bits:
34
35
36(1) Make separate commits for logically separate changes.
37
38Unless your patch is really trivial, you should not be sending
39out a patch that was generated between your working tree and your
40commit head. Instead, always make a commit with complete commit
41message and generate a series of patches from your repository.
42It is a good discipline.
43
44Describe the technical detail of the change(s).
45
46If your description starts to get too long, that's a sign that you
47probably need to split up your commit to finer grained pieces.
48
49I am very picky about formatting. Make sure your final version
50of every file was formatted using the Eclipse code formatter
51using the project specific settings (Properties->Java Code
52Style->Formatter->"Java Conventions [built-in]").
53
54
55(2) Generate your patch using git tools out of your commits.
56
57git based diff tools (git, and StGIT included) generate unidiff,
58which is the only acceptable format.
59
60You do not have to be afraid to use -M option to "git diff" or "git
61format-patch", if your patch involves file renames. The receiving
62end can handle them just fine.
63
64Please make sure your patch does not include any extra files which
65do not belong in a patch submission. Make sure to review your
66patch after generating it, to ensure accuracy. Before sending out,
67please make sure it cleanly applies to the "master" branch head.
68
69
70(3) Sending your patches.
71
72People on the git mailing list need to be able to read and comment
73on the changes you are submitting. It is important for a developer
74to be able to "quote" your changes, using standard e-mail tools, so
75that they may comment on specific portions of your code. For this
76reason, all patches should be submitted "inline". WARNING: Be wary
77of your MUAs word-wrap corrupting your patch. Do not cut-n-paste
78your patch; you can lose tabs that way if you are not careful.
79
80It is a common convention to prefix your subject line with [PATCH].
81This lets people easily distinguish patches from other e-mail
82discussions.
83
84"git format-patch" command follows the best current practice to
85format the body of an e-mail message. At the beginning of the patch
86should come your commit message, ending with the Signed-off-by:
87lines, and a line that consists of three dashes, followed by the
88diffstat information and the patch itself. If you are forwarding a
89patch from somebody else, optionally, at the beginning of the e-mail
90message just before the commit message starts, you can put a "From:
91" line to name that person.
92
93You often want to add additional explanation about the patch,
94other than the commit message itself. Place such "cover letter"
95material between the three dash lines and the diffstat.
96
97Do not attach the patch as a MIME attachment, compressed or not.
98Do not let your e-mail client send quoted-printable. Do not let your
99e-mail client send format=flowed which would destroy whitespaces
100in your patches. Many popular e-mail applications will not always
101transmit a MIME attachment as plain text, making it impossible to
102comment on your code. A MIME attachment also takes a bit more
103time to process. This does not decrease the likelihood of your
104MIME-attached change being accepted, but it makes it more likely
105that it will be postponed.
106
107Exception: If your mailer is mangling patches then someone may ask
108you to re-send them using MIME, that is OK.
109
110Do not PGP sign your patch, at least for now. Most likely, your
111maintainer or other people on the list would not have your PGP
112key and would not bother obtaining it anyway. Your patch is not
113judged by who you are; a good patch from an unknown origin has a
114far better chance of being accepted than a patch from a known,
115respected origin that is done poorly or does incorrect things.
116
117If you really really really really want to do a PGP signed
118patch, format it as "multipart/signed", not a text/plain message
119that starts with '-----BEGIN PGP SIGNED MESSAGE-----'. That is
120not a text/plain, it's something else.
121
122Note that your maintainer does not necessarily read everything
123on the git mailing list. If your patch is for discussion first,
124send it "To:" the mailing list, and optionally "cc:" him. If it
125is trivially correct or after the list reached a consensus, send it
126"To:" the maintainer and optionally "cc:" the list.
127
128
129(4) Check the license
130
131JGit is licensed under the 3-clause (new-style) BSD.
132
133Because of this licensing model *every* file within the project
134*must* list which license covers it in the header of the file.
135Any new contributions to an existing file *must* be submitted under
136the current license of that file. Any new files *must* clearly
137indicate which license they are provided under in the file header.
138
139Please verify that you are legally allowed and willing to submit your
140changes under the license covering each file *prior* to submitting
141your patch. It is virtually impossible to remove a patch once it
142has been applied and pushed out.
143
144
145(5) Sign your work
146
147To improve tracking of who did what, we've borrowed the "sign-off"
148procedure from the Linux kernel project on patches that are being
149emailed around. Although JGit is a lot smaller project it is
150a good discipline to follow it.
151
152The sign-off is a simple line at the end of the explanation for the
153patch, which certifies that you wrote it or otherwise have the right
154to pass it on as a open-source patch. The rules are pretty simple:
155if you can certify the below:
156
157 Developer's Certificate of Origin 1.1
158
159 By making a contribution to this project, I certify that:
160
161 (a) The contribution was created in whole or in part by me
162 and I have the right to submit it under the open source
163 license indicated in the file; or
164
165 (b) The contribution is based upon previous work that, to the
166 best of my knowledge, is covered under an appropriate
167 open source license and I have the right under that
168 license to submit that work with modifications, whether
169 created in whole or in part by me, under the same open
170 source license (unless I am permitted to submit under
171 a different license), as indicated in the file; or
172
173 (c) The contribution was provided directly to me by some
174 other person who certified (a), (b) or (c) and I have
175 not modified it.
176
177 (d) I understand and agree that this project and the
178 contribution are public and that a record of the
179 contribution (including all personal information I
180 submit with it, including my sign-off) is maintained
181 indefinitely and may be redistributed consistent with
182 this project or the open source license(s) involved.
183
184then you just add a line saying
185
186 Signed-off-by: Random J Developer <random@developer.example.org>
187
188This line can be automatically added by git if you run the git-commit
189command with the -s option.
190
191Some people also put extra tags at the end. They'll just be ignored
192for now, but you can do this to mark internal company procedures
193or just point out some special detail about the sign-off.
194
195
196------------------------------------------------
197MUA specific hints
198
199Some of patches I receive or pick up from the list share common
200patterns of breakage. Please make sure your MUA is set up
201properly not to corrupt whitespaces. Here are two common ones
202I have seen:
203
204* Empty context lines that do not have _any_ whitespace.
205
206* Non empty context lines that have one extra whitespace at the
207 beginning.
208
209One test you could do yourself if your MUA is set up correctly is:
210
211* Send the patch to yourself, exactly the way you would, except
212 To: and Cc: lines, which would not contain the list and
213 maintainer address.
214
215* Save that patch to a file in UNIX mailbox format. Call it say
216 a.patch.
217
218* Try to apply to the tip of the "master" branch from the
219 egit.git public repository:
220
221 $ git fetch git://repo.or.cz/egit.git master:test-apply
222 $ git checkout test-apply
223 $ git reset --hard
224 $ git am a.patch
225
226If it does not apply correctly, there can be various reasons.
227
228* Your patch itself does not apply cleanly. That is _bad_ but
229 does not have much to do with your MUA. Please rebase the
230 patch appropriately.
231
232* Your MUA corrupted your patch; applymbox would complain that
233 the patch does not apply. Look at .dotest/ subdirectory and
234 see what 'patch' file contains and check for the common
235 corruption patterns mentioned above.
236
237* While you are at it, check what are in 'info' and
238 'final-commit' files as well. If what is in 'final-commit' is
239 not exactly what you would want to see in the commit log
240 message, it is very likely that your maintainer would end up
241 hand editing the log message when he applies your patch.
242 Things like "Hi, this is my first patch.\n", if you really
243 want to put in the patch e-mail, should come after the
244 three-dash line that signals the end of the commit message.
245
246
247Pine
248----
249
250(Johannes Schindelin)
251
252I don't know how many people still use pine, but for those poor
253souls it may be good to mention that the quell-flowed-text is
254needed for recent versions.
255
256... the "no-strip-whitespace-before-send" option, too. AFAIK it
257was introduced in 4.60.
258
259(Linus Torvalds)
260
261And 4.58 needs at least this.
262
263---
264diff-tree 8326dd8350be64ac7fc805f6563a1d61ad10d32c (from e886a61f76edf5410573e92e38ce22974f9c40f1)
265Author: Linus Torvalds <torvalds@g5.osdl.org>
266Date: Mon Aug 15 17:23:51 2005 -0700
267
268 Fix pine whitespace-corruption bug
269
270 There's no excuse for unconditionally removing whitespace from
271 the pico buffers on close.
272
273diff --git a/pico/pico.c b/pico/pico.c
274--- a/pico/pico.c
275+++ b/pico/pico.c
276@@ -219,7 +219,9 @@ PICO *pm;
277 switch(pico_all_done){ /* prepare for/handle final events */
278 case COMP_EXIT : /* already confirmed */
279 packheader();
280+#if 0
281 stripwhitespace();
282+#endif
283 c |= COMP_EXIT;
284 break;
285
286
287(Daniel Barkalow)
288
289> A patch to SubmittingPatches, MUA specific help section for
290> users of Pine 4.63 would be very much appreciated.
291
292Ah, it looks like a recent version changed the default behavior to do the
293right thing, and inverted the sense of the configuration option. (Either
294that or Gentoo did it.) So you need to set the
295"no-strip-whitespace-before-send" option, unless the option you have is
296"strip-whitespace-before-send", in which case you should avoid checking
297it.
298
299
300Thunderbird
301-----------
302
303(A Large Angry SCM)
304
305Here are some hints on how to successfully submit patches inline using
306Thunderbird.
307
308This recipe appears to work with the current [*1*] Thunderbird from Suse.
309
310The following Thunderbird extensions are needed:
311 AboutConfig 0.5
312 http://aboutconfig.mozdev.org/
313 External Editor 0.7.2
314 http://globs.org/articles.php?lng=en&pg=8
315
3161) Prepare the patch as a text file using your method of choice.
317
3182) Before opening a compose window, use Edit->Account Settings to
319uncheck the "Compose messages in HTML format" setting in the
320"Composition & Addressing" panel of the account to be used to send the
321patch. [*2*]
322
3233) In the main Thunderbird window, _before_ you open the compose window
324for the patch, use Tools->about:config to set the following to the
325indicated values:
326 mailnews.send_plaintext_flowed => false
327 mailnews.wraplength => 0
328
3294) Open a compose window and click the external editor icon.
330
3315) In the external editor window, read in the patch file and exit the
332editor normally.
333
3346) Back in the compose window: Add whatever other text you wish to the
335message, complete the addressing and subject fields, and press send.
336
3377) Optionally, undo the about:config/account settings changes made in
338steps 2 & 3.
339
340
341[Footnotes]
342*1* Version 1.0 (20041207) from the MozillaThunderbird-1.0-5 rpm of Suse
3439.3 professional updates.
344
345*2* It may be possible to do this with about:config and the following
346settings but I haven't tried, yet.
347 mail.html_compose => false
348 mail.identity.default.compose_html => false
349 mail.identity.id?.compose_html => false
350
351
352
353Gnus
354----
355
356'|' in the *Summary* buffer can be used to pipe the current
357message to an external program, and this is a handy way to drive
358"git am". However, if the message is MIME encoded, what is
359piped into the program is the representation you see in your
360*Article* buffer after unwrapping MIME. This is often not what
361you would want for two reasons. It tends to screw up non ASCII
362characters (most notably in people's names), and also
363whitespaces (fatal in patches). Running 'C-u g' to display the
364message in raw form before using '|' to run the pipe can work
365this problem around.
366