From 993dcacd17c6ea0d9c366c1bfc3e9579dfa19b44 Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Fri, 13 Jul 2018 10:25:52 +0200 Subject: [PATCH] Fix the initial existence check for "repo" Commit 27226e742d7e1a3d371531c19a3fdd91a4f9ab4a introduced a warning if "repo" is not part of the bootstrapped REPO_URL. However, that check was done too early, directly after the call to _Clone. As the _Clone function does not actually clone but it only initializes and fetches, the check needs to be moved to after the call to _Checkout. To reproduce, call repo init --no-clone-bundle --repo-branch=master -u https://android.googlesource.com/platform/manifest which will currently always show the (bogus) warning message. With this fix, the warning will only be shown if "repo" indeed does not exist. While at it, also slightly improve the code by using os.path.join(). Change-Id: Ied89e24231addabab6075005065748df1ffa74c4 --- repo | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/repo b/repo index 13ccd2b..78cb41b 100755 --- a/repo +++ b/repo @@ -357,16 +357,17 @@ def _Init(args, gitc_init=False): dst = os.path.abspath(os.path.join(repodir, S_repo)) _Clone(url, dst, opt.quiet, not opt.no_clone_bundle) - if not os.path.isfile('%s/repo' % dst): - _print("warning: '%s' does not look like a git-repo repository, is " - "REPO_URL set correctly?" % url, file=sys.stderr) - if can_verify and not opt.no_repo_verify: rev = _Verify(dst, branch, opt.quiet) else: rev = 'refs/remotes/origin/%s^0' % branch _Checkout(dst, branch, rev, opt.quiet) + + if not os.path.isfile(os.path.join(dst, 'repo')): + _print("warning: '%s' does not look like a git-repo repository, is " + "REPO_URL set correctly?" % url, file=sys.stderr) + except CloneFailure: if opt.quiet: _print('fatal: repo init failed; run without --quiet to see why',