summaryrefslogtreecommitdiff
path: root/fsfmerge.sh
blob: e484fa44ce46cd02c11f0bfc0ae05fb7df1e26ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash

export GIT_WORK_TREE=/work/sources/gcc.git
export GIT_DIR="$GIT_WORK_TREE"/.git

NC='\e[0m'
red='\e[0;31m'
blue='\e[1;34m'
bold='\e[1m'

msg() { echo -n -e "${blue}** ${NC}${bold}$1${NC}" ; }
ask() { msg "$1 " ; eval "read $2"; }

VERSION="$1"
BRANCH="gcc-${VERSION}-branch"
DATE=$(date +"%Y-%m")
MBRANCH="Merge-$BRANCH-$DATE"
msg "Updating repo\n"
git remote update
ask "Creating branch: $MBRANCH [Enter]"
git checkout -b $MBRANCH origin/$BRANCH

msg "Last branch merge commit:\n"
git --no-pager log -n 1 --grep="Merge branches/$BRANCH" --pretty=medium origin/linaro/$BRANCH

REV=$(git log -n 1 --grep="Merge branches/$BRANCH" --format="%s" origin/linaro/$BRANCH)
REV=${REV##* }
REV=${REV%%.}
BSHA1=$(git log -n 1 --format="%h" --grep="$BRANCH@$REV" origin/$BRANCH)
MREV=$(git log -n 1 --format="%b" origin/$BRANCH | grep git-svn-id)
MSHA1=$(git log -n 1 --format="%h" origin/$BRANCH)
MREV=${MREV##*@}
MREV=${MREV%% *}

msg "Remove all rebase entries up to ${red}$BSHA1$\n"
msg "Keep first line as 'pick' and squash remaining ones (s/^pick/squash/)\n"
msg "Last commit to merge should be ${red}$MSHA1$\n"
msg "Branch merge commit message should be:\n"
msg "Merge branches/$BRANCH rev $MREV.\n"
ask "Start rebasing [Press key]"

git rebase -i origin/linaro-local/gcc-${VERSION}-integration-branch

if [ $? -ne 0 ]; then
  msg "Fix the conflicts and continue the rebase with:\n"
  msg "git rebase --continue\n"
  msg "Fix ownership with command:\n"
  msg "git commit --amend --reset-author\n"
else
  ask "Fix ownership [Press key]"
  git commit --amend --reset-author
fi