Skip to content

Commit f66bc5f

Browse files
RichiHgitster
authored andcommitted
Always show which directory is not a git repository
Unify all fatal: Not a git repository error messages so they include path information. Signed-off-by: Richard Hartmann <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5fdb709 commit f66bc5f

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

contrib/workdir/git-new-workdir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ branch=$3
2222
# want to make sure that what is pointed to has a .git directory ...
2323
git_dir=$(cd "$orig_git" 2>/dev/null &&
2424
git rev-parse --git-dir 2>/dev/null) ||
25-
die "\"$orig_git\" is not a git repository!"
25+
die "Not a git repository: \"$orig_git\""
2626

2727
case "$git_dir" in
2828
.git)

perl/Git.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,14 +204,14 @@ sub repository {
204204

205205
unless (-d "$dir/refs" and -d "$dir/objects" and -e "$dir/HEAD") {
206206
# Mimick git-rev-parse --git-dir error message:
207-
throw Error::Simple('fatal: Not a git repository');
207+
throw Error::Simple("fatal: Not a git repository: $dir");
208208
}
209209
my $search = Git->repository(Repository => $dir);
210210
try {
211211
$search->command('symbolic-ref', 'HEAD');
212212
} catch Git::Error::Command with {
213213
# Mimick git-rev-parse --git-dir error message:
214-
throw Error::Simple('fatal: Not a git repository');
214+
throw Error::Simple("fatal: Not a git repository: $dir");
215215
}
216216

217217
$opts{Repository} = abs_path($dir);

setup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ const char *setup_git_directory_gently(int *nongit_ok)
468468
*nongit_ok = 1;
469469
return NULL;
470470
}
471-
die("Not a git repository");
471+
die("Not a git repository (or any of the parent directories): %s", DEFAULT_GIT_DIR_ENVIRONMENT);
472472
}
473473
if (chdir(".."))
474474
die("Cannot change to %s/..: %s", cwd, strerror(errno));

0 commit comments

Comments
 (0)