summaryrefslogtreecommitdiff
path: root/setup.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2020-03-17 15:02:20 -0700
committerJunio C Hamano <gitster@pobox.com>2020-03-17 15:02:20 -0700
commit758d0773baa3732bc62838070566513df6a84239 (patch)
treeaeb0c9d951ced7858d3238bf5a41f59dfb831e01 /setup.c
parentf0c344ce578f71aeeee7d40cc01e66f74506ecf9 (diff)
parent5c20398699165a91af2d81ea2d20385bc8dd3627 (diff)
downloadgit-758d0773baa3732bc62838070566513df6a84239.tar.xz
Merge branch 'es/outside-repo-errmsg-hints' into maint
An earlier update to show the location of working tree in the error message did not consider the possibility that a git command may be run in a bare repository, which has been corrected. * es/outside-repo-errmsg-hints: prefix_path: show gitdir if worktree unavailable prefix_path: show gitdir when arg is outside repo
Diffstat (limited to 'setup.c')
-rw-r--r--setup.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/setup.c b/setup.c
index e2a479a64f..f4897287f7 100644
--- a/setup.c
+++ b/setup.c
@@ -120,8 +120,13 @@ char *prefix_path_gently(const char *prefix, int len,
char *prefix_path(const char *prefix, int len, const char *path)
{
char *r = prefix_path_gently(prefix, len, NULL, path);
- if (!r)
- die(_("'%s' is outside repository"), path);
+ if (!r) {
+ const char *hint_path = get_git_work_tree();
+ if (!hint_path)
+ hint_path = get_git_dir();
+ die(_("'%s' is outside repository at '%s'"), path,
+ absolute_path(hint_path));
+ }
return r;
}