From 3599cc397581086b7fddcd2e07308bfdac7751b1 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sat, 29 Feb 2020 02:53:41 -0500 Subject: init: respect --repo-rev changes We respect this option when running the first `repo init`, but then silently ignore it once the initial sync is done. Make sure users are able to change things on the fly. We refactor the wrapper API to allow reuse between the two init's. Bug: https://crbug.com/gerrit/11045 Change-Id: Icb89a8cddca32f39a760a6283152457810b2392d Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/260032 Tested-by: Mike Frysinger Reviewed-by: Jonathan Nieder --- subcmds/init.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'subcmds/init.py') diff --git a/subcmds/init.py b/subcmds/init.py index 431165d4..ce8b0187 100644 --- a/subcmds/init.py +++ b/subcmds/init.py @@ -38,6 +38,7 @@ from project import SyncBuffer from git_config import GitConfig from git_command import git_require, MIN_GIT_VERSION_SOFT, MIN_GIT_VERSION_HARD import platform_utils +from wrapper import Wrapper class Init(InteractiveCommand, MirrorSafeCommand): @@ -499,6 +500,16 @@ to update the working directory files. remote.url = opt.repo_url remote.Save() + # 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) + branch = rp.GetBranch('default') + branch.merge = remote_ref + rp.work_git.update_ref('refs/heads/default', rev) + branch.Save() + if opt.worktree: # Older versions of git supported worktree, but had dangerous gc bugs. git_require((2, 15, 0), fail=True, msg='git gc worktree corruption') -- cgit v1.2.3-54-g00ecf