summaryrefslogtreecommitdiff
path: root/perl
diff options
context:
space:
mode:
authorFrank Lichtenheld <flichtenheld@astaro.com>2009-05-07 13:41:27 (GMT)
committerJunio C Hamano <gitster@pobox.com>2009-05-09 15:25:55 (GMT)
commitda159c7759418bb14af655968dfa7a98bdcb8661 (patch)
treeb5d108f10e1c6d05988693e8c0f3c319f8c9a121 /perl
parentf01f1099f40f24fe6f7802185340a6fa3a3d4f35 (diff)
downloadgit-da159c7759418bb14af655968dfa7a98bdcb8661.zip
git-da159c7759418bb14af655968dfa7a98bdcb8661.tar.gz
git-da159c7759418bb14af655968dfa7a98bdcb8661.tar.bz2
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 291ff5b..4313db7 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());
}