summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2017-11-08 18:45:18 +0000
committerSam Thursfield <sam.thursfield@codethink.co.uk>2017-11-08 18:59:10 +0000
commit794e73cb4469c30bd830b333597a6932da1254f1 (patch)
treea9c4560028e43c72427ecd09383dc28f03dd92a9
parent213d9072b684d2dff78d8b4f1c7cfa9d6335b0d0 (diff)
downloadbuildstream-sam/git-fetch-prune.tar.gz
git.py source plugin: Prune remote-tracking branches when fetchingsam/git-fetch-prune
I noticed this issue when running `bst track` on a system that contained GLIBC. The following error occurred: [--:--:--] START [gnu-toolchain/stage2-glibc.bst]: Tracking release/2.25/master from git://git.baserock.org/delta/glibc Running host command /home/fedora/src/baserock/definitions/.cache/buildstream/sources/git/git___git_baserock_org_delta_glibc: /usr/bin/git fetch origin [--:--:--] STATUS [gnu-toolchain/stage2-glibc.bst]: Running host command /usr/bin/git fetch origin error: cannot lock ref 'refs/heads/hjl/memcpy/dpdk/master': 'refs/heads/hjl/memcpy' exists; cannot create 'refs/heads/hjl/memcpy/dpdk/master' From git://git.baserock.org/delta/glibc ! [new branch] hjl/memcpy/dpdk/master -> hjl/memcpy/dpdk/master (unable to update local ref) error: cannot lock ref 'refs/heads/hjl/x86/master': 'refs/heads/hjl/x86' exists; cannot create 'refs/heads/hjl/x86/master' ! [new branch] hjl/x86/master -> hjl/x86/master (unable to update local ref) error: cannot lock ref 'refs/heads/hjl/x86/math': 'refs/heads/hjl/x86' exists; cannot create 'refs/heads/hjl/x86/math' ! [new branch] hjl/x86/math -> hjl/x86/math (unable to update local ref) error: cannot lock ref 'refs/heads/hjl/x86/optimize': 'refs/heads/hjl/x86' exists; cannot create 'refs/heads/hjl/x86/optimize' ! [new branch] hjl/x86/optimize -> hjl/x86/optimize (unable to update local ref) error: some local refs could not be updated; try running 'git remote prune origin' to remove any old, conflicting branches git source at gnu-toolchain/stage2-glibc.bst [line 4 column 2]: Failed to fetch from remote git repository: git://git.baserock.org/delta/glibc The issue here is that my local clone had old remote-tracking refs which conflicted with newer upstream refs. For example, there used to be a ref named `hlj/memcpy` which I had mirrored locally. This has been deleted and now a ref exists named `hlj/memcpy/dpdk/master`. The new ref cannot be pulled because Git considers it to conflict with the old one. The solution is to use `git fetch --prune` when updating so that Git removes any outdated remote-tracking refs before trying to create any new ones.
-rw-r--r--buildstream/plugins/sources/git.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/buildstream/plugins/sources/git.py b/buildstream/plugins/sources/git.py
index afbca252c..baf159d82 100644
--- a/buildstream/plugins/sources/git.py
+++ b/buildstream/plugins/sources/git.py
@@ -108,7 +108,7 @@ class GitMirror():
(str(self.source), self.url, tmpdir, self.mirror)) from e
def fetch(self):
- self.source.call([self.source.host_git, 'fetch', 'origin'],
+ self.source.call([self.source.host_git, 'fetch', 'origin', '--prune'],
fail="Failed to fetch from remote git repository: {}".format(self.url),
cwd=self.mirror)