summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--git/remote.py14
-rw-r--r--git/test/test_remote.py5
2 files changed, 19 insertions, 0 deletions
diff --git a/git/remote.py b/git/remote.py
index 6126e3cc..c9da1979 100644
--- a/git/remote.py
+++ b/git/remote.py
@@ -604,6 +604,18 @@ class Remote(LazyMixin, Iterable):
raise
return output
+ def _assert_refspec(self):
+ """Turns out we can't deal with remotes if the refspec is missing"""
+ config = self.config_reader
+ try:
+ if config.get_value('fetch', default=type) is type:
+ msg = "Remote '%s' has no refspec set.\n"
+ msg += "You can set it as follows:"
+ msg += " 'git config --add \"remote.%s.fetch +refs/heads/*:refs/heads/*\"'." % self.name
+ raise AssertionError(msg)
+ finally:
+ config.release()
+
def fetch(self, refspec=None, progress=None, **kwargs):
"""Fetch the latest changes for this remote
@@ -631,6 +643,7 @@ class Remote(LazyMixin, Iterable):
:note:
As fetch does not provide progress information to non-ttys, we cannot make
it available here unfortunately as in the 'push' method."""
+ self._assert_refspec()
kwargs = add_progress(kwargs, self.repo.git, progress)
if isinstance(refspec, list):
args = refspec
@@ -651,6 +664,7 @@ class Remote(LazyMixin, Iterable):
:param progress: see 'push' method
:param kwargs: Additional arguments to be passed to git-pull
:return: Please see 'fetch' method """
+ self._assert_refspec()
kwargs = add_progress(kwargs, self.repo.git, progress)
proc = self.repo.git.pull(self, refspec, with_extended_output=True, as_process=True, v=True, **kwargs)
res = self._get_fetch_info_from_stderr(proc, progress or RemoteProgress())
diff --git a/git/test/test_remote.py b/git/test/test_remote.py
index af854988..6c37614d 100644
--- a/git/test/test_remote.py
+++ b/git/test/test_remote.py
@@ -494,6 +494,11 @@ class TestRemote(TestBase):
fetch_info_line_fmt = "c437ee5deb8d00cf02f03720693e4c802e99f390 not-for-merge %s '0.3' of "
fetch_info_line_fmt += "git://github.com/gitpython-developers/GitPython"
remote_info_line_fmt = "* [new branch] nomatter -> %s"
+
+ self.failUnlessRaises(ValueError, FetchInfo._from_line, self.rorepo,
+ remote_info_line_fmt % "refs/something/branch",
+ "269c498e56feb93e408ed4558c8138d750de8893\t\t/Users/ben/test/foo\n")
+
fi = FetchInfo._from_line(self.rorepo,
remote_info_line_fmt % "local/master",
fetch_info_line_fmt % 'remote-tracking branch')