| #!/usr/bin/env bash |
| |
| # This script pulls a specific branch from the origin repository, making sure |
| # not to keep the prefix. If the branch already exists, try to merge. If not, |
| # check out from origin. |
| # |
| # Syntax: git-pull linaro-local/[branch] |
| |
| . llvm-common |
| |
| branch=$1 |
| if [[ $branch = '' ]]; then |
| branch=`get_branch` |
| fi |
| |
| if [[ $branch = 'master' ]]; then |
| echo "Can't pull the master branch." |
| echo "Use git-refresh instead." |
| exit 1 |
| fi |
| |
| prefix="linaro-local/" |
| if echo $branch | grep -q linaro-local; then |
| prefix="" |
| fi |
| |
| safe_run git-refresh |
| |
| if git branch -a | not grep -q $branch; then |
| echo "Branch '$branch' doesn't exist in this repository" |
| exit 2 |
| fi |
| |
| # If the branch exists already, merge |
| if git branch | grep -q $branch; then |
| echo " + Merging the origin branch..." |
| if not git merge --ff-only origin/$prefix$branch; then |
| echo "Error merging the branch." |
| exit 1 |
| fi |
| # If not, just check out the branch |
| else |
| safe_run git checkout -b $branch origin/$prefix$branch |
| fi |