blob: 2869dcf7a6ed84bed0a28ad439b87b4b135e92d1 [file] [log] [blame]
Renato Golin94cc1042016-04-26 11:02:23 +01001#!/usr/bin/env bash
2
3# This script pushes the current branch to the origin repository.
4# As an added bonus, it refreshes the local master branch from
5# the origin, to make sure your branch is in sync with the master of the
6# repo you're pushing to.
7#
8# Syntax: git-push [branch (default=current)]
9
10. llvm-common
11
12branch=
13if [[ $1 != '' ]]; then
14 if [[ `git branch | grep $1` = '' ]]; then
15 echo "Branch '$1' doesn't exist in this repository"
16 exit 2
17 fi
18 branch=$1
19else
20 branch=`get_branch`
21fi
22
23if [[ $branch = 'master' ]]; then
24 echo "Can't push the master branch."
25 echo "Use git-refresh instead."
26 exit 1
27fi
28
29prefix="linaro-local/"
30if echo $branch | grep -q linaro-local; then
31 prefix=""
32fi
33
34echo " ++ Refresh Master from Upstream"
35safe_run git-refresh
36
37echo " ++ Rebase to new master"
38safe_run git checkout $branch
39safe_run git rebase master
40
41echo " ++ Push $branch to Origin"
42safe_run git push -u origin +$branch:$prefix$branch