1# Contributing to the curl project 2 3This document is intended to offer guidelines on how to best contribute to the 4curl project. This concerns new features as well as corrections to existing 5flaws or bugs. 6 7## Join the Community 8 9Skip over to [https://curl.se/mail/](https://curl.se/mail/) and join 10the appropriate mailing list(s). Read up on details before you post 11questions. Read this file before you start sending patches. We prefer 12questions sent to and discussions being held on the mailing list(s), not sent 13to individuals. 14 15Before posting to one of the curl mailing lists, please read up on the 16[mailing list etiquette](https://curl.se/mail/etiquette.html). 17 18We also hang out on IRC in #curl on libera.chat 19 20If you are at all interested in the code side of things, consider clicking 21'watch' on the [curl repo on GitHub](https://github.com/curl/curl) to be 22notified of pull requests and new issues posted there. 23 24## License and copyright 25 26When contributing with code, you agree to put your changes and new code under 27the same license curl and libcurl is already using unless stated and agreed 28otherwise. 29 30If you add a larger piece of code, you can opt to make that file or set of 31files to use a different license as long as they do not enforce any changes to 32the rest of the package and they make sense. Such "separate parts" can not be 33GPL licensed (as we do not want copyleft to affect users of libcurl) but they 34must use "GPL compatible" licenses (as we want to allow users to use libcurl 35properly in GPL licensed environments). 36 37When changing existing source code, you do not alter the copyright of the 38original file(s). The copyright will still be owned by the original creator(s) 39or those who have been assigned copyright by the original author(s). 40 41By submitting a patch to the curl project, you are assumed to have the right 42to the code and to be allowed by your employer or whatever to hand over that 43patch/code to us. We will credit you for your changes as far as possible, to 44give credit but also to keep a trace back to who made what changes. Please 45always provide us with your full real name when contributing, 46 47## What To Read 48 49Source code, the man pages, the [INTERNALS 50document](https://curl.se/dev/internals.html), 51[TODO](https://curl.se/docs/todo.html), 52[KNOWN_BUGS](https://curl.se/docs/knownbugs.html) and the [most recent 53changes](https://curl.se/dev/sourceactivity.html) in git. Just lurking on 54the [curl-library mailing 55list](https://curl.se/mail/list.cgi?list=curl-library) will give you a 56lot of insights on what's going on right now. Asking there is a good idea too. 57 58## Write a good patch 59 60### Follow code style 61 62When writing C code, follow the 63[CODE_STYLE](https://curl.se/dev/code-style.html) already established in 64the project. Consistent style makes code easier to read and mistakes less 65likely to happen. Run `make checksrc` before you submit anything, to make sure 66you follow the basic style. That script does not verify everything, but if it 67complains you know you have work to do. 68 69### Non-clobbering All Over 70 71When you write new functionality or fix bugs, it is important that you do not 72fiddle all over the source files and functions. Remember that it is likely 73that other people have done changes in the same source files as you have and 74possibly even in the same functions. If you bring completely new 75functionality, try writing it in a new source file. If you fix bugs, try to 76fix one bug at a time and send them as separate patches. 77 78### Write Separate Changes 79 80It is annoying when you get a huge patch from someone that is said to fix 511 81odd problems, but discussions and opinions do not agree with 510 of them - or 82509 of them were already fixed in a different way. Then the person merging 83this change needs to extract the single interesting patch from somewhere 84within the huge pile of source, and that creates a lot of extra work. 85 86Preferably, each fix that corrects a problem should be in its own patch/commit 87with its own description/commit message stating exactly what they correct so 88that all changes can be selectively applied by the maintainer or other 89interested parties. 90 91Also, separate changes enable bisecting much better for tracking problems 92and regression in the future. 93 94### Patch Against Recent Sources 95 96Please try to get the latest available sources to make your patches against. 97It makes the lives of the developers so much easier. The best is if you get 98the most up-to-date sources from the git repository, but the latest release 99archive is quite OK as well. 100 101### Documentation 102 103Writing docs is dead boring and one of the big problems with many open source 104projects. But someone's gotta do it. It makes things a lot easier if you 105submit a small description of your fix or your new features with every 106contribution so that it can be swiftly added to the package documentation. 107 108The documentation is always made in man pages (nroff formatted) or plain 109ASCII files. All HTML files on the website and in the release archives are 110generated from the nroff/ASCII versions. 111 112### Test Cases 113 114Since the introduction of the test suite, we can quickly verify that the main 115features are working as they are supposed to. To maintain this situation and 116improve it, all new features and functions that are added need to be tested 117in the test suite. Every feature that is added should get at least one valid 118test case that verifies that it works as documented. If every submitter also 119posts a few test cases, it will not end up as a heavy burden on a single person! 120 121If you do not have test cases or perhaps you have done something that is hard 122to write tests for, do explain exactly how you have otherwise tested and 123verified your changes. 124 125## Submit Your Changes 126 127### How to get your changes into the main sources 128 129Ideally you file a [pull request on 130GitHub](https://github.com/curl/curl/pulls), but you can also send your plain 131patch to [the curl-library mailing 132list](https://curl.se/mail/list.cgi?list=curl-library). 133 134If you opt to post a patch on the mailing list, chances are someone will 135convert it into a pull request for you, to have the CI jobs verify it proper 136before it can be merged. Be prepared that some feedback on the proposed change 137might then come on GitHub. 138 139Your change will be reviewed and discussed and you will be expected to correct 140flaws pointed out and update accordingly, or the change risks stalling and 141eventually just getting deleted without action. As a submitter of a change, 142you are the owner of that change until it has been merged. 143 144Respond on the list or on GitHub about the change and answer questions and/or 145fix nits/flaws. This is important. We will take lack of replies as a sign that 146you are not anxious to get your patch accepted and we tend to simply drop such 147changes. 148 149### About pull requests 150 151With GitHub it is easy to send a [pull 152request](https://github.com/curl/curl/pulls) to the curl project to have 153changes merged. 154 155We strongly prefer pull requests to mailed patches, as it makes it a proper 156git commit that is easy to merge and they are easy to track and not that easy 157to lose in the flood of many emails, like they sometimes do on the mailing 158lists. 159 160Every pull request submitted will automatically be tested in several different 161ways. [See the CI document for more 162information](https://github.com/curl/curl/blob/master/tests/CI.md). 163 164Sometimes the tests fail due to a dependency service temporarily being offline 165or otherwise unavailable, e.g. package downloads. In this case you can just 166try to update your pull requests to rerun the tests later as described below. 167 168You can update your pull requests by pushing new commits or force-pushing 169changes to existing commits. Force-pushing an amended commit without any 170actual content changed also allows you to retrigger the tests for that commit. 171 172When you adjust your pull requests after review, consider squashing the 173commits so that we can review the full updated version more easily. 174 175A pull request sent to the project might get labeled `needs-votes` by a 176project maintainer. This label means that in addition to meeting all other 177checks and qualifications this pull request must also receive more "votes" of 178user support. More signs that people want this to happen. It could be in the 179form of messages saying so, or thumbs-up reactions on GitHub. 180 181### Making quality changes 182 183Make the patch against as recent source versions as possible. 184 185If you have followed the tips in this document and your patch still has not 186been incorporated or responded to after some weeks, consider resubmitting it 187to the list or better yet: change it to a pull request. 188 189### Commit messages 190 191A short guide to how to write git commit messages in the curl project. 192 193 ---- start ---- 194 [area]: [short line describing the main effect] 195 -- empty line -- 196 [full description, no wider than 72 columns that describes as much as 197 possible as to why this change is made, and possibly what things 198 it fixes and everything else that is related, with unwieldy URLs replaced 199 with references like [0], [1], etc.] 200 -- empty line -- 201 [[0] URL - Reference to a URL in the description, almost like Markdown; 202 the last numbered reference is followed by an -- empty line -- ] 203 [Follow-up to {shorthash} - if this fixes or continues a previous commit; 204 add a Ref: that commit's PR or issue if it's not a small, obvious fix; 205 followed by an -- empty line -- ] 206 [Bug: URL to the source of the report or more related discussion; use Fixes 207 for GitHub issues instead when that is appropriate] 208 [Approved-by: John Doe - credit someone who approved the PR; if you are 209 committing this for someone else using --author=... you do not need this 210 as you are implicitly approving it by committing] 211 [Authored-by: John Doe - credit the original author of the code; only use 212 this if you cannot use "git commit --author=..."] 213 [Signed-off-by: John Doe - we do not use this, but do not bother removing it] 214 [whatever-else-by: credit all helpers, finders, doers; try to use one of 215 the following keywords if at all possible, for consistency: 216 Acked-by:, Assisted-by:, Co-authored-by:, Found-by:, Reported-by:, 217 Reviewed-by:, Suggested-by:, Tested-by:] 218 [Ref: #1234 - if this is related to a GitHub issue or PR, possibly one that 219 has already been closed] 220 [Ref: URL to more information about the commit; use Bug: instead for 221 a reference to a bug on another bug tracker] 222 [Fixes #1234 - if this closes a GitHub issue; GitHub will actually 223 close the issue once this commit is merged] 224 [Closes #1234 - if this closes a GitHub PR; GitHub will actually 225 close the PR once this commit is merged] 226 ---- stop ---- 227 228The first line is a succinct description of the change: 229 230 - use the imperative, present tense: "change" not "changed" nor "changes" 231 - do not capitalize the first letter 232 - no period (.) at the end 233 234The `[area]` in the first line can be `http2`, `cookies`, `openssl` or 235similar. There is no fixed list to select from but using the same "area" as 236other related changes could make sense. 237 238Do not forget to use commit --author=... if you commit someone else's work, and 239make sure that you have your own user and email setup correctly in git before 240you commit. 241 242Add whichever header lines as appropriate, with one line per person if more 243than one person was involved. There is no need to credit yourself unless you are 244using --author=... which hides your identity. Do not include people's e-mail 245addresses in headers to avoid spam, unless they are already public from a 246previous commit; saying `{userid} on github` is OK. 247 248### Write Access to git Repository 249 250If you are a frequent contributor, you may be given push access to the git 251repository and then you will be able to push your changes straight into the git 252repo instead of sending changes as pull requests or by mail as patches. 253 254Just ask if this is what you would want. You will be required to have posted 255several high quality patches first, before you can be granted push access. 256 257### How To Make a Patch with git 258 259You need to first checkout the repository: 260 261 git clone https://github.com/curl/curl.git 262 263You then proceed and edit all the files you like and you commit them to your 264local repository: 265 266 git commit [file] 267 268As usual, group your commits so that you commit all changes at once that 269constitute a logical change. 270 271Once you have done all your commits and you are happy with what you see, you 272can make patches out of your changes that are suitable for mailing: 273 274 git format-patch remotes/origin/master 275 276This creates files in your local directory named `NNNN-[name].patch` for each 277commit. 278 279Now send those patches off to the curl-library list. You can of course opt to 280do that with the 'git send-email' command. 281 282### How To Make a Patch without git 283 284Keep a copy of the unmodified curl sources. Make your changes in a separate 285source tree. When you think you have something that you want to offer the 286curl community, use GNU diff to generate patches. 287 288If you have modified a single file, try something like: 289 290 diff -u unmodified-file.c my-changed-one.c > my-fixes.diff 291 292If you have modified several files, possibly in different directories, you 293can use diff recursively: 294 295 diff -ur curl-original-dir curl-modified-sources-dir > my-fixes.diff 296 297The GNU diff and GNU patch tools exist for virtually all platforms, including 298all kinds of Unixes and Windows. 299 300### Useful resources 301 - [Webinar on getting code into cURL](https://www.youtube.com/watch?v=QmZ3W1d6LQI) 302 303## Update copyright and license information 304 305There is a CI job called **REUSE compliance / check** that will run on every 306pull request and commit to verify that the *REUSE state* of all files are 307still fine. 308 309This means that all files need to have their license and copyright information 310clearly stated. Ideally by having the standard curl source code header, with 311the SPDX-License-Identifier included. If the header does not work, you can use a 312smaller header or add the information for a specific file to the `.reuse/dep5` 313file. 314 315You can manually verify the copyright and compliance status by running the 316`./scripts/copyright.pl` script in the root of the git repository. 317