summaryrefslogtreecommitdiff
path: root/git/remote.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2015-01-22 15:22:39 +0100
committerSebastian Thiel <byronimo@gmail.com>2015-01-22 15:22:39 +0100
commit06bec1bcd1795192f4a4a274096f053afc8f80ec (patch)
treefda896da0f7406ff257b8f9d1d3805965bc94311 /git/remote.py
parentb54b9399920375f0bab14ff8495c0ea3f5fa1c33 (diff)
downloadgitpython-06bec1bcd1795192f4a4a274096f053afc8f80ec.tar.gz
Fetch now deals with custom refspecs much better.
Even though the test-csae only verifies this spec: +refs/pull/*:refs/heads/pull/* I could locally verify that it indeed handles other ones just as well: +refs/pull/*:refs/pull/* Fixes #243
Diffstat (limited to 'git/remote.py')
-rw-r--r--git/remote.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/git/remote.py b/git/remote.py
index c37d6c49..39d9dc4d 100644
--- a/git/remote.py
+++ b/git/remote.py
@@ -14,6 +14,7 @@ from .config import (
cp,
)
from .refs import (
+ Head,
Reference,
RemoteReference,
SymbolicReference,
@@ -177,8 +178,9 @@ class FetchInfo(object):
info.note # additional notes given by git-fetch intended for the user
info.old_commit # if info.flags & info.FORCED_UPDATE|info.FAST_FORWARD,
# field is set to the previous location of ref, otherwise None
+ info.remote_ref_path # The path from which we fetched on the remote. It's the remote's version of our info.ref
"""
- __slots__ = ('ref', 'old_commit', 'flags', 'note')
+ __slots__ = ('ref', 'old_commit', 'flags', 'note', 'remote_ref_path')
NEW_TAG, NEW_HEAD, HEAD_UPTODATE, TAG_UPDATE, REJECTED, FORCED_UPDATE, \
FAST_FORWARD, ERROR = [1 << x for x in range(8)]
@@ -193,7 +195,7 @@ class FetchInfo(object):
'=': HEAD_UPTODATE,
' ': FAST_FORWARD}
- def __init__(self, ref, flags, note='', old_commit=None):
+ def __init__(self, ref, flags, note='', old_commit=None, remote_ref_path=None):
"""
Initialize a new instance
"""
@@ -201,6 +203,7 @@ class FetchInfo(object):
self.flags = flags
self.note = note
self.old_commit = old_commit
+ self.remote_ref_path = remote_ref_path
def __str__(self):
return self.name
@@ -243,7 +246,7 @@ class FetchInfo(object):
new_hex_sha, fetch_operation, fetch_note = fetch_line.split("\t")
ref_type_name, fetch_note = fetch_note.split(' ', 1)
except ValueError: # unpack error
- raise ValueError("Failed to parse FETCH__HEAD line: %r" % fetch_line)
+ raise ValueError("Failed to parse FETCH_HEAD line: %r" % fetch_line)
# parse flags from control_character
flags = 0
@@ -288,6 +291,11 @@ class FetchInfo(object):
# note: remote-tracking is just the first part of the 'remote-tracking branch' token.
# We don't parse it correctly, but its enough to know what to do, and its new in git 1.7something
ref_type = RemoteReference
+ elif '/' in ref_type_name:
+ # If the fetch spec look something like this '+refs/pull/*:refs/heads/pull/*', and is thus pretty
+ # much anything the user wants, we will have trouble to determine what's going on
+ # For now, we assume the local ref is a Head
+ ref_type = Head
else:
raise TypeError("Cannot handle reference type: %r" % ref_type_name)
# END handle ref type
@@ -325,7 +333,7 @@ class FetchInfo(object):
note = (note and note.strip()) or ''
- return cls(remote_local_ref, flags, note, old_commit)
+ return cls(remote_local_ref, flags, note, old_commit, local_remote_ref)
class Remote(LazyMixin, Iterable):