Skip to content

remote: compatibility with git version > 2.10 #623

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
May 29, 2017
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
remote: compatibility with git version > 2.10
  • Loading branch information
wusisu committed May 3, 2017
commit d001b396074e4f0f67703da8d99de009f961fc6e
9 changes: 7 additions & 2 deletions git/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,16 @@ class FetchInfo(object):

_flag_map = {'!': ERROR,
'+': FORCED_UPDATE,
'-': TAG_UPDATE,
'*': 0,
'=': HEAD_UPTODATE,
' ': FAST_FORWARD}

v = Git().version_info[:2]
if v >= (2, 10):
_flag_map['t'] = TAG_UPDATE
else:
_flag_map['-'] = TAG_UPDATE

def __init__(self, ref, flags, note='', old_commit=None, remote_ref_path=None):
"""
Initialize a new instance
Expand Down Expand Up @@ -629,7 +634,7 @@ def _get_fetch_info_from_stderr(self, proc, progress):
fetch_info_lines = list()
# Basically we want all fetch info lines which appear to be in regular form, and thus have a
# command character. Everything else we ignore,
cmds = set(PushInfo._flag_map.keys()) & set(FetchInfo._flag_map.keys())
Copy link
Member

Choose a reason for hiding this comment

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

I wonder why this change was required.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe I make a mistake because I may not understand the project deeply.

I make this change for 3 reasons:

  1. In the project before this commit, there is no difference between set(PushInfo._flag_map.keys()) & set(FetchInfo._flag_map.keys()) and set(FetchInfo._flag_map.keys()).
    PushInfo._flag_map.keys() == ['X', '-', '*', '+', ' ', '=', '!'] and FetchInfo._flag_map.keys() == ['!', '+', '-', '*', '=', ' '], and these two _flag_map are considered unchangable.

  2. It seems that there is no need to make an intersection between Push and Fetch.
    The only two usages of this function is fetch and pull. As the function (named _get_fetch_info_from_stderr) has the word fetch in its name, its duty is to parse data from fetch messages, and thus should only use FetchInfo._flags_map.
    So, I think use set(FetchInfo._flag_map.keys()) is just the right way.

  3. Push command has no 't'.
    Accoding to the documents of git-fetch and git-push, fetch has more command than push now, make an intersection will make this function loss some types of records.

That's way I think I could and have to make this change.

cmds = set(FetchInfo._flag_map.keys())

progress_handler = progress.new_message_handler()
handle_process_output(proc, None, progress_handler, finalizer=None, decode_streams=False)
Expand Down