I have taken a small chunk of open-source code, around a hundred lines, and found that for whatever reason, I have modified it so drastically that my end result has essentially no resemblance to the original. Maybe a line or two, and a few variable names, are carried over, but the diff is just one or more big chunks of - followed by big chunks of +.If I'm now distributing my code, it seems clear to me that I should globally credit the original author for providing a foundation, and include the license under which I acquired the code. I'm wondering what my responsibilities in the social or technical dimensions are to mark specific changes, though. Am I rudely misrepresenting the original author's work when I say that mine is derived from it without pointing out the particular lines that were carried over? Is it helpful for another coder looking at my version if I include comments annotating what I've kept and why?I've used someone else's code as a starting point, taking primarily the ideas and not the substance. Ignoring any legal aspects,* what kind of precise, targeted change documentation should I ideally provide?What is proper etiquette for releasing a complete rewrite of an existing project? is closely related, but I've already chosen option 1. Best practices when forking code base is also related but doesn't address the specificity of attribution.*Various aspects of which have already been covered here.
Marking specific pieces of drastically changed open source code
open source;documentation;attribution
Your basic obligation is to follow the original author's license terms.  But beyond that, it's a good idea to mark off the section with comments that indicate the original source of the code.  That allows others to follow the chain back to its origin, and bugs in one might be present in the other.That said, there are many examples of open source or free software where this isn't the practice.  In fact, the larger the project, the less likely it is that you'll find such micro-attributions.