Patch Set 6: I would prefer that you didn't submit this

Logic looks right now.

Before we submit I think we need:

* Unit tests for the branches in the constructor.
* Consistency in the type of exception thrown when bare.
* Allow setWorkDir on a bare repository, making it non-bare.