diff options
author | Doug Anderson <dianders@chromium.org> | 2011-05-04 15:01:04 -0700 |
---|---|---|
committer | Doug Anderson <dianders@chromium.org> | 2011-06-09 16:48:23 -0700 |
commit | 30d452905f166b316152f236422f85c8aa75a2d0 (patch) | |
tree | cc6a18adb2ea8c0f209f21aca2e64fe20fb06005 /subcmds/init.py | |
parent | d6c93a28ca8cb079f473f749d805dcff97990225 (diff) | |
download | git-repo-30d452905f166b316152f236422f85c8aa75a2d0.tar.gz |
Add a --depth option to repo init.v1.7.5
Change-Id: Id30fb4a85f4f8a1847420b0b51a86060041eb5bf
Diffstat (limited to 'subcmds/init.py')
-rw-r--r-- | subcmds/init.py | 24 |
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: |