autobuild: Simplify find_git_root.
authorJelmer Vernooij <jelmer@samba.org>
Wed, 29 Sep 2010 00:38:18 +0000 (02:38 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Fri, 1 Oct 2010 09:03:18 +0000 (11:03 +0200)
script/autobuild.py

index 6f1484533471004b6b45eefedce22adb7df7625c..246eaf7fe8f4ec3d40b70e8867f4e47db249d545 100755 (executable)
@@ -241,19 +241,14 @@ def cleanup():
 
 def find_git_root():
     '''get to the top of the git repo'''
-    cwd=os.getcwd()
-    while os.getcwd() != '/':
-        try:
-            os.stat(".git")
-            ret = os.getcwd()
-            os.chdir(cwd)
-            return ret
-        except:
-            os.chdir("..")
-            pass
-    os.chdir(cwd)
+    p=os.getcwd()
+    while p != '/':
+        if os.path.isdir(os.path.join(p, ".git")):
+            return p
+        p = os.path.abspath(os.path.join(p, '..'))
     return None
 
+
 def rebase_tree(url):
     print("Rebasing on %s" % url)
     run_cmd("git remote add -t master master %s" % url, show=True, dir=test_master)