Commands requiring a work tree must not run in GIT_DIR
This patch helps when you accidentally run something like git-clean in the git directory instead of the work tree. Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
committed by
Junio C Hamano
parent
98d47d4ccf
commit
6d9ba67b0f
5
git.c
5
git.c
@ -299,8 +299,9 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
|
||||
prefix = setup_git_directory();
|
||||
if (p->option & USE_PAGER)
|
||||
setup_pager();
|
||||
if ((p->option & NOT_BARE) && is_bare_repository())
|
||||
die("%s cannot be used in a bare git directory", cmd);
|
||||
if ((p->option & NOT_BARE) &&
|
||||
(is_bare_repository() || is_inside_git_dir()))
|
||||
die("%s must be run in a work tree", cmd);
|
||||
trace_argv_printf(argv, argc, "trace: built-in: git");
|
||||
|
||||
exit(p->fn(argc, argv, prefix));
|
||||
|
||||
Reference in New Issue
Block a user