diff options
author | Mike Frysinger <vapier@google.com> | 2021-07-26 23:31:06 -0400 |
---|---|---|
committer | Mike Frysinger <vapier@google.com> | 2021-07-28 05:37:52 +0000 |
commit | a024bd33b808489acc909036b63697a819cc6ce7 (patch) | |
tree | 6306755871d93f49cc4992238651700e2ca18b35 | |
parent | 968d646f046355313008bfddfbd3fde1e0e14339 (diff) | |
download | git-repo-a024bd33b808489acc909036b63697a819cc6ce7.tar.gz |
repo: make --version always work
We don't really care what the subcommand is set to when --version
output is requested, so stop enforcing it. This fixes some weird
behavior like `repo --version version` fails, but `repo --version
help` works.
The new logic skips subcommand validation, so `repo --version asdf`
will still display the version output. This matches git behavior,
and makes a bit of sense when we consider that the user really wants
to see the tool version, and probably doesn't care about anything
else on the command line.
Change-Id: I87454d473c2c8869344b3888a7affaa2e03f5b0f
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/312907
Reviewed-by: Xin Li <delphij@google.com>
Tested-by: Mike Frysinger <vapier@google.com>
-rwxr-xr-x | main.py | 4 |
1 files changed, 1 insertions, 3 deletions
@@ -185,9 +185,7 @@ class _Repo(object): | |||
185 | print('\nRun `repo help <command>` for command-specific details.') | 185 | print('\nRun `repo help <command>` for command-specific details.') |
186 | return 0 | 186 | return 0 |
187 | elif gopts.show_version: | 187 | elif gopts.show_version: |
188 | if name and name != 'help': | 188 | # Always allow global --version regardless of subcommand validity. |
189 | print('fatal: invalid usage of --version', file=sys.stderr) | ||
190 | return 1 | ||
191 | name = 'version' | 189 | name = 'version' |
192 | elif not name: | 190 | elif not name: |
193 | # No subcommand specified, so show the help/subcommand. | 191 | # No subcommand specified, so show the help/subcommand. |