aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan S. Arnold <ryan.arnold@linaro.org>2015-10-01 16:33:51 -0500
committerRyan S. Arnold <ryan.arnold@linaro.org>2015-10-01 23:25:06 -0500
commitb69580653a31b02815fb513c987798fe3137d6a5 (patch)
treea614788a94ce72dfafd910122102e597c796e9ca
parente3b7c0311aa81814823be3305baf7c4aed5c8ce3 (diff)
lib/checkout.sh: prune git branches before git pull in checkout() 'Update' code path.
This is required due to the following scenario: A git reference dir is populated with a git clone on day X. On day Y a developer removes a branch and then replaces the same branch with a new branch of the same name. On day Z ABE is executed against the reference dir copy and the git pull fails due to error: 'refs/remotes/origin/<branch>' exists; cannot create 'refs/remotes/origin/<branch>'. You have to remove the stale branches before pulling the new ones. Change-Id: I436b4961deb5496e3b28567bad59e22f91ee7d09
-rw-r--r--lib/checkout.sh11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/checkout.sh b/lib/checkout.sh
index 9f983535..5299b706 100644
--- a/lib/checkout.sh
+++ b/lib/checkout.sh
@@ -367,6 +367,17 @@ checkout()
notice "Updating sources for ${tool} in ${srcdir}"
dryrun "(cd ${repodir} && git stash --all)"
dryrun "(cd ${repodir} && git reset --hard)"
+
+ # This is required due to the following scenario: A git
+ # reference dir is populated with a git clone on day X. On day
+ # Y a developer removes a branch and then replaces the same
+ # branch with a new branch of the same name. On day Z ABE is
+ # executed against the reference dir copy and the git pull fails
+ # due to error: 'refs/remotes/origin/<branch>' exists; cannot
+ # create 'refs/remotes/origin/<branch>'. You have to remove the
+ # stale branches before pulling the new ones.
+ dryrun "(cd ${repodir} && git remote prune origin)"
+
dryrun "(cd ${repodir} && git_robust pull)"
# Update branch directory (which maybe the same as repo
# directory)