diff options
author | Mike Frysinger <vapier@google.com> | 2021-07-26 15:42:59 -0400 |
---|---|---|
committer | Mike Frysinger <vapier@google.com> | 2021-07-28 05:38:53 +0000 |
commit | 73c43b839fe2ff974f13b7b06f9538762ce0b0d8 (patch) | |
tree | 23788297c0c014316a32f444bee74c073fc65ed9 /main.py | |
parent | 56345c345bdfdd71399d17ccd0ffe8f39bf720eb (diff) | |
download | git-repo-73c43b839fe2ff974f13b7b06f9538762ce0b0d8.tar.gz |
repo: add --show-toplevel akin to git
Simple API to make it easy to find the top of the repo client checkout
for users. This mirrors the `git rev-parse --show-toplevel` API.
Change-Id: I0c3f98def089d0fc9ebcfa50aa3dc02091c1c273
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/312909
Reviewed-by: Xin Li <delphij@google.com>
Tested-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'main.py')
-rwxr-xr-x | main.py | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -118,6 +118,10 @@ global_options.add_option('--time', | |||
118 | global_options.add_option('--version', | 118 | global_options.add_option('--version', |
119 | dest='show_version', action='store_true', | 119 | dest='show_version', action='store_true', |
120 | help='display this version of repo') | 120 | help='display this version of repo') |
121 | global_options.add_option('--show-toplevel', | ||
122 | action='store_true', | ||
123 | help='display the path of the top-level directory of ' | ||
124 | 'the repo client checkout') | ||
121 | global_options.add_option('--event-log', | 125 | global_options.add_option('--event-log', |
122 | dest='event_log', action='store', | 126 | dest='event_log', action='store', |
123 | help='filename of event log to append timeline to') | 127 | help='filename of event log to append timeline to') |
@@ -202,6 +206,9 @@ class _Repo(object): | |||
202 | elif gopts.show_version: | 206 | elif gopts.show_version: |
203 | # Always allow global --version regardless of subcommand validity. | 207 | # Always allow global --version regardless of subcommand validity. |
204 | name = 'version' | 208 | name = 'version' |
209 | elif gopts.show_toplevel: | ||
210 | print(os.path.dirname(self.repodir)) | ||
211 | return 0 | ||
205 | elif not name: | 212 | elif not name: |
206 | # No subcommand specified, so show the help/subcommand. | 213 | # No subcommand specified, so show the help/subcommand. |
207 | self._PrintHelp(short=True) | 214 | self._PrintHelp(short=True) |