@@ -42,7 +42,8 @@ class Git(LazyMixin):
42
42
of the command to stdout.
43
43
Set its value to 'full' to see details about the returned values.
44
44
"""
45
- __slots__ = ("_working_dir" , "cat_file_all" , "cat_file_header" , "_version_info" )
45
+ __slots__ = ("_working_dir" , "cat_file_all" , "cat_file_header" , "_version_info" ,
46
+ "_git_options" )
46
47
47
48
# CONFIGURATION
48
49
# The size in bytes read from stdout when copying git's output to another stream
@@ -217,7 +218,8 @@ def __init__(self, working_dir=None):
217
218
.git directory in case of bare repositories."""
218
219
super (Git , self ).__init__ ()
219
220
self ._working_dir = working_dir
220
-
221
+ self ._git_options = ()
222
+
221
223
# cached command slots
222
224
self .cat_file_header = None
223
225
self .cat_file_all = None
@@ -417,6 +419,21 @@ def __unpack_args(cls, arg_list):
417
419
# END for each arg
418
420
return outlist
419
421
422
+ def __call__ (self , ** kwargs ):
423
+ """Specify command line options to the git executable
424
+ for a subcommand call
425
+
426
+ :param kwargs:
427
+ is a dict of keyword arguments.
428
+ these arguments are passed as in _call_process
429
+ but will be passed to the git command rather than
430
+ the subcommand.
431
+
432
+ ``Examples``::
433
+ git(work_tree='/tmp').difftool()"""
434
+ self ._git_options = self .transform_kwargs (** kwargs )
435
+ return self
436
+
420
437
def _call_process (self , method , * args , ** kwargs ):
421
438
"""Run the given git command with the specified arguments and return
422
439
the result as a String
@@ -455,7 +472,14 @@ def _call_process(self, method, *args, **kwargs):
455
472
args = opt_args + ext_args
456
473
457
474
def make_call ():
458
- call = [self .GIT_PYTHON_GIT_EXECUTABLE , dashify (method )]
475
+ call = [self .GIT_PYTHON_GIT_EXECUTABLE ]
476
+
477
+ # add the git options, the reset to empty
478
+ # to avoid side_effects
479
+ call .extend (self ._git_options )
480
+ self ._git_options = ()
481
+
482
+ call .extend ([dashify (method )])
459
483
call .extend (args )
460
484
return call
461
485
#END utility to recreate call after changes
0 commit comments