From 23c900f105dd88bb404cfada0377fa817881cff8 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sat, 29 Feb 2020 02:52:44 -0500 Subject: [PATCH] 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 Reviewed-by: David Pursehouse --- subcmds/sync.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/subcmds/sync.py b/subcmds/sync.py index ae29f085..dadf2e45 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py @@ -845,6 +845,13 @@ later is required to fix a server side protocol bug. 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()