summaryrefslogtreecommitdiff
path: root/git/cmd.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2017-09-28 15:45:34 +0200
committerGitHub <noreply@github.com>2017-09-28 15:45:34 +0200
commitddb828ecd0e28d346934fd1838a5f1c74363fba6 (patch)
tree1e07af3b22ba20b59dadd4a5b8008a3217c40bb5 /git/cmd.py
parent2eb6cf0855232da2b8f37785677d1f58c8e86817 (diff)
parent2e482a20ab221cb6eca51f12f1bd29cda4eec484 (diff)
downloadgitpython-ddb828ecd0e28d346934fd1838a5f1c74363fba6.tar.gz
Merge pull request #645 from AJMansfield/master
Implemented Per-Call Environment Variables
Diffstat (limited to 'git/cmd.py')
-rw-r--r--git/cmd.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/git/cmd.py b/git/cmd.py
index 312f933a..e0946e47 100644
--- a/git/cmd.py
+++ b/git/cmd.py
@@ -47,7 +47,7 @@ from .util import (
execute_kwargs = set(('istream', 'with_extended_output',
'with_exceptions', 'as_process', 'stdout_as_string',
'output_stream', 'with_stdout', 'kill_after_timeout',
- 'universal_newlines', 'shell'))
+ 'universal_newlines', 'shell', 'env'))
log = logging.getLogger(__name__)
log.addHandler(logging.NullHandler())
@@ -597,6 +597,7 @@ class Git(LazyMixin):
with_stdout=True,
universal_newlines=False,
shell=None,
+ env=None,
**subprocess_kwargs
):
"""Handles executing the command on the shell and consumes and returns
@@ -640,6 +641,9 @@ class Git(LazyMixin):
decoded into a string using the default encoding (usually utf-8).
The latter can fail, if the output contains binary data.
+ :param env:
+ A dictionary of environment variables to be passed to `subprocess.Popen`.
+
:param subprocess_kwargs:
Keyword arguments to be passed to subprocess.Popen. Please note that
some of the valid kwargs are already set by this method, the ones you
@@ -685,6 +689,7 @@ class Git(LazyMixin):
cwd = self._working_dir or os.getcwd()
# Start the process
+ inline_env = env
env = os.environ.copy()
# Attempt to force all output to plain ascii english, which is what some parsing code
# may expect.
@@ -693,6 +698,8 @@ class Git(LazyMixin):
env["LANGUAGE"] = "C"
env["LC_ALL"] = "C"
env.update(self._environment)
+ if inline_env is not None:
+ env.update(inline_env)
if is_win:
cmd_not_found_exception = OSError