Skip to content

Commit 5df76d4

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 5df76d4

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

git/cmd.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import threading
2020
from collections import OrderedDict
2121
from textwrap import dedent
22+
import warnings
2223

2324
from git.compat import (
2425
defenc,
@@ -902,8 +903,14 @@ def transform_kwarg(self, name, value, split_single_char_options):
902903

903904
def transform_kwargs(self, split_single_char_options=True, **kwargs):
904905
"""Transforms Python style kwargs into git command line options."""
906+
# Python 3.6 preserves the order of kwargs and thus has a stable
907+
# order. For older versions sort the kwargs by the key to get a stable
908+
# order.
909+
if sys.version_info[:2] < (3, 6):
910+
kwargs = OrderedDict(sorted(kwargs.items(), key=lambda x: x[0]))
911+
warnings.warn("Python 3.5 support is deprecated. It does not preserve the order\n" +
912+
"for key-word arguments. Thus they will be sorted!!")
905913
args = []
906-
kwargs = OrderedDict(sorted(kwargs.items(), key=lambda x: x[0]))
907914
for k, v in kwargs.items():
908915
if isinstance(v, (list, tuple)):
909916
for value in v:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy