Correctly detect a git checkout. Refs #8090. Fixes #8266.

The problem is that when we `exec()` the version code from `setup.py`, the `__file__` paths changed and we were "missing" the `.git` directory.