4 function is_parent_branch
{
5 if [ "$(parent_branch $2)" = "$1" ]; then
12 function parent_branch
{
13 # Given a branch, $1, find the parent.
14 PARENT_BRANCH
=`git cat-file -p branch-created.$1 2> /dev/null | tail -1 | grep "parent:" | cut -d":" -f2`
15 if [ "$PARENT_BRANCH" != "" ]; then
22 function other_branches
{
23 for b
in $
(git branch
-r); do
24 if [[ `echo $b|grep *` ]]; then b
=$
(cut
-d" " -f0); fi
25 b
=`echo $b|cut -d"/" -f2`
26 if [[ `echo $*|grep $b` ]]; then continue; fi
31 # Parameter processing here
32 # mergebranch [-d] [from_branch] [to_branch]
33 while [ "$1" != "" ]; do
34 if [ "$1" = "-d" ]; then
36 elif [ "$MERGE_FROM" = "" ]; then
38 elif [ "$MERGE_INTO" = "" ]; then
45 if [ "$MERGE_FROM" = "" ]; then
46 MERGE_FROM
=`currentbranchname`
49 if [ "$MERGE_INTO" = "" ]; then
50 MERGE_INTO
=$
(parent_branch
$MERGE_FROM)
53 if [ "$DRYRUN" != 1 ]; then
57 echo $DRYRUN - $MERGE_FROM - $MERGE_INTO
59 if ( git status|
grep ".dotest/" ); then
60 echo "Need to resolve conflicts updating branch before merge can continue..."
63 changebranch master
&> /dev
/null
64 if [ "$DRYRUN" != 1 ]; then
69 if ( git status|
grep ".dotest/" ); then
70 echo "Need to resolve conflicts updating branch before merge can continue..."
73 if ( is_parent_branch
$MERGE_FROM $MERGE_INTO ); then
74 git
diff --stat $MERGE_INTO...
$MERGE_FROM
75 if [ "$DRYRUN" != 1 ]; then
78 changebranch
$MERGE_FROM &> /dev
/null
81 echo "Cannot merge from branch $MERGE_FROM into non-parent $MERGE_INTO. $MERGE_FROM's parent is $(parent_branch $MERGE_FROM)."