summaryrefslogtreecommitdiffstats
path: root/subcmds/sync.py
diff options
context:
space:
mode:
authorChe-Liang Chiou <clchiou@google.com>2012-01-11 11:28:42 +0800
committerChe-Liang Chiou <clchiou@google.com>2012-10-23 16:08:58 -0700
commit69998b0c6ff724bf620480140ccce648fec7d6a9 (patch)
treeb6f9c4c00b04a0f140074c4c2dba91ed4f055b11 /subcmds/sync.py
parent5c6eeac8f0350fd6b14cf226ffcff655f1dd9582 (diff)
downloadgit-repo-69998b0c6ff724bf620480140ccce648fec7d6a9.tar.gz
Represent git-submodule as nested projects
We need a representation of git-submodule in repo; otherwise repo will not sync submodules, and leave workspace in a broken state. Of course this will not be a problem if all projects are owned by the owner of the manifest file, who may simply choose not to use git-submodule in all projects. However, this is not possible in practice because manifest file owner is unlikely to own all upstream projects. As git submodules are simply git repositories, it is natural to treat them as plain repo projects that live inside a repo project. That is, we could use recursively declared projects to denote the is-submodule relation of git repositories. The behavior of repo remains the same to projects that do not have a sub-project within. As for parent projects, repo fetches them and their sub-projects as normal projects, and then checks out subprojects at the commit specified in parent's commit object. The sub-project is fetched at a path relative to parent project's working directory; so the path specified in manifest file should match that of .gitmodules file. If a submodule is not registered in repo manifest, repo will derive its properties from itself and its parent project, which might not always be correct. In such cases, the subproject is called a derived subproject. To a user, a sub-project is merely a git-submodule; so all tips of working with a git-submodule apply here, too. For example, you should not run `repo sync` in a parent repository if its submodule is dirty. Change-Id: I541e9e2ac1a70304272dbe09724572aa1004eb5c
Diffstat (limited to 'subcmds/sync.py')
-rw-r--r--subcmds/sync.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py
index e68a025e..90e2908f 100644
--- a/subcmds/sync.py
+++ b/subcmds/sync.py
@@ -503,12 +503,31 @@ uncommitted changes are present' % project.relpath
503 to_fetch.append(rp) 503 to_fetch.append(rp)
504 to_fetch.extend(all_projects) 504 to_fetch.extend(all_projects)
505 505
506 self._Fetch(to_fetch, opt) 506 fetched = self._Fetch(to_fetch, opt)
507 _PostRepoFetch(rp, opt.no_repo_verify) 507 _PostRepoFetch(rp, opt.no_repo_verify)
508 if opt.network_only: 508 if opt.network_only:
509 # bail out now; the rest touches the working tree 509 # bail out now; the rest touches the working tree
510 return 510 return
511 511
512 # Iteratively fetch missing and/or nested unregistered submodules
513 previously_missing_set = set()
514 while True:
515 self.manifest._Unload()
516 all = self.GetProjects(args, missing_ok=True)
517 missing = []
518 for project in all:
519 if project.gitdir not in fetched:
520 missing.append(project)
521 if not missing:
522 break
523 # Stop us from non-stopped fetching actually-missing repos: If set of
524 # missing repos has not been changed from last fetch, we break.
525 missing_set = set(p.name for p in missing)
526 if previously_missing_set == missing_set:
527 break
528 previously_missing_set = missing_set
529 fetched.update(self._Fetch(missing, opt))
530
512 if self.manifest.IsMirror: 531 if self.manifest.IsMirror:
513 # bail out now, we have no working tree 532 # bail out now, we have no working tree
514 return 533 return