blob: 114afbe7e23340e4b3ac73960db9c33d9cf02f94 [file] [log] [blame]
Diana Picus72189fd2016-05-23 19:32:46 +03001#!/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
10branch=`get_branch`
11echo "Rebasing $branch"
12
13if [[ `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
17fi
18
19if [[ `git branch | grep $branch` = '' ]]; then
20 echo "Branch $branch doesn't exist in this repository"
21 exit 3
22fi
23
24if [[ "$branch" = "master" ]]; then
25 echo "Can't rebase master"
26 exit 4
27fi
28
29git rebase master
30if [[ $? != 0 ]]; then
31 echo "Rebase failed, aborting rebase..."
32 safe_run git rebase --abort
33 exit 1
34fi