magit-get-top-dir: fix two issues

* Previously `magit-get-top-dir' didn't do the right thing when passed
  the name of a directory without a trailing slash.  Now it does but
  that comes at the cost of no longer excepting a regular file as
  input.

* Previously `magit-get-top-dir' didn't do the right thing when inside
  the .git directory.  Now it does.