Code

Git.pm: Set GIT_WORK_TREE if we set GIT_DIR
[git.git] / perl / Git.pm
index 291ff5b53c1883ee8fce67fbb7e2b32393ef0800..4313db75b5a1de3085e45b949c267ea4be9fe5fe 100644 (file)
@@ -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());
        }