| #!/usr/bin/env bash |
| |
| # This script rebases the current branch on the current master. It does not |
| # pull upstream master beforehand. If you need a fresh master, use git-refresh. |
| # |
| # Syntax: git-rebase |
| |
| . llvm-common |
| |
| branch=`get_branch` |
| echo "Rebasing $branch" |
| |
| if [[ `git diff | head -1` != '' ]]; then |
| echo "You have uncommitted changes in your repo, bailing" |
| echo "Please, stash your changes and run this script again" |
| exit 2 |
| fi |
| |
| if [[ `git branch | grep $branch` = '' ]]; then |
| echo "Branch $branch doesn't exist in this repository" |
| exit 3 |
| fi |
| |
| if [[ "$branch" = "master" ]]; then |
| echo "Can't rebase master" |
| exit 4 |
| fi |
| |
| git rebase master |
| if [[ $? != 0 ]]; then |
| echo "Rebase failed, aborting rebase..." |
| safe_run git rebase --abort |
| exit 1 |
| fi |