summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Frysinger <vapier@google.com>2021-07-26 15:42:59 -0400
committerMike Frysinger <vapier@google.com>2021-07-28 05:38:53 +0000
commit73c43b839fe2ff974f13b7b06f9538762ce0b0d8 (patch)
tree23788297c0c014316a32f444bee74c073fc65ed9
parent56345c345bdfdd71399d17ccd0ffe8f39bf720eb (diff)
downloadgit-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>
-rwxr-xr-xmain.py7
-rw-r--r--man/repo.14
2 files changed, 11 insertions, 0 deletions
diff --git a/main.py b/main.py
index 229cb729..2050cabb 100755
--- a/main.py
+++ b/main.py
@@ -118,6 +118,10 @@ global_options.add_option('--time',
118global_options.add_option('--version', 118global_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')
121global_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')
121global_options.add_option('--event-log', 125global_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)
diff --git a/man/repo.1 b/man/repo.1
index 0e85b0b7..4aa76380 100644
--- a/man/repo.1
+++ b/man/repo.1
@@ -34,6 +34,10 @@ time repo command execution
34\fB\-\-version\fR 34\fB\-\-version\fR
35display this version of repo 35display this version of repo
36.TP 36.TP
37\fB\-\-show\-toplevel\fR
38display the path of the top\-level directory of the
39repo client checkout
40.TP
37\fB\-\-event\-log\fR=\fI\,EVENT_LOG\/\fR 41\fB\-\-event\-log\fR=\fI\,EVENT_LOG\/\fR
38filename of event log to append timeline to 42filename of event log to append timeline to
39.TP 43.TP