Fix upward directory traversing if no repository is found

Getting revision of repository results in infinite loop if no repository was found.
A os.chdir(os.pardir) starting at / results in / as current dir. This leads to the solution
that if current dir equals old current dir there is no more parent directories.