Skip to content

Commit

Permalink
Fix order of operators before executing the git command
Browse files Browse the repository at this point in the history
Since Python 3.3, the hash value of an object is seeded randomly, making it
change between each call. As a consequence, the `dict` type relying on the hash
value for the order of the items upon iterating on it, and the parameters
passed to `git` being passed as `kwargs` to the `execute()` method, the order
of parameters will change randomly between calls.

For example, when you call `git.remote.pull()` in a code, two consecutives run
will generate:

1. git pull --progress -v origin master
2. git pull -v --progress origin master

By simply adding the `sorted()` call around `args` within the `transform_kwargs()`
method, it will ensure that each subsequent calls will execute the parameters in
the same order.
  • Loading branch information
guyzmo committed May 12, 2016
1 parent fb577c8 commit bdd4210
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion git/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ def transform_kwargs(self, split_single_char_options=True, **kwargs):
args += self.transform_kwarg(k, value, split_single_char_options)
else:
args += self.transform_kwarg(k, v, split_single_char_options)
return args
return sorted(args)

@classmethod
def __unpack_args(cls, arg_list):
Expand Down

0 comments on commit bdd4210

Please sign in to comment.