Patch Set 5: I would prefer that you didn't submit this; No score

Sorry this is turning into a nightmare, but the corresponding code in git-core is equally disastrous.  For legacy reasons, you can't just trust core.bare (turns out, this is actually my fault in git-core).  Even modern repositories sometimes don't have core.bare set, e.g. the `repo` tool used by Android forcibly removes core.bare when it creates a new git repository and requires the fallback detection logic to be used.

Given the complexity of this logic, I wonder if we shouldn't add some unit tests to help validate that the behavior matches what we expect to occur under the various states.