Git.pm: Set GIT_WORK_TREE if we set GIT_DIR
Otherwise git will use the current directory as work tree which will lead to unexpected results if we operate in sub directory of the work tree. Signed-off-by: Frank Lichtenheld <flichtenheld@astaro.com> Acked-by: Petr Baudis <pasky@suse.cz> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
f01f1099f4
commit
da159c7759
@ -1280,6 +1280,8 @@ sub _cmd_exec {
|
||||
my ($self, @args) = @_;
|
||||
if ($self) {
|
||||
$self->repo_path() and $ENV{'GIT_DIR'} = $self->repo_path();
|
||||
$self->repo_path() and $self->wc_path()
|
||||
and $ENV{'GIT_WORK_TREE'} = $self->wc_path();
|
||||
$self->wc_path() and chdir($self->wc_path());
|
||||
$self->wc_subdir() and chdir($self->wc_subdir());
|
||||
}
|
||||
|
Reference in New Issue
Block a user