From 28a3d2ea3003d2fcabdfff209db945ad9ec86f87 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 29 Sep 2010 02:38:18 +0200 Subject: autobuild: Simplify find_git_root. --- script/autobuild.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'script') diff --git a/script/autobuild.py b/script/autobuild.py index 6f14845334..246eaf7fe8 100755 --- a/script/autobuild.py +++ b/script/autobuild.py @@ -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) -- cgit