diff options
-rwxr-xr-x | repo | 23 | ||||
-rw-r--r-- | subcmds/init.py | 12 |
2 files changed, 23 insertions, 12 deletions
@@ -265,9 +265,12 @@ def GetParser(gitc_init=False): | |||
265 | 265 | ||
266 | # Logging. | 266 | # Logging. |
267 | group = parser.add_option_group('Logging options') | 267 | group = parser.add_option_group('Logging options') |
268 | group.add_option('-v', '--verbose', | ||
269 | dest='output_mode', action='store_true', | ||
270 | help='show all output') | ||
268 | group.add_option('-q', '--quiet', | 271 | group.add_option('-q', '--quiet', |
269 | action='store_true', default=False, | 272 | dest='output_mode', action='store_false', |
270 | help='be quiet') | 273 | help='only show errors') |
271 | 274 | ||
272 | # Manifest. | 275 | # Manifest. |
273 | group = parser.add_option_group('Manifest options') | 276 | group = parser.add_option_group('Manifest options') |
@@ -468,6 +471,8 @@ def _Init(args, gitc_init=False): | |||
468 | if args: | 471 | if args: |
469 | parser.print_usage() | 472 | parser.print_usage() |
470 | sys.exit(1) | 473 | sys.exit(1) |
474 | opt.quiet = opt.output_mode is False | ||
475 | opt.verbose = opt.output_mode is True | ||
471 | 476 | ||
472 | url = opt.repo_url | 477 | url = opt.repo_url |
473 | if not url: | 478 | if not url: |
@@ -527,7 +532,7 @@ def _Init(args, gitc_init=False): | |||
527 | do_verify = True | 532 | do_verify = True |
528 | 533 | ||
529 | dst = os.path.abspath(os.path.join(repodir, S_repo)) | 534 | dst = os.path.abspath(os.path.join(repodir, S_repo)) |
530 | _Clone(url, dst, opt.quiet, opt.clone_bundle) | 535 | _Clone(url, dst, opt.clone_bundle, opt.quiet, opt.verbose) |
531 | 536 | ||
532 | if do_verify: | 537 | if do_verify: |
533 | rev = _Verify(dst, branch, opt.quiet) | 538 | rev = _Verify(dst, branch, opt.quiet) |
@@ -746,7 +751,7 @@ def _InitHttp(): | |||
746 | urllib.request.install_opener(urllib.request.build_opener(*handlers)) | 751 | urllib.request.install_opener(urllib.request.build_opener(*handlers)) |
747 | 752 | ||
748 | 753 | ||
749 | def _Fetch(url, cwd, src, quiet): | 754 | def _Fetch(url, cwd, src, quiet, verbose): |
750 | if not quiet: | 755 | if not quiet: |
751 | print('Get %s' % url, file=sys.stderr) | 756 | print('Get %s' % url, file=sys.stderr) |
752 | 757 | ||
@@ -762,7 +767,7 @@ def _Fetch(url, cwd, src, quiet): | |||
762 | run_git(*cmd, stderr=err, cwd=cwd) | 767 | run_git(*cmd, stderr=err, cwd=cwd) |
763 | 768 | ||
764 | 769 | ||
765 | def _DownloadBundle(url, cwd, quiet): | 770 | def _DownloadBundle(url, cwd, quiet, verbose): |
766 | if not url.endswith('/'): | 771 | if not url.endswith('/'): |
767 | url += '/' | 772 | url += '/' |
768 | url += 'clone.bundle' | 773 | url += 'clone.bundle' |
@@ -812,12 +817,12 @@ def _DownloadBundle(url, cwd, quiet): | |||
812 | def _ImportBundle(cwd): | 817 | def _ImportBundle(cwd): |
813 | path = os.path.join(cwd, '.git', 'clone.bundle') | 818 | path = os.path.join(cwd, '.git', 'clone.bundle') |
814 | try: | 819 | try: |
815 | _Fetch(cwd, cwd, path, True) | 820 | _Fetch(cwd, cwd, path, True, False) |
816 | finally: | 821 | finally: |
817 | os.remove(path) | 822 | os.remove(path) |
818 | 823 | ||
819 | 824 | ||
820 | def _Clone(url, cwd, quiet, clone_bundle): | 825 | def _Clone(url, cwd, clone_bundle, quiet, verbose): |
821 | """Clones a git repository to a new subdirectory of repodir | 826 | """Clones a git repository to a new subdirectory of repodir |
822 | """ | 827 | """ |
823 | try: | 828 | try: |
@@ -834,9 +839,9 @@ def _Clone(url, cwd, quiet, clone_bundle): | |||
834 | _SetConfig(cwd, | 839 | _SetConfig(cwd, |
835 | 'remote.origin.fetch', | 840 | 'remote.origin.fetch', |
836 | '+refs/heads/*:refs/remotes/origin/*') | 841 | '+refs/heads/*:refs/remotes/origin/*') |
837 | if clone_bundle and _DownloadBundle(url, cwd, quiet): | 842 | if clone_bundle and _DownloadBundle(url, cwd, quiet, verbose): |
838 | _ImportBundle(cwd) | 843 | _ImportBundle(cwd) |
839 | _Fetch(url, cwd, 'origin', quiet) | 844 | _Fetch(url, cwd, 'origin', quiet, verbose) |
840 | 845 | ||
841 | 846 | ||
842 | def _Verify(cwd, branch, quiet): | 847 | def _Verify(cwd, branch, quiet): |
diff --git a/subcmds/init.py b/subcmds/init.py index af5bc297..be73cecd 100644 --- a/subcmds/init.py +++ b/subcmds/init.py | |||
@@ -87,9 +87,12 @@ to update the working directory files. | |||
87 | def _Options(self, p, gitc_init=False): | 87 | def _Options(self, p, gitc_init=False): |
88 | # Logging | 88 | # Logging |
89 | g = p.add_option_group('Logging options') | 89 | g = p.add_option_group('Logging options') |
90 | g.add_option('-v', '--verbose', | ||
91 | dest='output_mode', action='store_true', | ||
92 | help='show all output') | ||
90 | g.add_option('-q', '--quiet', | 93 | g.add_option('-q', '--quiet', |
91 | dest="quiet", action="store_true", default=False, | 94 | dest='output_mode', action='store_false', |
92 | help="be quiet") | 95 | help='only show errors') |
93 | 96 | ||
94 | # Manifest | 97 | # Manifest |
95 | g = p.add_option_group('Manifest options') | 98 | g = p.add_option_group('Manifest options') |
@@ -300,7 +303,7 @@ to update the working directory files. | |||
300 | if opt.submodules: | 303 | if opt.submodules: |
301 | m.config.SetString('repo.submodules', 'true') | 304 | m.config.SetString('repo.submodules', 'true') |
302 | 305 | ||
303 | if not m.Sync_NetworkHalf(is_new=is_new, quiet=opt.quiet, | 306 | if not m.Sync_NetworkHalf(is_new=is_new, quiet=opt.quiet, verbose=opt.verbose, |
304 | clone_bundle=opt.clone_bundle, | 307 | clone_bundle=opt.clone_bundle, |
305 | current_branch_only=opt.current_branch_only, | 308 | current_branch_only=opt.current_branch_only, |
306 | tags=opt.tags, submodules=opt.submodules, | 309 | tags=opt.tags, submodules=opt.submodules, |
@@ -483,6 +486,9 @@ to update the working directory files. | |||
483 | % ('.'.join(str(x) for x in MIN_GIT_VERSION_SOFT),), | 486 | % ('.'.join(str(x) for x in MIN_GIT_VERSION_SOFT),), |
484 | file=sys.stderr) | 487 | file=sys.stderr) |
485 | 488 | ||
489 | opt.quiet = opt.output_mode is False | ||
490 | opt.verbose = opt.output_mode is True | ||
491 | |||
486 | if opt.worktree: | 492 | if opt.worktree: |
487 | # Older versions of git supported worktree, but had dangerous gc bugs. | 493 | # Older versions of git supported worktree, but had dangerous gc bugs. |
488 | git_require((2, 15, 0), fail=True, msg='git gc worktree corruption') | 494 | git_require((2, 15, 0), fail=True, msg='git gc worktree corruption') |