magit-get-top-dir: fix if in .git directory

If we are in repo/.git, magit-get-top-dir will return nil. Fix this by
explicitly checking for .git in the working directory and returning the
preceeding path if so.

Among other things, this fixes a bug in git-rebase-mode, where you can't
view commits because default-directory is set to repo/.git/rebase-merge/.