Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 202216e

Browse files
committed
remote.fetch: fetchInfo would not provide old_commit information in case of fast_forwards although. Renamed cumbersome 'commit_before_forced_updated' attribute to 'old_commit' to be en par with PushInfo
1 parent 1dd7d64 commit 202216e

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

lib/git/remote.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -255,10 +255,10 @@ class FetchInfo(object):
255255
# i.e. info.flags & info.REJECTED
256256
# is 0 if ref is SymbolicReference
257257
info.note # additional notes given by git-fetch intended for the user
258-
info.commit_before_forced_update # if info.flags & info.FORCED_UPDATE,
258+
info.old_commit # if info.flags & info.FORCED_UPDATE|info.FAST_FORWARD,
259259
# field is set to the previous location of ref, otherwise None
260260
"""
261-
__slots__ = ('ref','commit_before_forced_update', 'flags', 'note')
261+
__slots__ = ('ref','old_commit', 'flags', 'note')
262262

263263
NEW_TAG, NEW_HEAD, HEAD_UPTODATE, TAG_UPDATE, REJECTED, FORCED_UPDATE, \
264264
FAST_FORWARD, ERROR = [ 1 << x for x in range(8) ]
@@ -276,7 +276,7 @@ def __init__(self, ref, flags, note = '', old_commit = None):
276276
self.ref = ref
277277
self.flags = flags
278278
self.note = note
279-
self.commit_before_forced_update = old_commit
279+
self.old_commit = old_commit
280280

281281
def __str__(self):
282282
return self.name
@@ -369,8 +369,11 @@ def _from_line(cls, repo, line, fetch_line):
369369
flags |= cls.NEW_TAG
370370
if 'new branch' in operation:
371371
flags |= cls.NEW_HEAD
372-
if '...' in operation:
373-
old_commit = Commit(repo, operation.split('...')[0])
372+
if '...' in operation or '..' in operation:
373+
split_token = '...'
374+
if control_character == ' ':
375+
split_token = split_token[:-1]
376+
old_commit = Commit(repo, operation.split(split_token)[0])
374377
# END handle refspec
375378
# END reference flag handling
376379

test/git/test_remote.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ def _test_fetch_result(self, results, remote):
7474
assert info.flags != 0
7575
# END reference type flags handling
7676
assert isinstance(info.ref, (SymbolicReference, Reference))
77-
if info.flags & info.FORCED_UPDATE:
78-
assert isinstance(info.commit_before_forced_update, Commit)
77+
if info.flags & (info.FORCED_UPDATE|info.FAST_FORWARD):
78+
assert isinstance(info.old_commit, Commit)
7979
else:
80-
assert info.commit_before_forced_update is None
80+
assert info.old_commit is None
8181
# END forced update checking
8282
# END for each info
8383

0 commit comments

Comments
 (0)