Skip to content

Commit a53bb10

Browse files
committed
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 89ade7b 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/
1 parent 20f4a9d commit a53bb10

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

git/cmd.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -902,8 +902,12 @@ def transform_kwarg(self, name, value, split_single_char_options):
902902

903903
def transform_kwargs(self, split_single_char_options=True, **kwargs):
904904
"""Transforms Python style kwargs into git command line options."""
905+
# only since 3.6 Python preserves the order of kwargs and thus has a stable
906+
# order. For older versions sort the kwargs by the key to get a stable
907+
# order.
908+
if sys.version_info[:2] < (3, 6):
909+
kwargs = OrderedDict(sorted(kwargs.items(), key=lambda x: x[0]))
905910
args = []
906-
kwargs = OrderedDict(sorted(kwargs.items(), key=lambda x: x[0]))
907911
for k, v in kwargs.items():
908912
if isinstance(v, (list, tuple)):
909913
for value in v:

0 commit comments

Comments
 (0)