diff options
-rw-r--r-- | project.py | 7 | ||||
-rw-r--r-- | subcmds/init.py | 24 |
2 files changed, 31 insertions, 0 deletions
@@ -1370,6 +1370,13 @@ class Project(object): | |||
1370 | ref_dir = None | 1370 | ref_dir = None |
1371 | 1371 | ||
1372 | cmd = ['fetch'] | 1372 | cmd = ['fetch'] |
1373 | |||
1374 | # The --depth option only affects the initial fetch; after that we'll do | ||
1375 | # full fetches of changes. | ||
1376 | depth = self.manifest.manifestProject.config.GetString('repo.depth') | ||
1377 | if depth and initial: | ||
1378 | cmd.append('--depth=%s' % depth) | ||
1379 | |||
1373 | if quiet: | 1380 | if quiet: |
1374 | cmd.append('--quiet') | 1381 | cmd.append('--quiet') |
1375 | if not self.worktree: | 1382 | if not self.worktree: |
diff --git a/subcmds/init.py b/subcmds/init.py index 37910843..c35cc82c 100644 --- a/subcmds/init.py +++ b/subcmds/init.py | |||
@@ -82,6 +82,9 @@ to update the working directory files. | |||
82 | g.add_option('--reference', | 82 | g.add_option('--reference', |
83 | dest='reference', | 83 | dest='reference', |
84 | help='location of mirror directory', metavar='DIR') | 84 | help='location of mirror directory', metavar='DIR') |
85 | g.add_option('--depth', type='int', default=None, | ||
86 | dest='depth', | ||
87 | help='create a shallow clone with given depth; see git clone') | ||
85 | 88 | ||
86 | # Tool | 89 | # Tool |
87 | g = p.add_option_group('repo Version options') | 90 | g = p.add_option_group('repo Version options') |
@@ -232,6 +235,25 @@ to update the working directory files. | |||
232 | if a in ('y', 'yes', 't', 'true', 'on'): | 235 | if a in ('y', 'yes', 't', 'true', 'on'): |
233 | gc.SetString('color.ui', 'auto') | 236 | gc.SetString('color.ui', 'auto') |
234 | 237 | ||
238 | def _ConfigureDepth(self, opt): | ||
239 | """Configure the depth we'll sync down. | ||
240 | |||
241 | Args: | ||
242 | opt: Options from optparse. We care about opt.depth. | ||
243 | """ | ||
244 | # Opt.depth will be non-None if user actually passed --depth to repo init. | ||
245 | if opt.depth is not None: | ||
246 | if opt.depth > 0: | ||
247 | # Positive values will set the depth. | ||
248 | depth = str(opt.depth) | ||
249 | else: | ||
250 | # Negative numbers will clear the depth; passing None to SetString | ||
251 | # will do that. | ||
252 | depth = None | ||
253 | |||
254 | # We store the depth in the main manifest project. | ||
255 | self.manifest.manifestProject.config.SetString('repo.depth', depth) | ||
256 | |||
235 | def Execute(self, opt, args): | 257 | def Execute(self, opt, args): |
236 | git_require(MIN_GIT_VERSION, fail=True) | 258 | git_require(MIN_GIT_VERSION, fail=True) |
237 | self._SyncManifest(opt) | 259 | self._SyncManifest(opt) |
@@ -241,6 +263,8 @@ to update the working directory files. | |||
241 | self._ConfigureUser() | 263 | self._ConfigureUser() |
242 | self._ConfigureColor() | 264 | self._ConfigureColor() |
243 | 265 | ||
266 | self._ConfigureDepth(opt) | ||
267 | |||
244 | if self.manifest.IsMirror: | 268 | if self.manifest.IsMirror: |
245 | type = 'mirror ' | 269 | type = 'mirror ' |
246 | else: | 270 | else: |