Update top_dir with git repo root just when cwd locate in a git repo.

if when execute command "git rev-parse --show-toplevel" in a directory
that is not a subdirectory of a git repo, CheckCallAndFilter will not
throw exception, so the top_dir may be updated with a invalid path.

BUG=633971

Signed-off-by: hanpfei <hanpfei@gmail.com>
Review-Url: https://codereview.chromium.org/2200193003
changes/90/365990/3
hanpfei 9 years ago committed by Commit bot
parent 4b8ed59b7b
commit 13f9c37185

@ -671,7 +671,9 @@ def GetPrimarySolutionPath():
# checkout.
top_dir = [os.getcwd()]
def filter_fn(line):
top_dir[0] = os.path.normpath(line.rstrip('\n'))
repo_root_path = os.path.normpath(line.rstrip('\n'))
if os.path.exists(repo_root_path):
top_dir[0] = repo_root_path
try:
CheckCallAndFilter(["git", "rev-parse", "--show-toplevel"],
print_stdout=False, filter_fn=filter_fn)

Loading…
Cancel
Save