Source Code Laundering: Git, Repo Count, and SOA
Join the DZone community and get the full member experience.Join For Free
each separate service means a separate git repository.
this is very popular these days. currently at least, until git adds big-repo capability (gigabytes of sources at head revision is problematic today). sometimes. i feel there’s sometimes a circular or bayesian association with git and small repos:
use git and you’re going to have many small repos.
have many small repos? – you’re using git.
of course i’m misusing bayes again . as a penance, i’d like to plug luana micallef’s 2.5 minute youtube clip on breast cancer likelihood . again.
one service per repo is popular, though. there’s a neatness to it, and a tighter understanding of what service needs to be redeployed after a period of development and what services do not. it could be a trap, but much of wielding conway’s sword risks that.
i think soon after git is able to perform with a bigger set of files at head, habits in that community will change.
what if you’re refactoring something, and need to do a set-piece extract of a component/service. say pre-existing services “a” contains a smaller piece that pre-existing service “b” could do with leveraging, without needed the rest of the “a” functionality. indeed, as you look at it more you see that it is indeed a “c” service that should have be eeked out earlier. so if “a” has a repo, and “b” has a repo, then “c” needs a repo. code is substantially going to leave one repo and arrive in another, even if we claim to have done a refactoring to get it there. in source-control terms there will be two commits – one a bunch of deletes in one repo, the other some corresponding additions in the new repo. two commits not one, and allegedly corresponding.
strictly speaking history is still there, but history tracing has been lost. sometimes your ide does this for you. most ides should be able to model file moves in ways that are more sophisticated than an add and a corresponding delete. in case they don’t then there is often a history repair feature of the source-control tool that allows you to fix it after the operation, but before the commit. fro example, the tortoisesvn docs have a section “repairing file renames”. other technologies may have similar capabilities. you can’t do that when the rename/move “mistake” is across two source-control repos though.
what if it wasn’t simply lines deleted and the same lines added in two repos (two commits)? what if something else changed in the same code-migration? that may have been accidental, but it could have been malicious. sure there’s a record of it, which is all you really need to be sarbanes-oxely compliant. but what about that diff? do people really look that closely when the commit message is “extracting c service from a, for a and b to both leverage”.
say part of the larger commit in the “a” repo, was:
say part of the larger commit in the new “c” repo, was:
no ability to leverage a “these files have moved” visual at all in the log given it is two commits in separate repos. spot the malicious code?
note too that, diffing is inconsistent when you compare source-control technologies for the “xyz.js moved directories” scenario, and more sophisticated cases. at least versus what it could be in an perfect world.
what that perfect world diff would look like if we had one big repo and the “c extraction” was completely within it, in a single atomic commit.
the attempt to hide the malicious code is more apparent. ok, so “source code laundering” as an analogy is a stretch, but it was worth a blog entry. by the way, credits go to neal b at my current client for blog title.
even as we consider for a second the creation of the c repo in itself, we must consider than an impediment to throughput, versus “make a directory” or c in a larger hierarchical trunk model. as regular developers, can we casually make new repos on the hosting platform? should we? will we, if we know it’s going to require conversations justifications? directories in an existing repo, seem a lot easier to make. indeed they’re a lot easier to delete too, if we change our minds (and not lose history).
back to git features
git has a “sparse checkouts” mode of operation. this is really neat in that it allows you to subset a checkout to just the pieces you want for the work at hand.
in a previous entry, i outlined how googlers subset their trunk , and this git mode feels like could use it for the same thing. the trouble is that it is not a “sparse clone” though, so the .git/ folder is still fetching zipped up things you don’t need in the working-copy.
it isn’t clear that git will ever get a proper “sparse clone” capability. ditto the fine-grained read/write permissions or acls that the industrial technologies have. in lieu of that you could use a perforce backend (for the truly big trunk), and their git-fusion product to do a real “sparse clone” with no downsides. atlassian’s writeup is fairly definitive on all of the large-repo considerations. it is fairly recent too.
subversion too has a sparse checkout capability. it is a little more clunky than the git equivalent, but it could be used to fashion a checkout that’s a subset, in the google trunk style.
microsoft’s .net open sourcing?
the opening of the .net framework landed source files on github essentially at revision 1:
too bad, there was a moment in 2000 when the .net source files were available under a “shared source” license, and a cursory inspection noted that the there were taligent copyrights in some of source files (as java did back then too). sure, microsoft’s license with sun allowed for such usages, but it would be awesome to rake over the full history (including moves/renames) to the day .net first started. that history was in sourcedepot (sd), no doubt, but that wasn’t licensed for public consumption, nor perhaps even suitable. it would have been great to see a full history including authors and contributors, whether currently at microsoft or alumni. i’m sure big-data and visualization people would have loved to do their stuff too.
Published at DZone with permission of Paul Hammant, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.