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