From 00066a9b450c3ce33a9b798fdb3da67372c65df3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Mart=C3=AD?= Date: Thu, 3 Jul 2014 16:25:24 +0200 Subject: [PATCH] Use any of the branches that point to origin/HEAD if there are multiple 'set-head origin --auto' fails if there are multiple branches that are the same as origin/HEAD: error: Multiple remote HEAD branches. Please choose one explicitly with: git remote set-head origin develop git remote set-head origin master So we want to grab any of them, e.g. the first branch that it gives us, and just use that as it will work just fine. --- fdroidserver/common.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fdroidserver/common.py b/fdroidserver/common.py index d0cc51d3..69e6e68b 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -480,7 +480,13 @@ class vcs_git(vcs): # Recreate origin/HEAD as git clone would do it, in case it disappeared p = SilentPopen(['git', 'remote', 'set-head', 'origin', '--auto'], cwd=self.local) if p.returncode != 0: - raise VCSException("Git remote set-head failed", p.output) + lines = p.output.splitlines() + if 'Multiple remote HEAD branches' not in lines[0]: + raise VCSException("Git remote set-head failed", p.output) + branch = lines[1].split(' ')[-1] + p2 = SilentPopen(['git', 'remote', 'set-head', 'origin', branch], cwd=self.local) + if p2.returncode != 0: + raise VCSException("Git remote set-head failed", p.output + '\n' + p2.output) self.refreshed = True # origin/HEAD is the HEAD of the remote, e.g. the "default branch" on # a github repo. Most of the time this is the same as origin/master. -- 2.30.2