init: respect --repo-url 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.
Bug: https://crbug.com/gerrit/11045
Change-Id: I129ec5fec43a85067d555bb60c0d1ae02465f139
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/258893
Tested-by: David Pursehouse <dpursehouse@collab.net>
Reviewed-by: David Pursehouse <dpursehouse@collab.net>
diff --git a/subcmds/init.py b/subcmds/init.py
index 2003006..94bd44c 100644
--- a/subcmds/init.py
+++ b/subcmds/init.py
@@ -490,6 +490,14 @@
opt.quiet = opt.output_mode is False
opt.verbose = opt.output_mode is True
+ rp = self.manifest.repoProject
+
+ # Handle new --repo-url requests.
+ if opt.repo_url:
+ remote = rp.GetRemote('origin')
+ remote.url = opt.repo_url
+ remote.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')