5 \___|\___/|_| \_\_____|
7 When Contributing Source Code
9 This document is intended to offer guidelines that can be useful to keep in
10 mind when you decide to contribute to the project. This concerns new features
11 as well as corrections to existing flaws or bugs.
14 1.1 Join the Community
20 2.2 Non-clobbering All Over
21 2.3 Write Separate Patches
22 2.4 Patch Against Recent Sources
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 About pull requests
34 ==============================================================================
38 1.1 Join the Community
40 Skip over to https://curl.haxx.se/mail/ and join the appropriate mailing
41 list(s). Read up on details before you post questions. Read this file before
42 you start sending patches! We prefer patches and discussions being held on
43 the mailing list(s), not sent to individuals.
45 Before posting to one of the curl mailing lists, please read up on the mailing
46 list etiquette: https://curl.haxx.se/mail/etiquette.html
48 We also hang out on IRC in #curl on irc.freenode.net
50 If you're at all interested in the code side of things, consider clicking
51 'watch' on the curl repo at github to get notified on pull requests and new
56 When contributing with code, you agree to put your changes and new code under
57 the same license curl and libcurl is already using unless stated and agreed
60 If you add a larger piece of code, you can opt to make that file or set of
61 files to use a different license as long as they don't enforce any changes to
62 the rest of the package and they make sense. Such "separate parts" can not be
63 GPL licensed (as we don't want copyleft to affect users of libcurl) but they
64 must use "GPL compatible" licenses (as we want to allow users to use libcurl
65 properly in GPL licensed environments).
67 When changing existing source code, you do not alter the copyright of the
68 original file(s). The copyright will still be owned by the original
69 creator(s) or those who have been assigned copyright by the original
72 By submitting a patch to the curl project, you are assumed to have the right
73 to the code and to be allowed by your employer or whatever to hand over that
74 patch/code to us. We will credit you for your changes as far as possible, to
75 give credit but also to keep a trace back to who made what changes. Please
76 always provide us with your full real name when contributing!
80 Source code, the man pages, the INTERNALS document, TODO, KNOWN_BUGS and the
81 most recent changes in the git log. Just lurking on the curl-library mailing
82 list is gonna give you a lot of insights on what's going on right now. Asking
83 there is a good idea too.
89 When writing C code, follow the CODE_STYLE already established in the
90 project. Consistent style makes code easier to read and mistakes less likely
93 2.2 Non-clobbering All Over
95 When you write new functionality or fix bugs, it is important that you don't
96 fiddle all over the source files and functions. Remember that it is likely
97 that other people have done changes in the same source files as you have and
98 possibly even in the same functions. If you bring completely new
99 functionality, try writing it in a new source file. If you fix bugs, try to
100 fix one bug at a time and send them as separate patches.
102 2.3 Write Separate Patches
104 It is annoying when you get a huge patch from someone that is said to fix 511
105 odd problems, but discussions and opinions don't agree with 510 of them - or
106 509 of them were already fixed in a different way. Then the patcher needs to
107 extract the single interesting patch from somewhere within the huge pile of
108 source, and that gives a lot of extra work. Preferably, all fixes that
109 correct different problems should be in their own patch with an attached
110 description exactly what they correct so that all patches can be selectively
111 applied by the maintainer or other interested parties.
113 Also, separate patches enable bisecting much better when we track problems in
116 2.4 Patch Against Recent Sources
118 Please try to get the latest available sources to make your patches
119 against. It makes the life of the developers so much easier. The very best is
120 if you get the most up-to-date sources from the git repository, but the
121 latest release archive is quite OK as well!
125 Writing docs is dead boring and one of the big problems with many open source
126 projects. Someone's gotta do it. It makes it a lot easier if you submit a
127 small description of your fix or your new features with every contribution so
128 that it can be swiftly added to the package documentation.
130 The documentation is always made in man pages (nroff formatted) or plain
131 ASCII files. All HTML files on the web site and in the release archives are
132 generated from the nroff/ASCII versions.
136 Since the introduction of the test suite, we can quickly verify that the main
137 features are working as they're supposed to. To maintain this situation and
138 improve it, all new features and functions that are added need to be tested
139 in the test suite. Every feature that is added should get at least one valid
140 test case that verifies that it works as documented. If every submitter also
141 posts a few test cases, it won't end up as a heavy burden on a single person!
143 If you don't have test cases or perhaps you have done something that is very
144 hard to write tests for, do explain exactly how you have otherwise tested and
145 verified your changes.
147 3. Pushing Out Your Changes
149 3.1 Write Access to git Repository
151 If you are a frequent contributor, or have another good reason, you can of
152 course get write access to the git repository and then you'll be able to push
153 your changes straight into the git repo instead of sending changes by mail as
154 patches. Just ask if this is what you'd want. You will be required to have
155 posted a few quality patches first, before you can be granted push access.
157 3.2 How To Make a Patch with git
159 You need to first checkout the repository:
161 git clone https://github.com/curl/curl.git
163 You then proceed and edit all the files you like and you commit them to your
168 As usual, group your commits so that you commit all changes that at once that
169 constitutes a logical change. See also section "3.5 Write good commit
172 Once you have done all your commits and you're happy with what you see, you
173 can make patches out of your changes that are suitable for mailing:
175 git format-patch remotes/origin/master
177 This creates files in your local directory named NNNN-[name].patch for each
180 Now send those patches off to the curl-library list. You can of course opt to
181 do that with the 'git send-email' command.
183 3.3 How To Make a Patch without git
185 Keep a copy of the unmodified curl sources. Make your changes in a separate
186 source tree. When you think you have something that you want to offer the
187 curl community, use GNU diff to generate patches.
189 If you have modified a single file, try something like:
191 diff -u unmodified-file.c my-changed-one.c > my-fixes.diff
193 If you have modified several files, possibly in different directories, you
194 can use diff recursively:
196 diff -ur curl-original-dir curl-modified-sources-dir > my-fixes.diff
198 The GNU diff and GNU patch tools exist for virtually all platforms, including
199 all kinds of Unixes and Windows:
201 For unix-like operating systems:
203 https://savannah.gnu.org/projects/patch/
204 https://www.gnu.org/software/diffutils/
208 http://gnuwin32.sourceforge.net/packages/patch.htm
209 http://gnuwin32.sourceforge.net/packages/diffutils.htm
211 3.4 How to get your changes into the main sources
213 Submit your patch to the curl-library mailing list.
215 Make the patch against as recent sources as possible.
217 Make sure your patch adheres to the source indent and coding style of already
218 existing source code. Failing to do so just adds more work for me.
220 Respond to replies on the list about the patch and answer questions and/or
221 fix nits/flaws. This is very important. I will take lack of replies as a sign
222 that you're not very anxious to get your patch accepted and I tend to simply
223 drop such patches from my TODO list.
225 If you've followed the above paragraphs and your patch still hasn't been
226 incorporated after some weeks, consider resubmitting it to the list.
228 3.5 Write good commit messages
230 A short guide to how to do fine commit messages in the curl project.
233 [area]: [short line describing the main effect]
235 [separate the above single line from the rest with an empty line]
237 [full description, no wider than 72 columns that describe as much as
238 possible as to why this change is made, and possibly what things
239 it fixes and everything else that is related]
241 [Bug: link to source of the report or more related discussion]
242 [Reported-by: John Doe - credit the reporter]
243 [whatever-else-by: credit all helpers, finders, doers]
246 Don't forget to use commit --author="" if you commit someone else's work,
247 and make sure that you have your own user and email setup correctly in git
250 3.6 About pull requests
252 With git (and especially github) it is easy and tempting to send a pull
253 request to the curl project to have changes merged this way instead of
254 mailing patches to the curl-library mailing list.
256 We used to dislike this but we're trying to change that and accept that this
257 is a frictionless way for people to contribute to the project. We now welcome
260 We will continue to avoid using github's merge tools to make the history
261 linear and to make sure commits follow our style guidelines.