summaryrefslogtreecommitdiff
path: root/git/cmd.py
diff options
context:
space:
mode:
authorBert Wesarg <bert.wesarg@googlemail.com>2021-03-11 16:35:24 +0100
committerBert Wesarg <bert.wesarg@googlemail.com>2021-03-13 13:41:23 +0100
commit5df76d451ff0fde14ab71b38030b6c3e6bc79c08 (patch)
tree7387c6ddda7cd7997206f372d80e2fe89fdb5115 /git/cmd.py
parent20f4a9d49b466a18f1af1fdfb480bc4520a4cdc2 (diff)
downloadgitpython-5df76d451ff0fde14ab71b38030b6c3e6bc79c08.tar.gz
Restore order of operators before executing the git command only for < py3.6
Since Python 3.6 kwargs order will be preserved and thus provide a stable order, therefore we can make 89ade7bfff534ae799d7dd693b206931d5ed3d4f conditional based on the Python. Thus make it able to pass ordered options to Git commands. See: https://www.python.org/dev/peps/pep-0468/
Diffstat (limited to 'git/cmd.py')
-rw-r--r--git/cmd.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/git/cmd.py b/git/cmd.py
index 050efaed..46d809c7 100644
--- a/git/cmd.py
+++ b/git/cmd.py
@@ -19,6 +19,7 @@ import sys
import threading
from collections import OrderedDict
from textwrap import dedent
+import warnings
from git.compat import (
defenc,
@@ -902,8 +903,14 @@ class Git(LazyMixin):
def transform_kwargs(self, split_single_char_options=True, **kwargs):
"""Transforms Python style kwargs into git command line options."""
+ # Python 3.6 preserves the order of kwargs and thus has a stable
+ # order. For older versions sort the kwargs by the key to get a stable
+ # order.
+ if sys.version_info[:2] < (3, 6):
+ kwargs = OrderedDict(sorted(kwargs.items(), key=lambda x: x[0]))
+ warnings.warn("Python 3.5 support is deprecated. It does not preserve the order\n" +
+ "for key-word arguments. Thus they will be sorted!!")
args = []
- kwargs = OrderedDict(sorted(kwargs.items(), key=lambda x: x[0]))
for k, v in kwargs.items():
if isinstance(v, (list, tuple)):
for value in v: