summaryrefslogtreecommitdiff
path: root/git.c
diff options
context:
space:
mode:
authorJohannes Schindelin <Johannes.Schindelin@gmx.de>2007-01-23 13:30:20 +0100
committerJunio C Hamano <junkio@cox.net>2007-02-05 14:02:16 -0800
commit6d9ba67b0fc2f18c1d7a65514edbdcdf86429c1c (patch)
treeed60e9bec4aa2adc5aecde724614f3fa4a542971 /git.c
parent98d47d4ccf76725e7833c1bbda1da82f7648925f (diff)
downloadgit-6d9ba67b0fc2f18c1d7a65514edbdcdf86429c1c.tar.gz
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>
Diffstat (limited to 'git.c')
-rw-r--r--git.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/git.c b/git.c
index fb03a547de..82a8357272 100644
--- a/git.c
+++ b/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));