diff options
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 3c68c2c3..8a29321e 100644 --- a/subcmds/init.py +++ b/subcmds/init.py | |||
@@ -15,6 +15,8 @@ | |||
15 | # limitations under the License. | 15 | # limitations under the License. |
16 | 16 | ||
17 | from __future__ import print_function | 17 | from __future__ import print_function |
18 | |||
19 | import optparse | ||
18 | import os | 20 | import os |
19 | import platform | 21 | import platform |
20 | import re | 22 | import re |
@@ -128,6 +130,10 @@ to update the working directory files. | |||
128 | g.add_option('--clone-filter', action='store', default='blob:none', | 130 | g.add_option('--clone-filter', action='store', default='blob:none', |
129 | dest='clone_filter', | 131 | dest='clone_filter', |
130 | help='filter for use with --partial-clone [default: %default]') | 132 | help='filter for use with --partial-clone [default: %default]') |
133 | # TODO(vapier): Expose option with real help text once this has been in the | ||
134 | # wild for a while w/out significant bug reports. Goal is by ~Sep 2020. | ||
135 | g.add_option('--worktree', action='store_true', | ||
136 | help=optparse.SUPPRESS_HELP) | ||
131 | g.add_option('--archive', | 137 | g.add_option('--archive', |
132 | dest='archive', action='store_true', | 138 | dest='archive', action='store_true', |
133 | help='checkout an archive instead of a git repository for ' | 139 | help='checkout an archive instead of a git repository for ' |
@@ -246,6 +252,20 @@ to update the working directory files. | |||
246 | if opt.dissociate: | 252 | if opt.dissociate: |
247 | m.config.SetString('repo.dissociate', 'true') | 253 | m.config.SetString('repo.dissociate', 'true') |
248 | 254 | ||
255 | if opt.worktree: | ||
256 | if opt.mirror: | ||
257 | print('fatal: --mirror and --worktree are incompatible', | ||
258 | file=sys.stderr) | ||
259 | sys.exit(1) | ||
260 | if opt.submodules: | ||
261 | print('fatal: --submodules and --worktree are incompatible', | ||
262 | file=sys.stderr) | ||
263 | sys.exit(1) | ||
264 | m.config.SetString('repo.worktree', 'true') | ||
265 | if is_new: | ||
266 | m.use_git_worktrees = True | ||
267 | print('warning: --worktree is experimental!', file=sys.stderr) | ||
268 | |||
249 | if opt.archive: | 269 | if opt.archive: |
250 | if is_new: | 270 | if is_new: |
251 | m.config.SetString('repo.archive', 'true') | 271 | m.config.SetString('repo.archive', 'true') |
@@ -459,6 +479,10 @@ to update the working directory files. | |||
459 | % ('.'.join(str(x) for x in MIN_GIT_VERSION_SOFT),), | 479 | % ('.'.join(str(x) for x in MIN_GIT_VERSION_SOFT),), |
460 | file=sys.stderr) | 480 | file=sys.stderr) |
461 | 481 | ||
482 | if opt.worktree: | ||
483 | # Older versions of git supported worktree, but had dangerous gc bugs. | ||
484 | git_require((2, 15, 0), fail=True, msg='git gc worktree corruption') | ||
485 | |||
462 | self._SyncManifest(opt) | 486 | self._SyncManifest(opt) |
463 | self._LinkManifest(opt.manifest_name) | 487 | self._LinkManifest(opt.manifest_name) |
464 | 488 | ||