Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Let's say I am working on an open source project and want to re-use a trivial utility function from another open source project (for example, a file search/replace function). Is it legal to copy the function and simply write a small copyright notice in top of the file? Should I include their name as copyright holders of the entire project in the license?

Similarly, let's say I fork an open source project. Where and how do I specify that the copyright is shared between both the original copyright holder and myself?

I guess the answer must somewhat vary according to the open source license but I'd like a general answer as much as possible.

PS: I'm mostly concerned about the legal aspect, but feel free to include your ethical point of view.

share|improve this question
What is the license of the project in question, and the project you are releasing? Yes, you can use the code, but please be more specific so that we can better inform you of your requirements under the license that is being used. – Tim Post Nov 29 '10 at 12:39
@Tim Post: It's mostly a theoretical question but if it can help let's suppose both projects have a GPL license since it's very common. – Olivier Lalonde Nov 29 '10 at 12:46
up vote 22 down vote accepted

I'm trying to make this answer as 'meta' applicable as possible.

Using snippets / bits from other projects

Clearly mark the code with the original author's copyright. Make sure that your license of choice is fully compatible with the license of the code you are using. You will need permission of the author to move the code to a different license (unless they specifically allow you to do so, I.e. "GPL 2 or any later version")

Your program should have an AUTHORS file (or similar), where you list all contributors and things that you used from other projects.

Forking a project

For each module that you substantially change, add your copyright under the original author's. The same thing goes for licensing, you are bound by the terms of the license that was in effect when you forked it. If the project says "GPL2 only", you must respect that, you can't go to GPL3 without their permission.

This varies, greatly, depending on the license at hand. The QPL says you can only distribute changes in patch format, for instance, so make sure you understand the terms that allow you to distribute modified versions of the software.

Beyond that, always preserve copyright. If adding your own copyright to what exists, be sure that you clearly mark exactly what you are claiming.

share|improve this answer
You can, sometimes, add licenses. Suppose you wanted to use a BSD function in a GPLed project: you can't remove the BSD license, but it is compatible with the GPL, so you can issue the whole project under the GPL and note that the function is also under the BSD license. It would be polite to release any changes you make to BSD-licensed code under the BSD. – David Thornley Nov 29 '10 at 15:21
@David - The OP wanted a generic answer (hence my urging to research the licenses). You are quite correct. HOWEVER, it is 'nice' to dual license any changes you made to the BSD code, so the original authors can actually use it if they want it. – Tim Post Nov 29 '10 at 15:50
At what point should the main license file have your copyright notice above the original authors'? When your SLOCs exceed 200% of the original project SLOCs? 300%? If the project you forked ends up being one of many librares or modules within your project? – hobs Apr 4 '13 at 18:04
@hobs imo, order of copyright notice is not an indication of the magnitude of contribution, but rather details chronologically the origins. – Technik Empire Nov 21 '15 at 12:16
@TechnikEmpire Chronological order makes sense, but for a contributors list rather than a copyright notice? I thought copyright notices might be better arranged according to the sections of code they apply to and the value/quantity of those sections in the package. It's useful to have a list of the people you need to contact, in order of priority, if you want to change something about the license. So if you get permission from the first few, but not the last, you have a smaller amount of code to recreate if you are determined to make the change. I wonder what Linus does? – hobs Nov 23 '15 at 20:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.