From 4aa8584ec6a57b24c7e41e6fccd0b554a264423d Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 25 Jan 2022 02:10:28 -0500 Subject: [PATCH] init: make bad --repo-rev settings more clear If the user passes a bad --repo-rev setting in a new checkout, add a tip to the error message that their option is probably bad instead of just saying "unable to resolve". If the user has already initialized a checkout, we'd display a raw traceback which would confuse them. Swallow that and also include the --repo-rev tip. Bug: https://crbug.com/gerrit/15610 Change-Id: I5d72513c7b37bf9bb5d19862fcdfaf0d1f44e886 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/328820 Reviewed-by: Jack Neus Tested-by: Mike Frysinger --- repo | 1 + subcmds/init.py | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/repo b/repo index 2af77ace..6d7ce42a 100755 --- a/repo +++ b/repo @@ -618,6 +618,7 @@ def _Init(args, gitc_init=False): "REPO_URL set correctly?" % url, file=sys.stderr) except CloneFailure: + print('fatal: double check your --repo-rev setting.', file=sys.stderr) if opt.quiet: print('fatal: repo init failed; run without --quiet to see why', file=sys.stderr) diff --git a/subcmds/init.py b/subcmds/init.py index e2f34cc8..b0db76a4 100644 --- a/subcmds/init.py +++ b/subcmds/init.py @@ -520,8 +520,12 @@ to update the working directory files. # Handle new --repo-rev requests. if opt.repo_rev: wrapper = Wrapper() - remote_ref, rev = wrapper.check_repo_rev( - rp.gitdir, opt.repo_rev, repo_verify=opt.repo_verify, quiet=opt.quiet) + try: + remote_ref, rev = wrapper.check_repo_rev( + rp.gitdir, opt.repo_rev, repo_verify=opt.repo_verify, quiet=opt.quiet) + except wrapper.CloneFailure: + print('fatal: double check your --repo-rev setting.', file=sys.stderr) + sys.exit(1) branch = rp.GetBranch('default') branch.merge = remote_ref rp.work_git.reset('--hard', rev)