From: Daniel Martí Date: Thu, 3 Jul 2014 14:25:24 +0000 (+0200) Subject: Use any of the branches that point to origin/HEAD if there are multiple X-Git-Tag: 0.2.1~54 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=00066a9b450c3ce33a9b798fdb3da67372c65df3;p=fdroidserver.git 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. --- 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.