diff options
author | Mike Frysinger <vapier@google.com> | 2020-02-29 02:53:41 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@google.com> | 2020-03-25 04:55:50 +0000 |
commit | 3599cc397581086b7fddcd2e07308bfdac7751b1 (patch) | |
tree | 5ae663f1830fa7d29ec66c86e2088244f7fa2e5a /subcmds | |
parent | cfc8111f5e04ece139892bb9af4bd63aac2b75f3 (diff) | |
download | git-repo-3599cc397581086b7fddcd2e07308bfdac7751b1.tar.gz |
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 <vapier@google.com>
Reviewed-by: Jonathan Nieder <jrn@google.com>
Diffstat (limited to 'subcmds')
-rw-r--r-- | subcmds/init.py | 11 |
1 files changed, 11 insertions, 0 deletions
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 | |||
38 | from git_config import GitConfig | 38 | from git_config import GitConfig |
39 | from git_command import git_require, MIN_GIT_VERSION_SOFT, MIN_GIT_VERSION_HARD | 39 | from git_command import git_require, MIN_GIT_VERSION_SOFT, MIN_GIT_VERSION_HARD |
40 | import platform_utils | 40 | import platform_utils |
41 | from wrapper import Wrapper | ||
41 | 42 | ||
42 | 43 | ||
43 | class Init(InteractiveCommand, MirrorSafeCommand): | 44 | class Init(InteractiveCommand, MirrorSafeCommand): |
@@ -499,6 +500,16 @@ to update the working directory files. | |||
499 | remote.url = opt.repo_url | 500 | remote.url = opt.repo_url |
500 | remote.Save() | 501 | remote.Save() |
501 | 502 | ||
503 | # Handle new --repo-rev requests. | ||
504 | if opt.repo_rev: | ||
505 | wrapper = Wrapper() | ||
506 | remote_ref, rev = wrapper.check_repo_rev( | ||
507 | rp.gitdir, opt.repo_rev, repo_verify=opt.repo_verify, quiet=opt.quiet) | ||
508 | branch = rp.GetBranch('default') | ||
509 | branch.merge = remote_ref | ||
510 | rp.work_git.update_ref('refs/heads/default', rev) | ||
511 | branch.Save() | ||
512 | |||
502 | if opt.worktree: | 513 | if opt.worktree: |
503 | # Older versions of git supported worktree, but had dangerous gc bugs. | 514 | # Older versions of git supported worktree, but had dangerous gc bugs. |
504 | git_require((2, 15, 0), fail=True, msg='git gc worktree corruption') | 515 | git_require((2, 15, 0), fail=True, msg='git gc worktree corruption') |