summaryrefslogtreecommitdiff
path: root/git/cmd.py
diff options
context:
space:
mode:
Diffstat (limited to 'git/cmd.py')
-rw-r--r--git/cmd.py28
1 files changed, 23 insertions, 5 deletions
diff --git a/git/cmd.py b/git/cmd.py
index c43fac56..72ba82c3 100644
--- a/git/cmd.py
+++ b/git/cmd.py
@@ -69,10 +69,10 @@ def handle_process_output(process, stdout_handler, stderr_handler,
:return: result of finalizer
:param process: subprocess.Popen instance
:param stdout_handler: f(stdout_line_string), or None
- :param stderr_hanlder: f(stderr_line_string), or None
+ :param stderr_handler: f(stderr_line_string), or None
:param finalizer: f(proc) - wait for proc to finish
:param decode_streams:
- Assume stdout/stderr streams are binary and decode them vefore pushing \
+ Assume stdout/stderr streams are binary and decode them before pushing \
their contents to handlers.
Set it to False if `universal_newline == True` (then streams are in text-mode)
or if decoding must happen later (i.e. for Diffs).
@@ -162,7 +162,7 @@ class Git(LazyMixin):
Set its value to 'full' to see details about the returned values.
"""
__slots__ = ("_working_dir", "cat_file_all", "cat_file_header", "_version_info",
- "_git_options", "_environment")
+ "_git_options", "_persistent_git_options", "_environment")
_excluded_ = ('cat_file_all', 'cat_file_header', '_version_info')
@@ -405,6 +405,7 @@ class Git(LazyMixin):
super(Git, self).__init__()
self._working_dir = working_dir
self._git_options = ()
+ self._persistent_git_options = []
# Extra environment variables to pass to git commands
self._environment = {}
@@ -421,9 +422,23 @@ class Git(LazyMixin):
return LazyMixin.__getattr__(self, name)
return lambda *args, **kwargs: self._call_process(name, *args, **kwargs)
+ def set_persistent_git_options(self, **kwargs):
+ """Specify command line options to the git executable
+ for subsequent subcommand calls
+
+ :param kwargs:
+ is a dict of keyword arguments.
+ these arguments are passed as in _call_process
+ but will be passed to the git command rather than
+ the subcommand.
+ """
+
+ self._persistent_git_options = self.transform_kwargs(
+ split_single_char_options=True, **kwargs)
+
def _set_cache_(self, attr):
if attr == '_version_info':
- # We only use the first 4 numbers, as everthing else could be strings in fact (on windows)
+ # We only use the first 4 numbers, as everything else could be strings in fact (on windows)
version_numbers = self._call_process('version').split(' ')[2]
self._version_info = tuple(int(n) for n in version_numbers.split('.')[:4] if n.isdigit())
else:
@@ -839,7 +854,10 @@ class Git(LazyMixin):
call = [self.GIT_PYTHON_GIT_EXECUTABLE]
- # add the git options, the reset to empty
+ # add persistent git options
+ call.extend(self._persistent_git_options)
+
+ # add the git options, then reset to empty
# to avoid side_effects
call.extend(self._git_options)
self._git_options = ()