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## Learning curl 8 9### Join the Community 10 11Skip over to [https://curl.haxx.se/mail/](https://curl.haxx.se/mail/) and join 12the appropriate mailing list(s). Read up on details before you post 13questions. Read this file before you start sending patches! We prefer 14questions sent to and discussions being held on the mailing list(s), not sent 15to individuals. 16 17Before posting to one of the curl mailing lists, please read up on the 18[mailing list etiquette](https://curl.haxx.se/mail/etiquette.html). 19 20We also hang out on IRC in #curl on irc.freenode.net 21 22If you're at all interested in the code side of things, consider clicking 23'watch' on the [curl repo on github](https://github.com/curl/curl) to get 24notified on pull requests and new issues posted there. 25 26### License and copyright 27 28When contributing with code, you agree to put your changes and new code under 29the same license curl and libcurl is already using unless stated and agreed 30otherwise. 31 32If you add a larger piece of code, you can opt to make that file or set of 33files to use a different license as long as they don't enforce any changes to 34the rest of the package and they make sense. Such "separate parts" can not be 35GPL licensed (as we don't want copyleft to affect users of libcurl) but they 36must use "GPL compatible" licenses (as we want to allow users to use libcurl 37properly in GPL licensed environments). 38 39When changing existing source code, you do not alter the copyright of the 40original file(s). The copyright will still be owned by the original creator(s) 41or those who have been assigned copyright by the original author(s). 42 43By submitting a patch to the curl project, you are assumed to have the right 44to the code and to be allowed by your employer or whatever to hand over that 45patch/code to us. We will credit you for your changes as far as possible, to 46give credit but also to keep a trace back to who made what changes. Please 47always provide us with your full real name when contributing! 48 49### What To Read 50 51Source code, the man pages, the [INTERNALS 52document](https://curl.haxx.se/dev/internals.html), 53[TODO](https://curl.haxx.se/docs/todo.html), 54[KNOWN_BUGS](https://curl.haxx.se/docs/knownbugs.html) and the [most recent 55changes](https://curl.haxx.se/dev/sourceactivity.html) in git. Just lurking on 56the [curl-library mailing 57list](https://curl.haxx.se/mail/list.cgi?list=curl-library) will give you a 58lot of insights on what's going on right now. Asking there is a good idea too. 59 60## Write a good patch 61 62### Follow code style 63 64When writing C code, follow the 65[CODE_STYLE](https://curl.haxx.se/dev/code-style.html) already established in 66the project. Consistent style makes code easier to read and mistakes less 67likely to happen. Run `make checksrc` before you submit anything, to make sure 68you follow the basic style. That script doesn't verify everything, but if it 69complains you know you have work to do. 70 71### Non-clobbering All Over 72 73When you write new functionality or fix bugs, it is important that you don't 74fiddle all over the source files and functions. Remember that it is likely 75that other people have done changes in the same source files as you have and 76possibly even in the same functions. If you bring completely new 77functionality, try writing it in a new source file. If you fix bugs, try to 78fix one bug at a time and send them as separate patches. 79 80### Write Separate Changes 81 82It is annoying when you get a huge patch from someone that is said to fix 511 83odd problems, but discussions and opinions don't agree with 510 of them - or 84509 of them were already fixed in a different way. Then the person merging 85this change needs to extract the single interesting patch from somewhere 86within the huge pile of source, and that gives a lot of extra work. 87 88Preferably, each fix that correct a problem should be in its own patch/commit 89with its own description/commit message stating exactly what they correct so 90that all changes can be selectively applied by the maintainer or other 91interested parties. 92 93Also, separate changes enable bisecting much better when we track problems 94and regression in the future. 95 96### Patch Against Recent Sources 97 98Please try to get the latest available sources to make your patches against. 99It makes the lives of the developers so much easier. The very best is if you 100get the most up-to-date sources from the git repository, but the latest 101release archive is quite OK as well! 102 103### Documentation 104 105Writing docs is dead boring and one of the big problems with many open source 106projects. Someone's gotta do it. It makes it a lot easier if you submit a 107small description of your fix or your new features with every contribution so 108that it can be swiftly added to the package documentation. 109 110The documentation is always made in man pages (nroff formatted) or plain 111ASCII files. All HTML files on the web site and in the release archives are 112generated from the nroff/ASCII versions. 113 114### Test Cases 115 116Since the introduction of the test suite, we can quickly verify that the main 117features are working as they're supposed to. To maintain this situation and 118improve it, all new features and functions that are added need to be tested 119in the test suite. Every feature that is added should get at least one valid 120test case that verifies that it works as documented. If every submitter also 121posts a few test cases, it won't end up as a heavy burden on a single person! 122 123If you don't have test cases or perhaps you have done something that is very 124hard to write tests for, do explain exactly how you have otherwise tested and 125verified your changes. 126 127## Sharing Your Changes 128 129### How to get your changes into the main sources 130 131Ideally you file a [pull request on 132github](https://github.com/curl/curl/pulls), but you can also send your plain 133patch to [the curl-library mailing 134list](https://curl.haxx.se/mail/list.cgi?list=curl-library). 135 136Either way, your change will be reviewed and discussed there and you will be 137expected to correct flaws pointed out and update accordingly, or the change 138risk stalling and eventually just get deleted without action. As a submitter 139of a change, you are the owner of that change until it has been merged. 140 141Respond on the list or on github about the change and answer questions and/or 142fix nits/flaws. This is very important. We will take lack of replies as a 143sign that you're not very anxious to get your patch accepted and we tend to 144simply drop such changes. 145 146### About pull requests 147 148With github it is easy to send a [pull 149request](https://github.com/curl/curl/pulls) to the curl project to have 150changes merged. 151 152We prefer pull requests to mailed patches, as it makes it a proper git commit 153that is easy to merge and they are easy to track and not that easy to loose 154in a flood of many emails, like they sometimes do on the mailing lists. 155 156When you adjust your pull requests after review, consider squashing the 157commits so that we can review the full updated version more easily. 158 159### Making quality patches 160 161Make the patch against as recent sources as possible. 162 163If you've followed the tips in this document and your patch still hasn't been 164incorporated or responded to after some weeks, consider resubmitting it to 165the list or better yet: change it to a pull request. 166 167### Write good commit messages 168 169A short guide to how to write commit messages in the curl project. 170 171 ---- start ---- 172 [area]: [short line describing the main effect] 173 -- empty line -- 174 [full description, no wider than 72 columns that describe as much as 175 possible as to why this change is made, and possibly what things 176 it fixes and everything else that is related] 177 -- empty line -- 178 [Bug: URL to source of the report or more related discussion] 179 [Reported-by: John Doe - credit the reporter] 180 [whatever-else-by: credit all helpers, finders, doers] 181 ---- stop ---- 182 183Don't forget to use commit --author="" if you commit someone else's work, 184and make sure that you have your own user and email setup correctly in git 185before you commit 186 187### Write Access to git Repository 188 189If you are a very frequent contributor, you may be given push access to the 190git repository and then you'll be able to push your changes straight into the 191git repo instead of sending changes as pull requests or by mail as patches. 192 193Just ask if this is what you'd want. You will be required to have posted 194several high quality patches first, before you can be granted push access. 195 196### How To Make a Patch with git 197 198You need to first checkout the repository: 199 200 git clone https://github.com/curl/curl.git 201 202You then proceed and edit all the files you like and you commit them to your 203local repository: 204 205 git commit [file] 206 207As usual, group your commits so that you commit all changes that at once that 208constitutes a logical change. 209 210Once you have done all your commits and you're happy with what you see, you 211can make patches out of your changes that are suitable for mailing: 212 213 git format-patch remotes/origin/master 214 215This creates files in your local directory named NNNN-[name].patch for each 216commit. 217 218Now send those patches off to the curl-library list. You can of course opt to 219do that with the 'git send-email' command. 220 221### How To Make a Patch without git 222 223Keep a copy of the unmodified curl sources. Make your changes in a separate 224source tree. When you think you have something that you want to offer the 225curl community, use GNU diff to generate patches. 226 227If you have modified a single file, try something like: 228 229 diff -u unmodified-file.c my-changed-one.c > my-fixes.diff 230 231If you have modified several files, possibly in different directories, you 232can use diff recursively: 233 234 diff -ur curl-original-dir curl-modified-sources-dir > my-fixes.diff 235 236The GNU diff and GNU patch tools exist for virtually all platforms, including 237all kinds of Unixes and Windows: 238 239For unix-like operating systems: 240 241 - [https://savannah.gnu.org/projects/patch/](https://savannah.gnu.org/projects/patch/) 242 - [https://www.gnu.org/software/diffutils/](https://www.gnu.org/software/diffutils/) 243 244For Windows: 245 246 - [http://gnuwin32.sourceforge.net/packages/patch.htm](http://gnuwin32.sourceforge.net/packages/patch.htm) 247 - [http://gnuwin32.sourceforge.net/packages/diffutils.htm](http://gnuwin32.sourceforge.net/packages/diffutils.htm) 248