sync: warn if not tracking a branch
Since tracking a branch prevents repo from updating, make sure we
warn people about the situation when using `repo sync`.
Bug: https://crbug.com/gerrit/11045
Change-Id: I966513f510827cc93194f8df176c6745946bd739
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/258892
Tested-by: Mike Frysinger <vapier@google.com>
Reviewed-by: David Pursehouse <dpursehouse@collab.net>
diff --git a/subcmds/sync.py b/subcmds/sync.py
index ae29f08..dadf2e4 100644
--- a/subcmds/sync.py
+++ b/subcmds/sync.py
@@ -845,6 +845,13 @@
rp = self.manifest.repoProject
rp.PreSync()
+ cb = rp.CurrentBranch
+ if cb:
+ base = rp.GetBranch(cb).merge
+ if not base or not base.startswith('refs/heads/'):
+ print('warning: repo is not tracking a remote branch, so it will not '
+ 'receive updates; run `repo init --repo-branch=stable` to fix.',
+ file=sys.stderr)
mp = self.manifest.manifestProject
mp.PreSync()