1414cp ,
1515)
1616from .refs import (
17+ Head ,
1718Reference ,
1819RemoteReference ,
1920SymbolicReference ,
@@ -177,8 +178,9 @@ class FetchInfo(object):
177178 info.note # additional notes given by git-fetch intended for the user
178179 info.old_commit # if info.flags & info.FORCED_UPDATE|info.FAST_FORWARD,
179180 # field is set to the previous location of ref, otherwise None
181+ info.remote_ref_path # The path from which we fetched on the remote. It's the remote's version of our info.ref
180182 """
181- __slots__ = ('ref' ,'old_commit' ,'flags' ,'note' )
183+ __slots__ = ('ref' ,'old_commit' ,'flags' ,'note' , 'remote_ref_path' )
182184
183185NEW_TAG ,NEW_HEAD ,HEAD_UPTODATE ,TAG_UPDATE ,REJECTED ,FORCED_UPDATE , \
184186FAST_FORWARD ,ERROR = [1 << x for x in range (8 )]
@@ -193,14 +195,15 @@ class FetchInfo(object):
193195'=' :HEAD_UPTODATE ,
194196' ' :FAST_FORWARD }
195197
196- def __init__ (self ,ref ,flags ,note = '' ,old_commit = None ):
198+ def __init__ (self ,ref ,flags ,note = '' ,old_commit = None , remote_ref_path = None ):
197199"""
198200 Initialize a new instance
199201 """
200202self .ref = ref
201203self .flags = flags
202204self .note = note
203205self .old_commit = old_commit
206+ self .remote_ref_path = remote_ref_path
204207
205208def __str__ (self ):
206209return self .name
@@ -243,7 +246,7 @@ def _from_line(cls, repo, line, fetch_line):
243246new_hex_sha ,fetch_operation ,fetch_note = fetch_line .split ("\t " )
244247ref_type_name ,fetch_note = fetch_note .split (' ' ,1 )
245248except ValueError :# unpack error
246- raise ValueError ("Failed to parseFETCH__HEAD line: %r" % fetch_line )
249+ raise ValueError ("Failed to parseFETCH_HEAD line: %r" % fetch_line )
247250
248251# parse flags from control_character
249252flags = 0
@@ -288,6 +291,11 @@ def _from_line(cls, repo, line, fetch_line):
288291# note: remote-tracking is just the first part of the 'remote-tracking branch' token.
289292# We don't parse it correctly, but its enough to know what to do, and its new in git 1.7something
290293ref_type = RemoteReference
294+ elif '/' in ref_type_name :
295+ # If the fetch spec look something like this '+refs/pull/*:refs/heads/pull/*', and is thus pretty
296+ # much anything the user wants, we will have trouble to determine what's going on
297+ # For now, we assume the local ref is a Head
298+ ref_type = Head
291299else :
292300raise TypeError ("Cannot handle reference type: %r" % ref_type_name )
293301# END handle ref type
@@ -325,7 +333,7 @@ def _from_line(cls, repo, line, fetch_line):
325333
326334note = (note and note .strip ())or ''
327335
328- return cls (remote_local_ref ,flags ,note ,old_commit )
336+ return cls (remote_local_ref ,flags ,note ,old_commit , local_remote_ref )
329337
330338
331339class Remote (LazyMixin ,Iterable ):