Skip to content

Copy environment for subprocess execution #208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 17, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion git/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,10 @@ def execute(self, command,
cwd = self._working_dir

# Start the process
env = os.environ.copy()
env["LC_MESSAGES"] = "C"
proc = Popen(command,
env={"LC_MESSAGES": "C"},
env=env,
cwd=cwd,
stdin=istream,
stderr=PIPE,
Expand Down
6 changes: 6 additions & 0 deletions git/test/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# the BSD License: http://www.opensource.org/licenses/bsd-license.php

import os
import mock
from git.test.lib import (TestBase,
patch,
raises,
Expand Down Expand Up @@ -128,3 +129,8 @@ def test_single_char_git_options_are_passed_to_git(self):

def test_change_to_transform_kwargs_does_not_break_command_options(self):
self.git.log(n=1)

def test_env_vars_passed_to_git(self):
editor = 'non_existant_editor'
with mock.patch.dict('os.environ', {'GIT_EDITOR': editor}):
assert self.git.var("GIT_EDITOR") == editor