The main gitshed functionality.

Pulls together code from previous commits.

The main() wrapper, BUILD files etc. will follow shortly.
Hmmm, I thought about it some more and stared at the code for a while, and concluded that I still prefer it the way it is. It's not a huge issue either way since this is such a tiny method. It may be the influence of Scala, but I know I've created more bugs due to not noticing an early return than I have due to indentation errors...

Let's agree to disagree on this one...