Skip to content

Restore order of operators before executing the git command only for < py3.6 #1193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 13, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion git/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import threading
from collections import OrderedDict
from textwrap import dedent
import warnings

from git.compat import (
defenc,
Expand Down Expand Up @@ -902,8 +903,14 @@ def transform_kwarg(self, name, value, split_single_char_options):

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):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to make people aware, could you add a deprecation warning mentioning the date until this will work?

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:
Expand Down