@@ -77,11 +77,11 @@ def get_dir(self):
7777
7878 def execute (self , command ,
7979 istream = None ,
80+ keep_cwd = False ,
8081 with_status = False ,
8182 with_stderr = False ,
8283 with_exceptions = False ,
8384 with_raw_output = False ,
84- with_keep_cwd = False ,
8585 ):
8686 """
8787 Handles executing the command on the shell and consumes and returns
@@ -93,6 +93,11 @@ def execute(self, command,
9393 ``istream``
9494 Standard input filehandle passed to subprocess.Popen.
9595
96+ ``keep_cwd``
97+ Whether to use the current working directory from os.getcwd().
98+ GitPython uses get_work_tree() as its working directory by
99+ default and get_git_dir() for bare repositories.
100+
96101 ``with_status``
97102 Whether to return a (status, str) tuple.
98103
@@ -105,9 +110,6 @@ def execute(self, command,
105110 ``with_raw_output``
106111 Whether to avoid stripping off trailing whitespace.
107112
108- ``with_keep_cwd``
109- Whether to use the current working directory from os.getcwd().
110-
111113 Returns
112114 str(output) # with_status = False (Default)
113115 tuple(int(status), str(output)) # with_status = True
@@ -124,7 +126,7 @@ def execute(self, command,
124126 stderr = subprocess .PIPE
125127
126128 # Allow the user to have the command executed in their working dir.
127- if with_keep_cwd :
129+ if keep_cwd :
128130 cwd = os .getcwd ()
129131 else :
130132 cwd = self ._cwd
@@ -214,11 +216,11 @@ def method_missing(self, method, *args, **kwargs):
214216 # Handle optional arguments prior to calling transform_kwargs
215217 # otherwise these'll end up in args, which is bad.
216218 istream = kwargs .pop ("istream" , None )
219+ keep_cwd = kwargs .pop ("keep_cwd" , None )
217220 with_status = kwargs .pop ("with_status" , None )
218221 with_stderr = kwargs .pop ("with_stderr" , None )
219222 with_exceptions = kwargs .pop ("with_exceptions" , None )
220223 with_raw_output = kwargs .pop ("with_raw_output" , None )
221- with_keep_cwd = kwargs .pop ("with_keep_cwd" , None )
222224
223225 # Prepare the argument list
224226 opt_args = self .transform_kwargs (** kwargs )
@@ -230,9 +232,9 @@ def method_missing(self, method, *args, **kwargs):
230232
231233 return self .execute (call ,
232234 istream = istream ,
235+ keep_cwd = keep_cwd ,
233236 with_status = with_status ,
234237 with_stderr = with_stderr ,
235238 with_exceptions = with_exceptions ,
236239 with_raw_output = with_raw_output ,
237- with_keep_cwd = with_keep_cwd ,
238240 )
0 commit comments