I just read the git-blame manual page once more and noticed this part:
A particularly useful way is to see if an added file has lines created by copy-and-paste from existing files. Sometimes this indicates that the developer was being sloppy and did not refactor the code properly. You can first find the commit that introduced the file with:
git log --diff-filter=A --pretty=short -- foo
and then annotate the change between the commit and its parents, using commit^! notation:
git blame -C -C -f $commit^! -- foo
This sounds quite interesting, but I don't quite grok how it works, and why. I wonder whether it can be used in a git hook to detect copy & pasted code.
Can some git expert maybe explain the effect of using the above git commands together, and whether it's possible to use something like that to make git show whether there's code duplication (maybe by using the 'similarity index' which git seems to computed when renaming files)?