blob: 6db6029ca1e46de9cd95242dbc559412e8bac396 [file] [log] [blame]
Renato Golin94cc1042016-04-26 11:02:23 +01001#!/usr/bin/env bash
2
3# This script pulls a specific branch from the origin repository, making sure
4# not to keep the prefix. If the branch already exists, try to merge. If not,
5# check out from origin.
6#
Diana Picus72189fd2016-05-23 19:32:46 +03007# Syntax: git-pull linaro-local/[branch]
Renato Golin94cc1042016-04-26 11:02:23 +01008
9. llvm-common
10
11branch=$1
12if [[ $branch = '' ]]; then
13 branch=`get_branch`
14fi
Renato Golin94cc1042016-04-26 11:02:23 +010015
16if [[ $branch = 'master' ]]; then
17 echo "Can't pull the master branch."
18 echo "Use git-refresh instead."
19 exit 1
20fi
21
22prefix="linaro-local/"
23if echo $branch | grep -q linaro-local; then
24 prefix=""
25fi
26
27safe_run git-refresh
28
29if git branch -a | not grep -q $branch; then
30 echo "Branch '$branch' doesn't exist in this repository"
31 exit 2
32fi
33
34# If the branch exists already, merge
35if git branch | grep -q $branch; then
Renato Golin94cc1042016-04-26 11:02:23 +010036 echo " + Merging the origin branch..."
37 if not git merge --ff-only origin/$prefix$branch; then
Diana Picus72189fd2016-05-23 19:32:46 +030038 echo "Error merging the branch."
Renato Golin94cc1042016-04-26 11:02:23 +010039 exit 1
40 fi
41# If not, just check out the branch
42else
43 safe_run git checkout -b $branch origin/$prefix$branch
44fi