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:
Johannes Schindelin
2007-01-23 13:30:20 +01:00
committed by Junio C Hamano
parent 98d47d4ccf
commit 6d9ba67b0f
4 changed files with 19 additions and 4 deletions

View File

@ -48,7 +48,8 @@ cd_to_toplevel () {
}
require_work_tree () {
test $(is_bare_repository) = false ||
test $(is_bare_repository) = false &&
test $(git-rev-parse --is-inside-git-dir) = false ||
die "fatal: $0 cannot be used without a working tree."
}