diff options
author | Anson Mansfield <anson.mansfield@gmail.com> | 2017-07-19 18:36:17 -0400 |
---|---|---|
committer | Anson Mansfield <anson.mansfield@gmail.com> | 2017-07-19 19:10:55 -0400 |
commit | 24d4926fd8479b8a298de84a2bcfdb94709ac619 (patch) | |
tree | 511efcfbd2eff4f55a90b76ff72919eca7e914c5 /git/cmd.py | |
parent | cf8dc259fcc9c1397ea67cec3a6a4cb5816e3e68 (diff) | |
download | gitpython-24d4926fd8479b8a298de84a2bcfdb94709ac619.tar.gz |
implemented per-call environment variable support
Diffstat (limited to 'git/cmd.py')
-rw-r--r-- | git/cmd.py | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -46,7 +46,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()) @@ -471,6 +471,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 @@ -514,6 +515,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 @@ -559,6 +563,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. @@ -567,6 +572,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 |