From 8d43dea6ea4b7d1664632e555e207f617e54657b Mon Sep 17 00:00:00 2001 From: Raman Tenneti Date: Sun, 7 Feb 2021 16:30:27 -0800 Subject: sync: pass --bare option when doing git clone of superproject. Changed "git pull" to "git fetch" as we are using --bare option. Used the following command to fetch: git fetch origin +refs/heads/*:refs/heads/* --prune Pass --branch argument to Superproject's UpdateProjectsRevisionId function. Returned False/None when directories don't exist instead of raise GitError exception from _Fetch and _LsTree functions. The caller of Fetch does Clone if Fetch fails. Tested the code with the following commands. $ ./run_tests -v Tested the init and sync code by copying all the repo changes into my Android AOSP checkout and running repo sync with --use-superproject option. Bug: https://crbug.com/gerrit/13709 Bug: https://crbug.com/gerrit/13707 Tested-by: Raman Tenneti Change-Id: I3e441ecdfc87c735f46eff0eb98efa63cc2eb22a Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/296222 Reviewed-by: Mike Frysinger --- subcmds/sync.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'subcmds/sync.py') diff --git a/subcmds/sync.py b/subcmds/sync.py index c0f605a8..5855af55 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py @@ -271,6 +271,15 @@ later is required to fix a server side protocol bug. dest='repo_upgraded', action='store_true', help=SUPPRESS_HELP) + def _GetBranch(self): + """Returns the branch name for getting the approved manifest.""" + p = self.manifest.manifestProject + b = p.GetBranch(p.CurrentBranch) + branch = b.merge + if branch.startswith(R_HEADS): + branch = branch[len(R_HEADS):] + return branch + def _UpdateProjectsRevisionId(self, opt, args): """Update revisionId of every project with the SHA from superproject. @@ -302,9 +311,11 @@ later is required to fix a server side protocol bug. all_projects = self.GetProjects(args, missing_ok=True, submodules_ok=opt.fetch_submodules) + branch = self._GetBranch() manifest_path = superproject.UpdateProjectsRevisionId(self.manifest, all_projects, - url=superproject_url) + url=superproject_url, + branch=branch) if not manifest_path: print('error: Update of revsionId from superproject has failed', file=sys.stderr) @@ -753,11 +764,7 @@ later is required to fix a server side protocol bug. try: server = xmlrpc.client.Server(manifest_server, transport=transport) if opt.smart_sync: - p = self.manifest.manifestProject - b = p.GetBranch(p.CurrentBranch) - branch = b.merge - if branch.startswith(R_HEADS): - branch = branch[len(R_HEADS):] + branch = self._GetBranch() if 'SYNC_TARGET' in os.environ: target = os.environ['SYNC_TARGET'] -- cgit v1.2.3-54-g00ecf