Git Development Community | 1a6964c | 2009-09-29 16:47:03 -0700 | [diff] [blame] | 1 | Short 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 | |
| 25 | Long Version: |
| 26 | |
| 27 | I wanted a file describing how to submit patches for JGit, |
| 28 | so I started with the one found in the core Git distribution |
| 29 | (Documentation/SubmittingPatches), which itself was based on the |
| 30 | patch submission guidelines for the Linux kernel. |
| 31 | |
| 32 | However there are some differences, so please review and familiarize |
| 33 | yourself with the following relevant bits: |
| 34 | |
| 35 | |
| 36 | (1) Make separate commits for logically separate changes. |
| 37 | |
| 38 | Unless your patch is really trivial, you should not be sending |
| 39 | out a patch that was generated between your working tree and your |
| 40 | commit head. Instead, always make a commit with complete commit |
| 41 | message and generate a series of patches from your repository. |
| 42 | It is a good discipline. |
| 43 | |
| 44 | Describe the technical detail of the change(s). |
| 45 | |
| 46 | If your description starts to get too long, that's a sign that you |
| 47 | probably need to split up your commit to finer grained pieces. |
| 48 | |
| 49 | I am very picky about formatting. Make sure your final version |
| 50 | of every file was formatted using the Eclipse code formatter |
| 51 | using the project specific settings (Properties->Java Code |
| 52 | Style->Formatter->"Java Conventions [built-in]"). |
| 53 | |
| 54 | |
| 55 | (2) Generate your patch using git tools out of your commits. |
| 56 | |
| 57 | git based diff tools (git, and StGIT included) generate unidiff, |
| 58 | which is the only acceptable format. |
| 59 | |
| 60 | You do not have to be afraid to use -M option to "git diff" or "git |
| 61 | format-patch", if your patch involves file renames. The receiving |
| 62 | end can handle them just fine. |
| 63 | |
| 64 | Please make sure your patch does not include any extra files which |
| 65 | do not belong in a patch submission. Make sure to review your |
| 66 | patch after generating it, to ensure accuracy. Before sending out, |
| 67 | please make sure it cleanly applies to the "master" branch head. |
| 68 | |
| 69 | |
| 70 | (3) Sending your patches. |
| 71 | |
| 72 | People on the git mailing list need to be able to read and comment |
| 73 | on the changes you are submitting. It is important for a developer |
| 74 | to be able to "quote" your changes, using standard e-mail tools, so |
| 75 | that they may comment on specific portions of your code. For this |
| 76 | reason, all patches should be submitted "inline". WARNING: Be wary |
| 77 | of your MUAs word-wrap corrupting your patch. Do not cut-n-paste |
| 78 | your patch; you can lose tabs that way if you are not careful. |
| 79 | |
| 80 | It is a common convention to prefix your subject line with [PATCH]. |
| 81 | This lets people easily distinguish patches from other e-mail |
| 82 | discussions. |
| 83 | |
| 84 | "git format-patch" command follows the best current practice to |
| 85 | format the body of an e-mail message. At the beginning of the patch |
| 86 | should come your commit message, ending with the Signed-off-by: |
| 87 | lines, and a line that consists of three dashes, followed by the |
| 88 | diffstat information and the patch itself. If you are forwarding a |
| 89 | patch from somebody else, optionally, at the beginning of the e-mail |
| 90 | message just before the commit message starts, you can put a "From: |
| 91 | " line to name that person. |
| 92 | |
| 93 | You often want to add additional explanation about the patch, |
| 94 | other than the commit message itself. Place such "cover letter" |
| 95 | material between the three dash lines and the diffstat. |
| 96 | |
| 97 | Do not attach the patch as a MIME attachment, compressed or not. |
| 98 | Do not let your e-mail client send quoted-printable. Do not let your |
| 99 | e-mail client send format=flowed which would destroy whitespaces |
| 100 | in your patches. Many popular e-mail applications will not always |
| 101 | transmit a MIME attachment as plain text, making it impossible to |
| 102 | comment on your code. A MIME attachment also takes a bit more |
| 103 | time to process. This does not decrease the likelihood of your |
| 104 | MIME-attached change being accepted, but it makes it more likely |
| 105 | that it will be postponed. |
| 106 | |
| 107 | Exception: If your mailer is mangling patches then someone may ask |
| 108 | you to re-send them using MIME, that is OK. |
| 109 | |
| 110 | Do not PGP sign your patch, at least for now. Most likely, your |
| 111 | maintainer or other people on the list would not have your PGP |
| 112 | key and would not bother obtaining it anyway. Your patch is not |
| 113 | judged by who you are; a good patch from an unknown origin has a |
| 114 | far better chance of being accepted than a patch from a known, |
| 115 | respected origin that is done poorly or does incorrect things. |
| 116 | |
| 117 | If you really really really really want to do a PGP signed |
| 118 | patch, format it as "multipart/signed", not a text/plain message |
| 119 | that starts with '-----BEGIN PGP SIGNED MESSAGE-----'. That is |
| 120 | not a text/plain, it's something else. |
| 121 | |
| 122 | Note that your maintainer does not necessarily read everything |
| 123 | on the git mailing list. If your patch is for discussion first, |
| 124 | send it "To:" the mailing list, and optionally "cc:" him. If it |
| 125 | is 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 | |
| 131 | JGit is licensed under the 3-clause (new-style) BSD. |
| 132 | |
| 133 | Because of this licensing model *every* file within the project |
| 134 | *must* list which license covers it in the header of the file. |
| 135 | Any new contributions to an existing file *must* be submitted under |
| 136 | the current license of that file. Any new files *must* clearly |
| 137 | indicate which license they are provided under in the file header. |
| 138 | |
| 139 | Please verify that you are legally allowed and willing to submit your |
| 140 | changes under the license covering each file *prior* to submitting |
| 141 | your patch. It is virtually impossible to remove a patch once it |
| 142 | has been applied and pushed out. |
| 143 | |
| 144 | |
| 145 | (5) Sign your work |
| 146 | |
| 147 | To improve tracking of who did what, we've borrowed the "sign-off" |
| 148 | procedure from the Linux kernel project on patches that are being |
| 149 | emailed around. Although JGit is a lot smaller project it is |
| 150 | a good discipline to follow it. |
| 151 | |
| 152 | The sign-off is a simple line at the end of the explanation for the |
| 153 | patch, which certifies that you wrote it or otherwise have the right |
| 154 | to pass it on as a open-source patch. The rules are pretty simple: |
| 155 | if 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 | |
| 184 | then you just add a line saying |
| 185 | |
| 186 | Signed-off-by: Random J Developer <random@developer.example.org> |
| 187 | |
| 188 | This line can be automatically added by git if you run the git-commit |
| 189 | command with the -s option. |
| 190 | |
| 191 | Some people also put extra tags at the end. They'll just be ignored |
| 192 | for now, but you can do this to mark internal company procedures |
| 193 | or just point out some special detail about the sign-off. |
| 194 | |
| 195 | |
| 196 | ------------------------------------------------ |
| 197 | MUA specific hints |
| 198 | |
| 199 | Some of patches I receive or pick up from the list share common |
| 200 | patterns of breakage. Please make sure your MUA is set up |
| 201 | properly not to corrupt whitespaces. Here are two common ones |
| 202 | I 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 | |
| 209 | One 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 | |
| 226 | If 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 | |
| 247 | Pine |
| 248 | ---- |
| 249 | |
| 250 | (Johannes Schindelin) |
| 251 | |
| 252 | I don't know how many people still use pine, but for those poor |
| 253 | souls it may be good to mention that the quell-flowed-text is |
| 254 | needed for recent versions. |
| 255 | |
| 256 | ... the "no-strip-whitespace-before-send" option, too. AFAIK it |
| 257 | was introduced in 4.60. |
| 258 | |
| 259 | (Linus Torvalds) |
| 260 | |
| 261 | And 4.58 needs at least this. |
| 262 | |
| 263 | --- |
| 264 | diff-tree 8326dd8350be64ac7fc805f6563a1d61ad10d32c (from e886a61f76edf5410573e92e38ce22974f9c40f1) |
| 265 | Author: Linus Torvalds <torvalds@g5.osdl.org> |
| 266 | Date: 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 | |
| 273 | diff --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 | |
| 292 | Ah, it looks like a recent version changed the default behavior to do the |
| 293 | right thing, and inverted the sense of the configuration option. (Either |
| 294 | that 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 |
| 297 | it. |
| 298 | |
| 299 | |
| 300 | Thunderbird |
| 301 | ----------- |
| 302 | |
| 303 | (A Large Angry SCM) |
| 304 | |
| 305 | Here are some hints on how to successfully submit patches inline using |
| 306 | Thunderbird. |
| 307 | |
| 308 | This recipe appears to work with the current [*1*] Thunderbird from Suse. |
| 309 | |
| 310 | The 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 | |
| 316 | 1) Prepare the patch as a text file using your method of choice. |
| 317 | |
| 318 | 2) Before opening a compose window, use Edit->Account Settings to |
| 319 | uncheck the "Compose messages in HTML format" setting in the |
| 320 | "Composition & Addressing" panel of the account to be used to send the |
| 321 | patch. [*2*] |
| 322 | |
| 323 | 3) In the main Thunderbird window, _before_ you open the compose window |
| 324 | for the patch, use Tools->about:config to set the following to the |
| 325 | indicated values: |
| 326 | mailnews.send_plaintext_flowed => false |
| 327 | mailnews.wraplength => 0 |
| 328 | |
| 329 | 4) Open a compose window and click the external editor icon. |
| 330 | |
| 331 | 5) In the external editor window, read in the patch file and exit the |
| 332 | editor normally. |
| 333 | |
| 334 | 6) Back in the compose window: Add whatever other text you wish to the |
| 335 | message, complete the addressing and subject fields, and press send. |
| 336 | |
| 337 | 7) Optionally, undo the about:config/account settings changes made in |
| 338 | steps 2 & 3. |
| 339 | |
| 340 | |
| 341 | [Footnotes] |
| 342 | *1* Version 1.0 (20041207) from the MozillaThunderbird-1.0-5 rpm of Suse |
| 343 | 9.3 professional updates. |
| 344 | |
| 345 | *2* It may be possible to do this with about:config and the following |
| 346 | settings 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 | |
| 353 | Gnus |
| 354 | ---- |
| 355 | |
| 356 | '|' in the *Summary* buffer can be used to pipe the current |
| 357 | message to an external program, and this is a handy way to drive |
| 358 | "git am". However, if the message is MIME encoded, what is |
| 359 | piped into the program is the representation you see in your |
| 360 | *Article* buffer after unwrapping MIME. This is often not what |
| 361 | you would want for two reasons. It tends to screw up non ASCII |
| 362 | characters (most notably in people's names), and also |
| 363 | whitespaces (fatal in patches). Running 'C-u g' to display the |
| 364 | message in raw form before using '|' to run the pipe can work |
| 365 | this problem around. |
| 366 | |