Suppress error when visiting file in other than git repo

`magit-get-top-dir` say  `Wrong type argument: stringp, nil` when visiting file in other than git repository. This commit fix this issue.