summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Frysinger <vapier@google.com>2020-12-05 22:57:19 -0500
committerMike Frysinger <vapier@google.com>2020-12-06 21:46:30 +0000
commit5e2f32fe1398ba1dbdee81a248ab88d6f269002d (patch)
tree3bd9063b3450439ac19ecb042aaa07c46c318b36
parent51e39d536d9210dbae285f330a8ecb697d52aac6 (diff)
downloadgit-repo-5e2f32fe1398ba1dbdee81a248ab88d6f269002d.tar.gz
init: reset hard to --repo-rev
When updating the tracking ref to whatever the user requested, make sure we reset state completely rather than trying to update the ref to it. This avoids confusing git as to the current state of the tree, and is more inline with user intentions: if they made a local change to the checkout, but ran repo init with a specific rev, we shouldn't stay wedged forever until they manually clean it all up. Bug: https://crbug.com/gerrit/12801 Change-Id: Ieba8d9c15781b4d0649bf01c7460694da63387b2 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/290923 Reviewed-by: Michael Mortensen <mmortensen@google.com> Tested-by: Mike Frysinger <vapier@google.com>
-rw-r--r--subcmds/init.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/subcmds/init.py b/subcmds/init.py
index f46babfe..af3685a0 100644
--- a/subcmds/init.py
+++ b/subcmds/init.py
@@ -521,7 +521,7 @@ to update the working directory files.
521 rp.gitdir, opt.repo_rev, repo_verify=opt.repo_verify, quiet=opt.quiet) 521 rp.gitdir, opt.repo_rev, repo_verify=opt.repo_verify, quiet=opt.quiet)
522 branch = rp.GetBranch('default') 522 branch = rp.GetBranch('default')
523 branch.merge = remote_ref 523 branch.merge = remote_ref
524 rp.work_git.update_ref('refs/heads/default', rev) 524 rp.work_git.reset('--hard', rev)
525 branch.Save() 525 branch.Save()
526 526
527 if opt.worktree: 527 if opt.worktree: