Deciding "bareness" is more than just looking at core.bare in the configuration file.

IIRC the algorithm is something like:

  IF core.bare is set
    USE core.bare

  ELSE IF GIT_DIR explicitly given and no GIT_WORK_TREE
    ASSUME bare

  ELSE IF getDirectory().getName() is exactly ".git"
    ASSUME not bare

  ELSE
    ASSUME bare

Since this is complex enough, and the code throws an exception if its bare, we probably should introduce a:

  public boolean isBare()

method to perform the decision making, and then define getWorkDir to throw when isBare() is true.

Also, bare repositories don't have index files, so getIndex() and getIndexFile() should also throw the same exception.