diff --git a/builtin-rev-parse.c b/builtin-rev-parse.c
index 497903a85a69288afc291ff49e32f7c80140beae..8d78b69c902a99738cfc337222ba71493ff45370 100644 (file)
--- a/builtin-rev-parse.c
+++ b/builtin-rev-parse.c
}
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) {