summaryrefslogtreecommitdiffstats
path: root/subcmds/init.py
diff options
context:
space:
mode:
Diffstat (limited to 'subcmds/init.py')
-rw-r--r--subcmds/init.py24
1 files changed, 24 insertions, 0 deletions
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: