Diana Picus | 72189fd | 2016-05-23 19:32:46 +0300 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | # This script rebases the current branch on the current master. It does not |
| 4 | # pull upstream master beforehand. If you need a fresh master, use git-refresh. |
| 5 | # |
| 6 | # Syntax: git-rebase |
| 7 | |
| 8 | . llvm-common |
| 9 | |
| 10 | branch=`get_branch` |
| 11 | echo "Rebasing $branch" |
| 12 | |
| 13 | if [[ `git diff | head -1` != '' ]]; then |
| 14 | echo "You have uncommitted changes in your repo, bailing" |
| 15 | echo "Please, stash your changes and run this script again" |
| 16 | exit 2 |
| 17 | fi |
| 18 | |
| 19 | if [[ `git branch | grep $branch` = '' ]]; then |
| 20 | echo "Branch $branch doesn't exist in this repository" |
| 21 | exit 3 |
| 22 | fi |
| 23 | |
| 24 | if [[ "$branch" = "master" ]]; then |
| 25 | echo "Can't rebase master" |
| 26 | exit 4 |
| 27 | fi |
| 28 | |
| 29 | git rebase master |
| 30 | if [[ $? != 0 ]]; then |
| 31 | echo "Rebase failed, aborting rebase..." |
| 32 | safe_run git rebase --abort |
| 33 | exit 1 |
| 34 | fi |