I think the better approach here is:

 if (workTreeConfig != null) {
    workDir = fs.resolve(d, workTreeConfig);
 } else if (getConfig().getString("core", null, "bare") != null)) {
    if (getConfig().getBoolean("core", "bare", true))
      workDir = gitDir.getParentFile();
    else
      workDir = null;
 } else if (Constants.DOT_GIT.equals(gitDir.getName())) {
    workDir = gitDir.getParentFile();
 } else {
    workDir = null;
 }

No, its not pretty.  None of the "setup" code in git-core is sane.  Its a horrible mess that nobody likes to touch, because the algorithm is completely, utterly broken, but users just expect it to keep working like it has been.