SCM-740 proper git-status handling if pwd is not the git root directory

thanks to Jan Novotny for catching this issue and providing a patch.
Applied with fixed imports and formatting.