]> git.ozlabs.org Git - next-scripts/commitdiff
do_merge: many updates
authorStephen Rothwell <sfr@canb.auug.org.au>
Thu, 3 Nov 2011 01:29:19 +0000 (12:29 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Thu, 3 Nov 2011 01:29:19 +0000 (12:29 +1100)
do_merge

index 985a34c54d96979ef6a01179ef84ff110a9cff49..c1e688208a678b48c7b30e5bdca1e3c959806be4 100755 (executable)
--- a/do_merge
+++ b/do_merge
@@ -1,12 +1,14 @@
 #!/bin/bash
 
 LOG_FILE="../merge.log"
-build_host="sprygo"
+build_host="ka2"
 build_dir="/scratch/sfr/next"
 build_cmd="bin/build_next"
 
 no_build=false
 start_from=""
+[ "$NEXT_BUILD_HOST" ] && build_host="$NEXT_BUILD_HOST"
+[ "$NEXT_BUILD_DIR" ] && build_host="$NEXT_BUILD_DIR"
 
 [ "$1" = "-n" ] && {
        shift
@@ -21,7 +23,14 @@ start_from=""
        }
        shift
 }
-[ -n "$1" ] && build_host="$1"
+[ -n "$1" ] && {
+       build_host="$1"
+       shift
+}
+[ -n "$1" ] && {
+       build_dir="$1"
+       shift
+}
 
 log()
 {
@@ -35,8 +44,59 @@ execute()
        return ${PIPESTATUS[0]}
 }
 
+do_rebase()
+{
+       rbase=${1#*/}
+       rbase=${rbase%%:*}
+       rtop=${1#*:}
+       rbid=$(git rev-parse $2/$rbase)
+       rtid=$(git rev-parse $2/$rtop)
+       [ "$rbid" = "$rtid" ] && {
+               echo Empty tree
+               return
+       }
+       [ "$(git rev-list HEAD..$2/$rtop)" ] || {
+               echo Already merged
+               return
+       }
+       execute git clone -s -l -n -q . ../rebase-tmp || {
+               echo Clone failed 1>&2
+               bash -i || exit
+       }
+       log '$' cd ../rebase-tmp
+       cd ../rebase-tmp
+       execute git fetch --no-tags ../next refs/remotes/$2/$rtop:$2/$rtop || {
+               echo Fetch of top failed 1>&2
+               bash -i || exit
+       }
+       execute git fetch --no-tags ../next refs/remotes/$2/$rbase:$2/$rbase || {
+               echo Fetch of base failed 1>&2
+               bash -i || exit
+       }
+       execute git checkout $2/$rtop || {
+               echo Checkout of top failed 1>&2
+               bash -i || exit
+       }
+       execute git rebase --onto master $2/$rbase || {
+               echo Rebase failed 1>&2
+               bash -i || exit
+       }
+       log '$' cd ../next
+       cd ../next
+       execute git pull -f ../rebase-tmp $2/$rtop || {
+               echo Pull failed 1>&2
+               echo $h >>../merge.debug
+               git diff >>../merge.debug 2>&1
+               git diff 2>&1 | egrep -q '<<<<<|^\*' && {
+                       bash -i || exit
+               }
+       }
+       execute rm -rf ../rebase-tmp
+}
+
 [ -n "$start_from" ] || {
        cp /dev/null $LOG_FILE
+       execute date
        execute git checkout master
        execute git reset --hard stable
 }
@@ -59,16 +119,23 @@ for h in $heads; do
 
        log Merging $h
        old_head=$(git rev-parse HEAD)
-       execute git merge $h || {
-               echo Merge failed 1>&2
-               echo $h >>../merge.debug
-               git diff >>../merge.debug 2>&1
-               git diff 2>&1 | egrep -q '<<<<<|^\*' && {
-                       bash -i || exit
+       case "$h" in
+       *:*)
+               do_rebase $h $tree
+               ;;
+       *)
+               execute git merge $h || {
+                       echo Merge failed 1>&2
+                       echo $h >>../merge.debug
+                       git diff >>../merge.debug 2>&1
+                       git diff 2>&1 | egrep -q '<<<<<|^\*' && {
+                               bash -i || exit
+                       }
+                       GIT_EDITOR=: execute git commit -v -a
+                       execute git diff -M --stat --summary 'HEAD^..'
                }
-               GIT_EDITOR=: execute git commit -v -a
-               execute git diff -M --stat --summary 'HEAD^..'
-       }
+               ;;
+       esac
        [ -f "../merge-fixes/$tree" ] && {
                for p in $(cat "../merge-fixes/$tree"); do
                        ../tools/merge_fix -n "$p" || {
@@ -76,6 +143,9 @@ for h in $heads; do
                        }
                done
        }
+       [ -x "../pre-build/$tree" ] && {
+               "../pre-build/$tree" || bash -i || exit
+       }
        $no_build && continue
        $need_build || {
                # See if we need to build after merging this tree
@@ -89,8 +159,8 @@ for h in $heads; do
        do_build=$(grep -v '^#' ../real_control | awk -F '      ' '$3=="'$tree'" { print $6; }')
        [ "$do_build" = "yes" ] ||
                continue
-       rsync -avH --exclude .git --delete . "$build_host":"$build_dir"/. || {
-               echo Rsync failed 1>&2
+       git push -f "$build_host":"$build_dir" master:refs/heads/next || {
+               echo git push failed 1>&2
                bash -i || exit
        }
        ssh "$build_host" "$build_cmd" || {