CONTRIBUTE 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. _ _ ____ _
  2. ___| | | | _ \| |
  3. / __| | | | |_) | |
  4. | (__| |_| | _ <| |___
  5. \___|\___/|_| \_\_____|
  6. When Contributing Source Code
  7. This document is intended to offer guidelines that can be useful to keep in
  8. mind when you decide to contribute to the project. This concerns new features
  9. as well as corrections to existing flaws or bugs.
  10. 1. Learning cURL
  11. 1.1 Join the Community
  12. 1.2 License
  13. 1.3 What To Read
  14. 2. cURL Coding Standards
  15. 2.1 Naming
  16. 2.2 Indenting
  17. 2.3 Commenting
  18. 2.4 Line Lengths
  19. 2.5 General Style
  20. 2.6 Non-clobbering All Over
  21. 2.7 Platform Dependent Code
  22. 2.8 Write Separate Patches
  23. 2.9 Patch Against Recent Sources
  24. 2.10 Document
  25. 2.11 Test Cases
  26. 3. Pushing Out Your Changes
  27. 3.1 Write Access to git Repository
  28. 3.2 How To Make a Patch with git
  29. 3.3 How To Make a Patch without git
  30. 3.4 How to get your changes into the main sources
  31. 3.5 Write good commit messages
  32. 3.6 Please don't send pull requests
  33. ==============================================================================
  34. 1. Learning cURL
  35. 1.1 Join the Community
  36. Skip over to http://curl.haxx.se/mail/ and join the appropriate mailing
  37. list(s). Read up on details before you post questions. Read this file before
  38. you start sending patches! We prefer patches and discussions being held on
  39. the mailing list(s), not sent to individuals.
  40. Before posting to one of the curl mailing lists, please read up on the mailing
  41. list etiquette: http://curl.haxx.se/mail/etiquette.html
  42. We also hang out on IRC in #curl on irc.freenode.net
  43. 1.2. License
  44. When contributing with code, you agree to put your changes and new code under
  45. the same license curl and libcurl is already using unless stated and agreed
  46. otherwise.
  47. If you add a larger piece of code, you can opt to make that file or set of
  48. files to use a different license as long as they don't enforce any changes to
  49. the rest of the package and they make sense. Such "separate parts" can not be
  50. GPL licensed (as we don't want copyleft to affect users of libcurl) but they
  51. must use "GPL compatible" licenses (as we want to allow users to use libcurl
  52. properly in GPL licensed environments).
  53. When changing existing source code, you do not alter the copyright of the
  54. original file(s). The copyright will still be owned by the original
  55. creator(s) or those who have been assigned copyright by the original
  56. author(s).
  57. By submitting a patch to the curl project, you are assumed to have the right
  58. to the code and to be allowed by your employer or whatever to hand over that
  59. patch/code to us. We will credit you for your changes as far as possible, to
  60. give credit but also to keep a trace back to who made what changes. Please
  61. always provide us with your full real name when contributing!
  62. 1.3 What To Read
  63. Source code, the man pages, the INTERNALS document, TODO, KNOWN_BUGS, the
  64. most recent CHANGES. Just lurking on the curl-library mailing list is gonna
  65. give you a lot of insights on what's going on right now. Asking there is a
  66. good idea too.
  67. 2. cURL Coding Standards
  68. 2.1 Naming
  69. Try using a non-confusing naming scheme for your new functions and variable
  70. names. It doesn't necessarily have to mean that you should use the same as in
  71. other places of the code, just that the names should be logical,
  72. understandable and be named according to what they're used for. File-local
  73. functions should be made static. We like lower case names.
  74. See the INTERNALS document on how we name non-exported library-global
  75. symbols.
  76. 2.2 Indenting
  77. Use the same indenting levels and bracing method as all the other code
  78. already does. It makes the source code easier to follow if all of it is
  79. written using the same style. We don't ask you to like it, we just ask you to
  80. follow the tradition! ;-) This mainly means: 2-level indents, using spaces
  81. only (no tabs) and having the opening brace ({) on the same line as the if()
  82. or while().
  83. Also note that we use if() and while() with no space before the parenthesis.
  84. 2.3 Commenting
  85. Comment your source code extensively using C comments (/* comment */), DO NOT
  86. use C++ comments (// this style). Commented code is quality code and enables
  87. future modifications much more. Uncommented code risk having to be completely
  88. replaced when someone wants to extend things, since other persons' source
  89. code can get quite hard to read.
  90. 2.4 Line Lengths
  91. We write source lines shorter than 80 columns.
  92. 2.5 General Style
  93. Keep your functions small. If they're small you avoid a lot of mistakes and
  94. you don't accidentally mix up variables etc.
  95. 2.6 Non-clobbering All Over
  96. When you write new functionality or fix bugs, it is important that you don't
  97. fiddle all over the source files and functions. Remember that it is likely
  98. that other people have done changes in the same source files as you have and
  99. possibly even in the same functions. If you bring completely new
  100. functionality, try writing it in a new source file. If you fix bugs, try to
  101. fix one bug at a time and send them as separate patches.
  102. 2.7 Platform Dependent Code
  103. Use #ifdef HAVE_FEATURE to do conditional code. We avoid checking for
  104. particular operating systems or hardware in the #ifdef lines. The
  105. HAVE_FEATURE shall be generated by the configure script for unix-like systems
  106. and they are hard-coded in the config-[system].h files for the others.
  107. 2.8 Write Separate Patches
  108. It is annoying when you get a huge patch from someone that is said to fix 511
  109. odd problems, but discussions and opinions don't agree with 510 of them - or
  110. 509 of them were already fixed in a different way. Then the patcher needs to
  111. extract the single interesting patch from somewhere within the huge pile of
  112. source, and that gives a lot of extra work. Preferably, all fixes that
  113. correct different problems should be in their own patch with an attached
  114. description exactly what they correct so that all patches can be selectively
  115. applied by the maintainer or other interested parties.
  116. Also, separate patches enable bisecting much better when we track problems in
  117. the future.
  118. 2.9 Patch Against Recent Sources
  119. Please try to get the latest available sources to make your patches
  120. against. It makes the life of the developers so much easier. The very best is
  121. if you get the most up-to-date sources from the git repository, but the
  122. latest release archive is quite OK as well!
  123. 2.10 Document
  124. Writing docs is dead boring and one of the big problems with many open source
  125. projects. Someone's gotta do it. It makes it a lot easier if you submit a
  126. small description of your fix or your new features with every contribution so
  127. that it can be swiftly added to the package documentation.
  128. The documentation is always made in man pages (nroff formatted) or plain
  129. ASCII files. All HTML files on the web site and in the release archives are
  130. generated from the nroff/ASCII versions.
  131. 2.11 Test Cases
  132. Since the introduction of the test suite, we can quickly verify that the main
  133. features are working as they're supposed to. To maintain this situation and
  134. improve it, all new features and functions that are added need to be tested
  135. in the test suite. Every feature that is added should get at least one valid
  136. test case that verifies that it works as documented. If every submitter also
  137. posts a few test cases, it won't end up as a heavy burden on a single person!
  138. If you don't have test cases or perhaps you have done something that is very
  139. hard to write tests for, do explain exactly how you have otherwise tested and
  140. verified your changes.
  141. 3. Pushing Out Your Changes
  142. 3.1 Write Access to git Repository
  143. If you are a frequent contributor, or have another good reason, you can of
  144. course get write access to the git repository and then you'll be able to push
  145. your changes straight into the git repo instead of sending changes by mail as
  146. patches. Just ask if this is what you'd want. You will be required to have
  147. posted a few quality patches first, before you can be granted push access.
  148. 3.2 How To Make a Patch with git
  149. You need to first checkout the repository:
  150. git clone git://github.com/bagder/curl.git
  151. You then proceed and edit all the files you like and you commit them to your
  152. local repository:
  153. git commit [file]
  154. As usual, group your commits so that you commit all changes that at once that
  155. constitutes a logical change. See also section "3.5 Write good commit
  156. messages".
  157. Once you have done all your commits and you're happy with what you see, you
  158. can make patches out of your changes that are suitable for mailing:
  159. git format-patch remotes/origin/master
  160. This creates files in your local directory named NNNN-[name].patch for each
  161. commit.
  162. Now send those patches off to the curl-library list. You can of course opt to
  163. do that with the 'git send-email' command.
  164. 3.3 How To Make a Patch without git
  165. Keep a copy of the unmodified curl sources. Make your changes in a separate
  166. source tree. When you think you have something that you want to offer the
  167. curl community, use GNU diff to generate patches.
  168. If you have modified a single file, try something like:
  169. diff -u unmodified-file.c my-changed-one.c > my-fixes.diff
  170. If you have modified several files, possibly in different directories, you
  171. can use diff recursively:
  172. diff -ur curl-original-dir curl-modified-sources-dir > my-fixes.diff
  173. The GNU diff and GNU patch tools exist for virtually all platforms, including
  174. all kinds of Unixes and Windows:
  175. For unix-like operating systems:
  176. http://www.gnu.org/software/patch/patch.html
  177. http://www.gnu.org/directory/diffutils.html
  178. For Windows:
  179. http://gnuwin32.sourceforge.net/packages/patch.htm
  180. http://gnuwin32.sourceforge.net/packages/diffutils.htm
  181. 3.4 How to get your changes into the main sources
  182. Submit your patch to the curl-library mailing list.
  183. Make the patch against as recent sources as possible.
  184. Make sure your patch adheres to the source indent and coding style of already
  185. existing source code. Failing to do so just adds more work for me.
  186. Respond to replies on the list about the patch and answer questions and/or
  187. fix nits/flaws. This is very important. I will take lack of replies as a sign
  188. that you're not very anxious to get your patch accepted and I tend to simply
  189. drop such patches from my TODO list.
  190. If you've followed the above paragraphs and your patch still hasn't been
  191. incorporated after some weeks, consider resubmitting it to the list.
  192. 3.5 Write good commit messages
  193. A short guide to how to do fine commit messages in the curl project.
  194. ---- start ----
  195. [area]: [short line describing the main effect]
  196. [separate the above single line from the rest with an empty line]
  197. [full description, no wider than 72 columns that describe as much as
  198. possible as to why this change is made, and possibly what things
  199. it fixes and everything else that is related]
  200. [Bug: link to source of the report or more related discussion]
  201. [Reported-by: John Doe - credit the reporter]
  202. [whatever-else-by: credit all helpers, finders, doers]
  203. ---- stop ----
  204. Don't forget to use commit --author="" if you commit someone else's work,
  205. and make sure that you have your own user and email setup correctly in git
  206. before you commit
  207. 3.6 Please don't send pull requests
  208. With git (and especially github) it is easy and tempting to send a pull
  209. request to one or more people in the curl project to have changes merged this
  210. way instead of mailing patches to the curl-library mailing list.
  211. We don't like that. We want them mailed for these reasons:
  212. - Peer review. Anyone and everyone on the list can review, comment and
  213. improve on the patch. Pull requests limit this ability.
  214. - Anyone can merge the patch into their own trees for testing and those who
  215. have push rights can push it to the main repo. It doesn't have to be anyone
  216. the patch author knows beforehand.
  217. - Commit messages can be tweaked and changed if merged locally instead of
  218. using github. Merges directly on github requires the changes to be perfect
  219. already, which they seldom are.
  220. - Merges on github prevents rebases and even enforces --no-ff which is a git
  221. style we don't otherwise use in the project
  222. However: once patches have been reviewed and deemed fine on list they are
  223. perfectly OK to be pulled from a published git tree.