Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit89ade7b

Browse files
committed
Fix order of operators before executing the git command
Since Python 3.3, the hash value of an object is seeded randomly, making itchange between each call. As a consequence, the `dict` type relying on the hashvalue for the order of the items upon iterating on it, and the parameterspassed to `git` being passed as `kwargs` to the `execute()` method, the orderof parameters will change randomly between calls.For example, when you call `git.remote.pull()` in a code, two consecutives runwill generate:1. git pull --progress -v origin master2. git pull -v --progress origin masterWithin the `transform_kwargs()` method, I'm promoting `kwargs` into an`collections.OrderedDict` being built with `kwargs` sorted on the keys.Then it will ensure that each subsequent calls will execute theparameters in the same order.
1 parentfb577c8 commit89ade7b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

‎git/cmd.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
importerrno
1414
importmmap
1515

16+
fromcollectionsimportOrderedDict
17+
1618
fromcontextlibimportcontextmanager
1719
importsignal
1820
fromsubprocessimport (
@@ -783,6 +785,7 @@ def transform_kwarg(self, name, value, split_single_char_options):
783785
deftransform_kwargs(self,split_single_char_options=True,**kwargs):
784786
"""Transforms Python style kwargs into git command line options."""
785787
args=list()
788+
kwargs=OrderedDict(sorted(kwargs.items(),key=lambdax:x[0]))
786789
fork,vinkwargs.items():
787790
ifisinstance(v, (list,tuple)):
788791
forvalueinv:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp