14
14
cp ,
15
15
)
16
16
from .refs import (
17
+ Head ,
17
18
Reference ,
18
19
RemoteReference ,
19
20
SymbolicReference ,
@@ -177,8 +178,9 @@ class FetchInfo(object):
177
178
info.note # additional notes given by git-fetch intended for the user
178
179
info.old_commit # if info.flags & info.FORCED_UPDATE|info.FAST_FORWARD,
179
180
# 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
180
182
"""
181
- __slots__ = ('ref' , 'old_commit' , 'flags' , 'note' )
183
+ __slots__ = ('ref' , 'old_commit' , 'flags' , 'note' , 'remote_ref_path' )
182
184
183
185
NEW_TAG , NEW_HEAD , HEAD_UPTODATE , TAG_UPDATE , REJECTED , FORCED_UPDATE , \
184
186
FAST_FORWARD , ERROR = [1 << x for x in range (8 )]
@@ -193,14 +195,15 @@ class FetchInfo(object):
193
195
'=' : HEAD_UPTODATE ,
194
196
' ' : FAST_FORWARD }
195
197
196
- def __init__ (self , ref , flags , note = '' , old_commit = None ):
198
+ def __init__ (self , ref , flags , note = '' , old_commit = None , remote_ref_path = None ):
197
199
"""
198
200
Initialize a new instance
199
201
"""
200
202
self .ref = ref
201
203
self .flags = flags
202
204
self .note = note
203
205
self .old_commit = old_commit
206
+ self .remote_ref_path = remote_ref_path
204
207
205
208
def __str__ (self ):
206
209
return self .name
@@ -243,7 +246,7 @@ def _from_line(cls, repo, line, fetch_line):
243
246
new_hex_sha , fetch_operation , fetch_note = fetch_line .split ("\t " )
244
247
ref_type_name , fetch_note = fetch_note .split (' ' , 1 )
245
248
except ValueError : # unpack error
246
- raise ValueError ("Failed to parse FETCH__HEAD line: %r" % fetch_line )
249
+ raise ValueError ("Failed to parse FETCH_HEAD line: %r" % fetch_line )
247
250
248
251
# parse flags from control_character
249
252
flags = 0
@@ -288,6 +291,11 @@ def _from_line(cls, repo, line, fetch_line):
288
291
# note: remote-tracking is just the first part of the 'remote-tracking branch' token.
289
292
# We don't parse it correctly, but its enough to know what to do, and its new in git 1.7something
290
293
ref_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
291
299
else :
292
300
raise TypeError ("Cannot handle reference type: %r" % ref_type_name )
293
301
# END handle ref type
@@ -325,7 +333,7 @@ def _from_line(cls, repo, line, fetch_line):
325
333
326
334
note = (note and note .strip ()) or ''
327
335
328
- return cls (remote_local_ref , flags , note , old_commit )
336
+ return cls (remote_local_ref , flags , note , old_commit , local_remote_ref )
329
337
330
338
331
339
class Remote (LazyMixin , Iterable ):
0 commit comments