summaryrefslogtreecommitdiff
path: root/builtin-rev-parse.c
diff options
context:
space:
mode:
Diffstat (limited to 'builtin-rev-parse.c')
-rw-r--r--builtin-rev-parse.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/builtin-rev-parse.c b/builtin-rev-parse.c
index 497903a85a..8d78b69c90 100644
--- a/builtin-rev-parse.c
+++ b/builtin-rev-parse.c
@@ -321,6 +321,13 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
}
if (!strcmp(arg, "--show-cdup")) {
const char *pfx = prefix;
+ if (!is_inside_work_tree()) {
+ const char *work_tree =
+ get_git_work_tree();
+ if (work_tree)
+ printf("%s\n", work_tree);
+ continue;
+ }
while (pfx) {
pfx = strchr(pfx, '/');
if (pfx) {