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

(2 inline comments)

Could you please file a bug for what you are trying to fix here ? Explain what's the misbehavior and also add the stack trace.

I think providing a generic error message doesn't really fix the problem, instead we should handle bare repository in a different way. We know that this exception would occur if the repo is bare, so we should handle this case appropriately instead of frightening the user with a hard to understand error message.