From 8e11f8f59d59c0d9f9a2cc517eeef47a1a200fb1 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Mon, 8 Oct 2012 12:20:52 +0000 Subject: Handle branch name kind changes more gracefully. Scenario: a repository contains a ref: refs/heads/foo and we have that in our repository cache. Action: upstream deletes that ref and then pushes a new refs at refs/heads/foo/bar. Action: we attempt to update the git and the update fails because git remote update cannot cope with the 'kind' change of refs/heads/foo from ref to directory. Remedy: If we get an exception from the remote update --prune we try the less efficient but more resilient combination of first pruning and then updating. Reviewed-By: Lars Wirzenius (over the shoulder) Reviewed-By: Richard Maw (over the shoulder) --- morphlib/cachedrepo.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'morphlib/cachedrepo.py') diff --git a/morphlib/cachedrepo.py b/morphlib/cachedrepo.py index f0ca627b..c40cb657 100644 --- a/morphlib/cachedrepo.py +++ b/morphlib/cachedrepo.py @@ -271,7 +271,11 @@ class CachedRepo(object): raise CheckoutError(self, ref, target_dir) def _update(self): # pragma: no cover - self._runcmd(['git', 'remote', 'update', 'origin', '--prune']) + try: + self._runcmd(['git', 'remote', 'update', 'origin', '--prune']) + except cliapp.AppException, ae: + self._runcmd(['git', 'remote', 'prune', 'origin']) + self._runcmd(['git', 'remote', 'update', 'origin']) def __str__(self): # pragma: no cover return self.url -- cgit v1.2.1