Skip to content

Commit 6d9b1f4

Browse files
committed
gitcmd: may now receive extra keyword arguments to be passed directly to the subproces.Popen invocation. It could be used to pass custom environments, without changing the own one (gitpython-developers#26)
1 parent 1ee2afb commit 6d9b1f4

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

Diff for: lib/git/cmd.py

+9-11
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,7 @@
1616
'with_exceptions', 'as_process',
1717
'output_stream' )
1818

19-
extra = {}
20-
# NOTE: Execution through a shell on windows appears to be slightly faster, but in fact
21-
# I consider it a problem whenever complex strings are passed and *interpreted*
22-
# by the shell beforehand. This can cause great confusion and reduces compatability
23-
# between the OS which is why the shell should not be used ( unless it does not work
24-
# otherwise )
25-
#if sys.platform == 'win32':
26-
# extra = {'shell': False}
19+
2720

2821
def dashify(string):
2922
return string.replace('_', '-')
@@ -140,7 +133,8 @@ def execute(self, command,
140133
with_extended_output=False,
141134
with_exceptions=True,
142135
as_process=False,
143-
output_stream=None
136+
output_stream=None,
137+
**subprocess_kwargs
144138
):
145139
"""
146140
Handles executing the command on the shell and consumes and returns
@@ -183,7 +177,11 @@ def execute(self, command,
183177
This merely is a workaround as data will be copied from the
184178
output pipe to the given output stream directly.
185179
186-
180+
``**subprocess_kwargs``
181+
Keyword arguments to be passed to subprocess.Popen. Please note that
182+
some of the valid kwargs are already set by this method, the ones you
183+
specify may not be the same ones.
184+
187185
Returns::
188186
189187
str(output) # extended_output = False (Default)
@@ -216,7 +214,7 @@ def execute(self, command,
216214
stderr=subprocess.PIPE,
217215
stdout=subprocess.PIPE,
218216
close_fds=(os.name=='posix'),# unsupported on linux
219-
**extra
217+
**subprocess_kwargs
220218
)
221219
if as_process:
222220
return self.AutoInterrupt(proc, command)

0 commit comments

Comments
 (0)