summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Schuberth <sschuberth@gmail.com>2018-07-13 10:25:52 +0200
committerSebastian Schuberth <sschuberth@gmail.com>2018-07-13 17:21:47 +0200
commit993dcacd17c6ea0d9c366c1bfc3e9579dfa19b44 (patch)
tree245ef01845075e0ac6831f6ead374834f299939a
parentb10f0e5b9a9ba6d8e9a27b3a81d2fc1d65d9810d (diff)
downloadgit-repo-993dcacd17c6ea0d9c366c1bfc3e9579dfa19b44.tar.gz
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
-rwxr-xr-xrepo9
1 files changed, 5 insertions, 4 deletions
diff --git a/repo b/repo
index 13ccd2ba..78cb41bf 100755
--- a/repo
+++ b/repo
@@ -357,16 +357,17 @@ def _Init(args, gitc_init=False):
357 dst = os.path.abspath(os.path.join(repodir, S_repo)) 357 dst = os.path.abspath(os.path.join(repodir, S_repo))
358 _Clone(url, dst, opt.quiet, not opt.no_clone_bundle) 358 _Clone(url, dst, opt.quiet, not opt.no_clone_bundle)
359 359
360 if not os.path.isfile('%s/repo' % dst):
361 _print("warning: '%s' does not look like a git-repo repository, is "
362 "REPO_URL set correctly?" % url, file=sys.stderr)
363
364 if can_verify and not opt.no_repo_verify: 360 if can_verify and not opt.no_repo_verify:
365 rev = _Verify(dst, branch, opt.quiet) 361 rev = _Verify(dst, branch, opt.quiet)
366 else: 362 else:
367 rev = 'refs/remotes/origin/%s^0' % branch 363 rev = 'refs/remotes/origin/%s^0' % branch
368 364
369 _Checkout(dst, branch, rev, opt.quiet) 365 _Checkout(dst, branch, rev, opt.quiet)
366
367 if not os.path.isfile(os.path.join(dst, 'repo')):
368 _print("warning: '%s' does not look like a git-repo repository, is "
369 "REPO_URL set correctly?" % url, file=sys.stderr)
370
370 except CloneFailure: 371 except CloneFailure:
371 if opt.quiet: 372 if opt.quiet:
372 _print('fatal: repo init failed; run without --quiet to see why', 373 _print('fatal: repo init failed; run without --quiet to see why',