aboutsummaryrefslogtreecommitdiff
path: root/perl
diff options
context:
space:
mode:
authorFrank Lichtenheld <flichtenheld@astaro.com>2009-05-07 15:41:27 +0200
committerJunio C Hamano <gitster@pobox.com>2009-05-09 08:25:55 -0700
commitda159c7759418bb14af655968dfa7a98bdcb8661 (patch)
treeb5d108f10e1c6d05988693e8c0f3c319f8c9a121 /perl
parentf01f1099f40f24fe6f7802185340a6fa3a3d4f35 (diff)
downloadgit-da159c7759418bb14af655968dfa7a98bdcb8661.tar.gz
git-da159c7759418bb14af655968dfa7a98bdcb8661.tar.xz
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>
Diffstat (limited to 'perl')
-rw-r--r--perl/Git.pm2
1 files changed, 2 insertions, 0 deletions
diff --git a/perl/Git.pm b/perl/Git.pm
index 291ff5b53..4313db75b 100644
--- a/perl/Git.pm
+++ b/perl/Git.pm
@@ -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());
}