diff options
author | Mike Frysinger <vapier@google.com> | 2020-02-17 14:36:08 -0500 |
---|---|---|
committer | David Pursehouse <dpursehouse@collab.net> | 2020-02-19 00:24:43 +0000 |
commit | c58ec4dba102d88fec67e833eb8421202eb4c1ea (patch) | |
tree | c8c84e03f9359ae9dd126854069d34207c298831 | |
parent | e1191b3adb22e0b406db87691b13ddab2c236267 (diff) | |
download | git-repo-c58ec4dba102d88fec67e833eb8421202eb4c1ea.tar.gz |
avoid negative variables
Trying to use booleans with names like "no_xxx" are hard to follow due
to the double negatives. Invert all of them so we only have positive
meanings to follow.
Change-Id: Ifd37d0368f97034d94aa2cf38db52c723ac0c6ed
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/255493
Tested-by: Mike Frysinger <vapier@google.com>
Reviewed-by: David Pursehouse <dpursehouse@collab.net>
-rwxr-xr-x | main.py | 4 | ||||
-rw-r--r-- | project.py | 13 | ||||
-rwxr-xr-x | repo | 13 | ||||
-rw-r--r-- | subcmds/init.py | 10 | ||||
-rw-r--r-- | subcmds/rebase.py | 4 | ||||
-rw-r--r-- | subcmds/selfupdate.py | 4 | ||||
-rw-r--r-- | subcmds/sync.py | 18 |
7 files changed, 34 insertions, 32 deletions
@@ -108,7 +108,7 @@ global_options.add_option('-p', '--paginate', | |||
108 | dest='pager', action='store_true', | 108 | dest='pager', action='store_true', |
109 | help='display command output in the pager') | 109 | help='display command output in the pager') |
110 | global_options.add_option('--no-pager', | 110 | global_options.add_option('--no-pager', |
111 | dest='no_pager', action='store_true', | 111 | dest='pager', action='store_false', |
112 | help='disable the pager') | 112 | help='disable the pager') |
113 | global_options.add_option('--color', | 113 | global_options.add_option('--color', |
114 | choices=('auto', 'always', 'never'), default=None, | 114 | choices=('auto', 'always', 'never'), default=None, |
@@ -222,7 +222,7 @@ class _Repo(object): | |||
222 | file=sys.stderr) | 222 | file=sys.stderr) |
223 | return 1 | 223 | return 1 |
224 | 224 | ||
225 | if not gopts.no_pager and not isinstance(cmd, InteractiveCommand): | 225 | if gopts.pager and not isinstance(cmd, InteractiveCommand): |
226 | config = cmd.manifest.globalConfig | 226 | config = cmd.manifest.globalConfig |
227 | if gopts.pager: | 227 | if gopts.pager: |
228 | use_pager = True | 228 | use_pager = True |
@@ -1432,7 +1432,7 @@ class Project(object): | |||
1432 | current_branch_only=False, | 1432 | current_branch_only=False, |
1433 | force_sync=False, | 1433 | force_sync=False, |
1434 | clone_bundle=True, | 1434 | clone_bundle=True, |
1435 | no_tags=False, | 1435 | tags=True, |
1436 | archive=False, | 1436 | archive=False, |
1437 | optimized_fetch=False, | 1437 | optimized_fetch=False, |
1438 | prune=False, | 1438 | prune=False, |
@@ -1501,9 +1501,8 @@ class Project(object): | |||
1501 | elif self.manifest.default.sync_c: | 1501 | elif self.manifest.default.sync_c: |
1502 | current_branch_only = True | 1502 | current_branch_only = True |
1503 | 1503 | ||
1504 | if not no_tags: | 1504 | if not self.sync_tags: |
1505 | if not self.sync_tags: | 1505 | tags = False |
1506 | no_tags = True | ||
1507 | 1506 | ||
1508 | if self.clone_depth: | 1507 | if self.clone_depth: |
1509 | depth = self.clone_depth | 1508 | depth = self.clone_depth |
@@ -1517,7 +1516,7 @@ class Project(object): | |||
1517 | if not self._RemoteFetch( | 1516 | if not self._RemoteFetch( |
1518 | initial=is_new, quiet=quiet, verbose=verbose, alt_dir=alt_dir, | 1517 | initial=is_new, quiet=quiet, verbose=verbose, alt_dir=alt_dir, |
1519 | current_branch_only=current_branch_only, | 1518 | current_branch_only=current_branch_only, |
1520 | no_tags=no_tags, prune=prune, depth=depth, | 1519 | tags=tags, prune=prune, depth=depth, |
1521 | submodules=submodules, force_sync=force_sync, | 1520 | submodules=submodules, force_sync=force_sync, |
1522 | clone_filter=clone_filter): | 1521 | clone_filter=clone_filter): |
1523 | return False | 1522 | return False |
@@ -2197,7 +2196,7 @@ class Project(object): | |||
2197 | quiet=False, | 2196 | quiet=False, |
2198 | verbose=False, | 2197 | verbose=False, |
2199 | alt_dir=None, | 2198 | alt_dir=None, |
2200 | no_tags=False, | 2199 | tags=True, |
2201 | prune=False, | 2200 | prune=False, |
2202 | depth=None, | 2201 | depth=None, |
2203 | submodules=False, | 2202 | submodules=False, |
@@ -2355,7 +2354,7 @@ class Project(object): | |||
2355 | 2354 | ||
2356 | # If using depth then we should not get all the tags since they may | 2355 | # If using depth then we should not get all the tags since they may |
2357 | # be outside of the depth. | 2356 | # be outside of the depth. |
2358 | if no_tags or depth: | 2357 | if not tags or depth: |
2359 | cmd.append('--no-tags') | 2358 | cmd.append('--no-tags') |
2360 | else: | 2359 | else: |
2361 | cmd.append('--tags') | 2360 | cmd.append('--tags') |
@@ -315,9 +315,11 @@ def GetParser(gitc_init=False): | |||
315 | help='restrict manifest projects to ones with a specified ' | 315 | help='restrict manifest projects to ones with a specified ' |
316 | 'platform group [auto|all|none|linux|darwin|...]', | 316 | 'platform group [auto|all|none|linux|darwin|...]', |
317 | metavar='PLATFORM') | 317 | metavar='PLATFORM') |
318 | group.add_option('--no-clone-bundle', action='store_true', | 318 | group.add_option('--no-clone-bundle', |
319 | dest='clone_bundle', default=True, action='store_false', | ||
319 | help='disable use of /clone.bundle on HTTP/HTTPS') | 320 | help='disable use of /clone.bundle on HTTP/HTTPS') |
320 | group.add_option('--no-tags', action='store_true', | 321 | group.add_option('--no-tags', |
322 | dest='tags', default=True, action='store_false', | ||
321 | help="don't fetch tags in the manifest") | 323 | help="don't fetch tags in the manifest") |
322 | 324 | ||
323 | # Tool. | 325 | # Tool. |
@@ -326,7 +328,8 @@ def GetParser(gitc_init=False): | |||
326 | help='repo repository location ($REPO_URL)') | 328 | help='repo repository location ($REPO_URL)') |
327 | group.add_option('--repo-branch', metavar='REVISION', | 329 | group.add_option('--repo-branch', metavar='REVISION', |
328 | help='repo branch or revision ($REPO_REV)') | 330 | help='repo branch or revision ($REPO_REV)') |
329 | group.add_option('--no-repo-verify', action='store_true', | 331 | group.add_option('--no-repo-verify', |
332 | dest='repo_verify', default=True, action='store_false', | ||
330 | help='do not verify repo source code') | 333 | help='do not verify repo source code') |
331 | 334 | ||
332 | # Other. | 335 | # Other. |
@@ -505,7 +508,7 @@ def _Init(args, gitc_init=False): | |||
505 | 508 | ||
506 | _CheckGitVersion() | 509 | _CheckGitVersion() |
507 | try: | 510 | try: |
508 | if opt.no_repo_verify: | 511 | if not opt.repo_verify: |
509 | do_verify = False | 512 | do_verify = False |
510 | else: | 513 | else: |
511 | if NeedSetupGnuPG(): | 514 | if NeedSetupGnuPG(): |
@@ -514,7 +517,7 @@ def _Init(args, gitc_init=False): | |||
514 | do_verify = True | 517 | do_verify = True |
515 | 518 | ||
516 | dst = os.path.abspath(os.path.join(repodir, S_repo)) | 519 | dst = os.path.abspath(os.path.join(repodir, S_repo)) |
517 | _Clone(url, dst, opt.quiet, not opt.no_clone_bundle) | 520 | _Clone(url, dst, opt.quiet, opt.clone_bundle) |
518 | 521 | ||
519 | if do_verify: | 522 | if do_verify: |
520 | rev = _Verify(dst, branch, opt.quiet) | 523 | rev = _Verify(dst, branch, opt.quiet) |
diff --git a/subcmds/init.py b/subcmds/init.py index dde97286..3c68c2c3 100644 --- a/subcmds/init.py +++ b/subcmds/init.py | |||
@@ -146,10 +146,10 @@ to update the working directory files. | |||
146 | 'platform group [auto|all|none|linux|darwin|...]', | 146 | 'platform group [auto|all|none|linux|darwin|...]', |
147 | metavar='PLATFORM') | 147 | metavar='PLATFORM') |
148 | g.add_option('--no-clone-bundle', | 148 | g.add_option('--no-clone-bundle', |
149 | dest='no_clone_bundle', action='store_true', | 149 | dest='clone_bundle', default=True, action='store_false', |
150 | help='disable use of /clone.bundle on HTTP/HTTPS') | 150 | help='disable use of /clone.bundle on HTTP/HTTPS') |
151 | g.add_option('--no-tags', | 151 | g.add_option('--no-tags', |
152 | dest='no_tags', action='store_true', | 152 | dest='tags', default=True, action='store_false', |
153 | help="don't fetch tags in the manifest") | 153 | help="don't fetch tags in the manifest") |
154 | 154 | ||
155 | # Tool | 155 | # Tool |
@@ -161,7 +161,7 @@ to update the working directory files. | |||
161 | dest='repo_branch', | 161 | dest='repo_branch', |
162 | help='repo branch or revision', metavar='REVISION') | 162 | help='repo branch or revision', metavar='REVISION') |
163 | g.add_option('--no-repo-verify', | 163 | g.add_option('--no-repo-verify', |
164 | dest='no_repo_verify', action='store_true', | 164 | dest='repo_verify', default=True, action='store_false', |
165 | help='do not verify repo source code') | 165 | help='do not verify repo source code') |
166 | 166 | ||
167 | # Other | 167 | # Other |
@@ -281,9 +281,9 @@ to update the working directory files. | |||
281 | m.config.SetString('repo.submodules', 'true') | 281 | m.config.SetString('repo.submodules', 'true') |
282 | 282 | ||
283 | if not m.Sync_NetworkHalf(is_new=is_new, quiet=opt.quiet, | 283 | if not m.Sync_NetworkHalf(is_new=is_new, quiet=opt.quiet, |
284 | clone_bundle=not opt.no_clone_bundle, | 284 | clone_bundle=opt.clone_bundle, |
285 | current_branch_only=opt.current_branch_only, | 285 | current_branch_only=opt.current_branch_only, |
286 | no_tags=opt.no_tags, submodules=opt.submodules, | 286 | tags=opt.tags, submodules=opt.submodules, |
287 | clone_filter=opt.clone_filter): | 287 | clone_filter=opt.clone_filter): |
288 | r = m.GetRemote(m.remote.name) | 288 | r = m.GetRemote(m.remote.name) |
289 | print('fatal: cannot obtain manifest %s' % r.url, file=sys.stderr) | 289 | print('fatal: cannot obtain manifest %s' % r.url, file=sys.stderr) |
diff --git a/subcmds/rebase.py b/subcmds/rebase.py index eb92a3c7..24d80bfd 100644 --- a/subcmds/rebase.py +++ b/subcmds/rebase.py | |||
@@ -53,7 +53,7 @@ branch but need to incorporate new upstream changes "underneath" them. | |||
53 | dest='force_rebase', action='store_true', | 53 | dest='force_rebase', action='store_true', |
54 | help='Pass --force-rebase to git rebase') | 54 | help='Pass --force-rebase to git rebase') |
55 | p.add_option('--no-ff', | 55 | p.add_option('--no-ff', |
56 | dest='no_ff', action='store_true', | 56 | dest='ff', default=True, action='store_false', |
57 | help='Pass --no-ff to git rebase') | 57 | help='Pass --no-ff to git rebase') |
58 | p.add_option('-q', '--quiet', | 58 | p.add_option('-q', '--quiet', |
59 | dest='quiet', action='store_true', | 59 | dest='quiet', action='store_true', |
@@ -93,7 +93,7 @@ branch but need to incorporate new upstream changes "underneath" them. | |||
93 | common_args.append('--quiet') | 93 | common_args.append('--quiet') |
94 | if opt.force_rebase: | 94 | if opt.force_rebase: |
95 | common_args.append('--force-rebase') | 95 | common_args.append('--force-rebase') |
96 | if opt.no_ff: | 96 | if not opt.ff: |
97 | common_args.append('--no-ff') | 97 | common_args.append('--no-ff') |
98 | if opt.autosquash: | 98 | if opt.autosquash: |
99 | common_args.append('--autosquash') | 99 | common_args.append('--autosquash') |
diff --git a/subcmds/selfupdate.py b/subcmds/selfupdate.py index 4817a862..bf6256ab 100644 --- a/subcmds/selfupdate.py +++ b/subcmds/selfupdate.py | |||
@@ -40,7 +40,7 @@ need to be performed by an end-user. | |||
40 | def _Options(self, p): | 40 | def _Options(self, p): |
41 | g = p.add_option_group('repo Version options') | 41 | g = p.add_option_group('repo Version options') |
42 | g.add_option('--no-repo-verify', | 42 | g.add_option('--no-repo-verify', |
43 | dest='no_repo_verify', action='store_true', | 43 | dest='repo_verify', default=True, action='store_false', |
44 | help='do not verify repo source code') | 44 | help='do not verify repo source code') |
45 | g.add_option('--repo-upgraded', | 45 | g.add_option('--repo-upgraded', |
46 | dest='repo_upgraded', action='store_true', | 46 | dest='repo_upgraded', action='store_true', |
@@ -60,5 +60,5 @@ need to be performed by an end-user. | |||
60 | 60 | ||
61 | rp.bare_git.gc('--auto') | 61 | rp.bare_git.gc('--auto') |
62 | _PostRepoFetch(rp, | 62 | _PostRepoFetch(rp, |
63 | no_repo_verify=opt.no_repo_verify, | 63 | repo_verify=opt.repo_verify, |
64 | verbose=True) | 64 | verbose=True) |
diff --git a/subcmds/sync.py b/subcmds/sync.py index 849e878c..1988cc72 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
@@ -247,7 +247,7 @@ later is required to fix a server side protocol bug. | |||
247 | dest='manifest_name', | 247 | dest='manifest_name', |
248 | help='temporary manifest to use for this sync', metavar='NAME.xml') | 248 | help='temporary manifest to use for this sync', metavar='NAME.xml') |
249 | p.add_option('--no-clone-bundle', | 249 | p.add_option('--no-clone-bundle', |
250 | dest='no_clone_bundle', action='store_true', | 250 | dest='clone_bundle', default=True, action='store_false', |
251 | help='disable use of /clone.bundle on HTTP/HTTPS') | 251 | help='disable use of /clone.bundle on HTTP/HTTPS') |
252 | p.add_option('-u', '--manifest-server-username', action='store', | 252 | p.add_option('-u', '--manifest-server-username', action='store', |
253 | dest='manifest_server_username', | 253 | dest='manifest_server_username', |
@@ -259,7 +259,7 @@ later is required to fix a server side protocol bug. | |||
259 | dest='fetch_submodules', action='store_true', | 259 | dest='fetch_submodules', action='store_true', |
260 | help='fetch submodules from server') | 260 | help='fetch submodules from server') |
261 | p.add_option('--no-tags', | 261 | p.add_option('--no-tags', |
262 | dest='no_tags', action='store_true', | 262 | dest='tags', default=True, action='store_false', |
263 | help="don't fetch tags") | 263 | help="don't fetch tags") |
264 | p.add_option('--optimized-fetch', | 264 | p.add_option('--optimized-fetch', |
265 | dest='optimized_fetch', action='store_true', | 265 | dest='optimized_fetch', action='store_true', |
@@ -276,7 +276,7 @@ later is required to fix a server side protocol bug. | |||
276 | 276 | ||
277 | g = p.add_option_group('repo Version options') | 277 | g = p.add_option_group('repo Version options') |
278 | g.add_option('--no-repo-verify', | 278 | g.add_option('--no-repo-verify', |
279 | dest='no_repo_verify', action='store_true', | 279 | dest='repo_verify', default=True, action='store_false', |
280 | help='do not verify repo source code') | 280 | help='do not verify repo source code') |
281 | g.add_option('--repo-upgraded', | 281 | g.add_option('--repo-upgraded', |
282 | dest='repo_upgraded', action='store_true', | 282 | dest='repo_upgraded', action='store_true', |
@@ -338,8 +338,8 @@ later is required to fix a server side protocol bug. | |||
338 | verbose=opt.verbose, | 338 | verbose=opt.verbose, |
339 | current_branch_only=opt.current_branch_only, | 339 | current_branch_only=opt.current_branch_only, |
340 | force_sync=opt.force_sync, | 340 | force_sync=opt.force_sync, |
341 | clone_bundle=not opt.no_clone_bundle, | 341 | clone_bundle=opt.clone_bundle, |
342 | no_tags=opt.no_tags, archive=self.manifest.IsArchive, | 342 | tags=opt.tags, archive=self.manifest.IsArchive, |
343 | optimized_fetch=opt.optimized_fetch, | 343 | optimized_fetch=opt.optimized_fetch, |
344 | prune=opt.prune, | 344 | prune=opt.prune, |
345 | clone_filter=clone_filter) | 345 | clone_filter=clone_filter) |
@@ -841,7 +841,7 @@ later is required to fix a server side protocol bug. | |||
841 | start = time.time() | 841 | start = time.time() |
842 | success = mp.Sync_NetworkHalf(quiet=opt.quiet, verbose=opt.verbose, | 842 | success = mp.Sync_NetworkHalf(quiet=opt.quiet, verbose=opt.verbose, |
843 | current_branch_only=opt.current_branch_only, | 843 | current_branch_only=opt.current_branch_only, |
844 | no_tags=opt.no_tags, | 844 | tags=opt.tags, |
845 | optimized_fetch=opt.optimized_fetch, | 845 | optimized_fetch=opt.optimized_fetch, |
846 | submodules=self.manifest.HasSubmodules, | 846 | submodules=self.manifest.HasSubmodules, |
847 | clone_filter=self.manifest.CloneFilter) | 847 | clone_filter=self.manifest.CloneFilter) |
@@ -977,7 +977,7 @@ later is required to fix a server side protocol bug. | |||
977 | 977 | ||
978 | fetched = self._Fetch(to_fetch, opt, err_event) | 978 | fetched = self._Fetch(to_fetch, opt, err_event) |
979 | 979 | ||
980 | _PostRepoFetch(rp, opt.no_repo_verify) | 980 | _PostRepoFetch(rp, opt.repo_verify) |
981 | if opt.network_only: | 981 | if opt.network_only: |
982 | # bail out now; the rest touches the working tree | 982 | # bail out now; the rest touches the working tree |
983 | if err_event.isSet(): | 983 | if err_event.isSet(): |
@@ -1067,11 +1067,11 @@ def _PostRepoUpgrade(manifest, quiet=False): | |||
1067 | project.PostRepoUpgrade() | 1067 | project.PostRepoUpgrade() |
1068 | 1068 | ||
1069 | 1069 | ||
1070 | def _PostRepoFetch(rp, no_repo_verify=False, verbose=False): | 1070 | def _PostRepoFetch(rp, repo_verify=True, verbose=False): |
1071 | if rp.HasChanges: | 1071 | if rp.HasChanges: |
1072 | print('info: A new version of repo is available', file=sys.stderr) | 1072 | print('info: A new version of repo is available', file=sys.stderr) |
1073 | print(file=sys.stderr) | 1073 | print(file=sys.stderr) |
1074 | if no_repo_verify or _VerifyTag(rp): | 1074 | if not repo_verify or _VerifyTag(rp): |
1075 | syncbuf = SyncBuffer(rp.config) | 1075 | syncbuf = SyncBuffer(rp.config) |
1076 | rp.Sync_LocalHalf(syncbuf) | 1076 | rp.Sync_LocalHalf(syncbuf) |
1077 | if not syncbuf.Finish(): | 1077 | if not syncbuf.Finish(): |