Fixed infinite loop when root folder is not a git repository

Looks like you just missed the "did I reach the root directory without finding anything" checks in a couple places.  So, I just copied the code from the place that had it to the two that were missing it.  This seems to fix the issue.