diff options
author | Martin Kelly <mkelly@xevo.com> | 2017-03-21 16:05:12 -0700 |
---|---|---|
committer | Martin Kelly <mkelly@xevo.com> | 2017-05-23 16:51:31 -0700 |
commit | e4e94d26ae81dbc9eb6e2f345fac7cd8c533cb9a (patch) | |
tree | 1fe598a2b3e89ae9a56fd640e6cd5b53a8704c7a /subcmds/init.py | |
parent | ffb4b890997b1799f188ec44f005d949feb643a7 (diff) | |
download | git-repo-e4e94d26ae81dbc9eb6e2f345fac7cd8c533cb9a.tar.gz |
init: add --submodules to sync manifest submodules
repo sync can sync submodules via the --fetch-submodules option.
However, if the manifest repo has submodules, those will not be synced.
Having submodules in the manifest repo -- while not commonly done -- can
be useful for inheriting a manifest from another project using <include>
and layering changes on top of it. In this way, you can avoid having to
deal with merge conflicts between your own manifests and the other
project's manifests (for example, if you're managing an Android fork).
Add a --submodule option to init that automatically syncs the submodules
in the manifest repo whenever the manifest repo changes.
Change-Id: I45d34f04517774c1462d7f233f482d1d81a332a8
Signed-off-by: Martin Kelly <mkelly@xevo.com>
Diffstat (limited to 'subcmds/init.py')
-rw-r--r-- | subcmds/init.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/subcmds/init.py b/subcmds/init.py index bb7187d7..b260ec0f 100644 --- a/subcmds/init.py +++ b/subcmds/init.py | |||
@@ -111,6 +111,9 @@ to update the working directory files. | |||
111 | dest='archive', action='store_true', | 111 | dest='archive', action='store_true', |
112 | help='checkout an archive instead of a git repository for ' | 112 | help='checkout an archive instead of a git repository for ' |
113 | 'each project. See git archive.') | 113 | 'each project. See git archive.') |
114 | g.add_option('--submodules', | ||
115 | dest='submodules', action='store_true', | ||
116 | help='sync any submodules associated with the manifest repo') | ||
114 | g.add_option('-g', '--groups', | 117 | g.add_option('-g', '--groups', |
115 | dest='groups', default='default', | 118 | dest='groups', default='default', |
116 | help='restrict manifest projects to ones with specified ' | 119 | help='restrict manifest projects to ones with specified ' |
@@ -236,10 +239,13 @@ to update the working directory files. | |||
236 | 'in another location.', file=sys.stderr) | 239 | 'in another location.', file=sys.stderr) |
237 | sys.exit(1) | 240 | sys.exit(1) |
238 | 241 | ||
242 | if opt.submodules: | ||
243 | m.config.SetString('repo.submodules', 'true') | ||
244 | |||
239 | if not m.Sync_NetworkHalf(is_new=is_new, quiet=opt.quiet, | 245 | if not m.Sync_NetworkHalf(is_new=is_new, quiet=opt.quiet, |
240 | clone_bundle=not opt.no_clone_bundle, | 246 | clone_bundle=not opt.no_clone_bundle, |
241 | current_branch_only=opt.current_branch_only, | 247 | current_branch_only=opt.current_branch_only, |
242 | no_tags=opt.no_tags): | 248 | no_tags=opt.no_tags, submodules=opt.submodules): |
243 | r = m.GetRemote(m.remote.name) | 249 | r = m.GetRemote(m.remote.name) |
244 | print('fatal: cannot obtain manifest %s' % r.url, file=sys.stderr) | 250 | print('fatal: cannot obtain manifest %s' % r.url, file=sys.stderr) |
245 | 251 | ||
@@ -253,7 +259,7 @@ to update the working directory files. | |||
253 | m.MetaBranchSwitch() | 259 | m.MetaBranchSwitch() |
254 | 260 | ||
255 | syncbuf = SyncBuffer(m.config) | 261 | syncbuf = SyncBuffer(m.config) |
256 | m.Sync_LocalHalf(syncbuf) | 262 | m.Sync_LocalHalf(syncbuf, submodules=opt.submodules) |
257 | syncbuf.Finish() | 263 | syncbuf.Finish() |
258 | 264 | ||
259 | if is_new or m.CurrentBranch is None: | 265 | if is_new or m.CurrentBranch is None: |