summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbackflip56
1 files changed, 42 insertions, 14 deletions
diff --git a/backflip b/backflip
index 62438f3..ef6b939 100755
--- a/backflip
+++ b/backflip
@@ -10,13 +10,33 @@
# Configuration
# ==============================================================================
VERSION=4.9
-LINARO_REF_BRANCH=linaro-${VERSION}-branch
+REF_BRANCH=linaro-${VERSION}-branch
DATE=`date +%Y-%m-%d`
NAME=`git config user.name`
FNAME=`echo ${NAME} | cut -d ' ' -f 1`
EMAIL=`git config user.email`
EDITOR="${EDITOR:-vim}"
+STACKED=false
+
+# Arguments
+while getopts "b:r:v:" options
+do
+ case $options in
+ r ) REF_BRANCH=$OPTARG
+ ;;
+ b ) DEV_BRANCH=$OPTARG
+ STACKED=true
+ ;;
+ v ) VERSION=$OPTARG
+ ;;
+ esac
+done
+shift $(($OPTIND - 1))
+
+if [ -z ${DEV_BRANCH+x} ]; then
+ DEV_BRANCH=${REF_BRANCH}
+fi
# Style
NC='\e[0m'
@@ -52,20 +72,20 @@ ask() {
# arg1 : svn rev number
# arg2 : ChangeLog file
-# Create ChangeLog entry for arg1 in arg2.frag
+# Create ChangeLog entry for arg1 in arg2.arg1.frag
forge_entry() {
- echo -e $DATE" "$NAME" <"$EMAIL">\n\n\tBackport from trunk r"$1"." >> $2.frag
+ echo -e $DATE" "$NAME" <"$EMAIL">\n\n\tBackport from trunk r"$1"." >> $2.$1.frag
git show --format=oneline ${SHA1} -- $2 \
| grep ^+ \
| sed -e '1d' -e 's:^+::' \
- | awk '$1 ~ /^2.*$/ {print "\t"$0} $1 !~ /^2.*$/ {print $0}' >> $2.frag
+ | awk '$1 ~ /^2.*$/ {print "\t"$0} $1 !~ /^2.*$/ {print $0}' >> $2.$1.frag
print_info "${bold}Forged ChangeLog entry:${NC}"
- cat $2.frag
+ cat $2.$1.frag
ask "${bold}Edit ChangeLog entry [N/y] ?" user_edit
if [ "$user_edit" == "y" ]; then
- "$EDITOR" $2.frag
+ "$EDITOR" $2.$1.frag
fi
- git add $2.frag
+ git add $2.$1.frag
}
# ==============================================================================
@@ -98,7 +118,7 @@ fi
# ==============================================================================
print_step "Cherry-picking Revision"
# ==============================================================================
-git checkout $LINARO_REF_BRANCH
+git checkout $DEV_BRANCH
git cherry-pick -n $SHA1
# ==============================================================================
@@ -126,18 +146,26 @@ fi
# ==============================================================================
print_step "Branch/Commit/Push/Review"
# ==============================================================================
-bname=${FNAME}-${VERSION}-backport-${1}
+if $STACKED; then
+ bname=${DEV_BRANCH}-${1}
+else
+ bname=${FNAME}-${VERSION}-backport-${1}
+fi
ask "${bold}Create backport branch [Y/n] ?" user_bc
if [ "$user_bc" != "n" ]; then
ask "${bold}Change name (${blue}${bname}${NC}${bold}) [N/y] ?" user_bname
if [ "$user_bname" == "y" ]; then
ask "${bold}Enter name :" bname
fi
- git checkout -b ${bname} origin/${LINARO_REF_BRANCH}
+ git checkout -b ${bname} ${DEV_BRANCH}
ask "${bold}Commit backport [Y/n] ?" user_commit
if [ "$user_commit" != "n" ]; then
- git commit
+ if $STACKED; then
+ git commit --amend
+ else
+ git commit
+ fi
ask "${bold}Create patch [Y/n] ?" user_patch
if [ "$user_patch" != "n" ]; then
@@ -151,8 +179,8 @@ if [ "$user_bc" != "n" ]; then
ask "${bold}Request review (amend commit) [Y/n] ?" user_review
if [ "$user_review" != "n" ]; then
git commit --amend
- git review $LINARO_REF_BRANCH
- git checkout $LINARO_REF_BRANCH
+ git review $REF_BRANCH
+ git checkout $DEV_BRANCH
fi
fi
fi
@@ -163,7 +191,7 @@ ask "${bold}Abort and Cleanup [N/y] ?" user_abort
# ==============================================================================
if [ "$user_abort" == "y" ]; then
git reset --hard
- git checkout ${LINARO_REF_BRANCH}
+ git checkout ${DEV_BRANCH}
if [ "$user_bc" != "n" ]; then
git branch -D ${bname}
if [ "$user_push" != "n" ]; then