summaryrefslogtreecommitdiff
path: root/Documentation/git-rev-parse.txt
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2019-11-19 03:05:43 -0500
committerJunio C Hamano <gitster@pobox.com>2019-11-20 10:19:58 +0900
commit2d92ab32fd624349d308334befbf07adf9f179b9 (patch)
tree03c48980c4a44bb537b12b3736334eb83b276bd8 /Documentation/git-rev-parse.txt
parentd9f6f3b6195a0ca35642561e530798ad1469bd41 (diff)
downloadgit-2d92ab32fd624349d308334befbf07adf9f179b9.tar.gz
rev-parse: make --show-toplevel without a worktree an error
Ever since it was introduced in 7cceca5ccc (Add 'git rev-parse --show-toplevel' option., 2010-01-12), the --show-toplevel option has treated a missing working tree as a quiet success: it neither prints a toplevel path, but nor does it report any kind of error. While a caller could distinguish this case by looking for an empty response, the behavior is rather confusing. We're better off complaining that there is no working tree, as other internal commands would do in similar cases (e.g., "git status" or any builtin with NEED_WORK_TREE set would just die()). So let's do the same here. While we're at it, let's clarify the documentation and add some tests, both for the new behavior and for the more mundane case (which was not covered). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'Documentation/git-rev-parse.txt')
-rw-r--r--Documentation/git-rev-parse.txt3
1 files changed, 2 insertions, 1 deletions
diff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt
index 9985477efe..19b12b6d43 100644
--- a/Documentation/git-rev-parse.txt
+++ b/Documentation/git-rev-parse.txt
@@ -262,7 +262,8 @@ print a message to stderr and exit with nonzero status.
directory.
--show-toplevel::
- Show the absolute path of the top-level directory.
+ Show the absolute path of the top-level directory of the working
+ tree. If there is no working tree, report an error.
--show-superproject-working-tree::
Show the absolute path of the root of the superproject's