You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SUBMITTING_PATCHES 13KB

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