Skip to content

Commit e0020b2

Browse files
nasamuffingitster
authored andcommitted
prefix_path: show gitdir when arg is outside repo
When developing a script, it can be painful to understand why Git thinks something is outside the current repo, if the current repo isn't what the user thinks it is. Since this can be tricky to diagnose, especially in cases like submodules or nested worktrees, let's give the user a hint about which repository is offended about that path. Signed-off-by: Emily Shaffer <[email protected]> Acked-by: brian m. carlson <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d0654dc commit e0020b2

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

pathspec.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,8 @@ static void init_pathspec_item(struct pathspec_item *item, unsigned flags,
439439
match = prefix_path_gently(prefix, prefixlen,
440440
&prefixlen, copyfrom);
441441
if (!match)
442-
die(_("%s: '%s' is outside repository"), elt, copyfrom);
442+
die(_("%s: '%s' is outside repository at '%s'"), elt,
443+
copyfrom, absolute_path(get_git_work_tree()));
443444
}
444445

445446
item->match = match;

setup.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ char *prefix_path(const char *prefix, int len, const char *path)
121121
{
122122
char *r = prefix_path_gently(prefix, len, NULL, path);
123123
if (!r)
124-
die(_("'%s' is outside repository"), path);
124+
die(_("'%s' is outside repository at '%s'"), path,
125+
absolute_path(get_git_work_tree()));
125126
return r;
126127
}
127128

0 commit comments

Comments
 (0)