]> git.ozlabs.org Git - next-scripts/blobdiff - do_merge
do_merge: we have had no rebasing trees for some time
[next-scripts] / do_merge
index 1ede56cfbd3f08875daf833a3bbd388774c2672a..01d7f1c01bbdc1220680286639b0419a2780d264 100755 (executable)
--- a/do_merge
+++ b/do_merge
 #!/bin/bash
 
-while read name url ref; do
-       [[ -z "$ref" ]] && ref="master"
-       echo $name $ref
-       git merge -n $name/$ref
-       [[ -f .git/MERGE_HEAD ]] && {
-               echo $name $ref >>Next/conflicts
-               git reset --hard
-       }
-done <Next/control 2>&1 | tee Next/merge.log
+no_build=false
+start_from=""
+
+[ "$1" = "-n" ] && {
+       shift
+       no_build=true
+}
+[ "$1" = "-s" ] && {
+       shift
+       start_from="$1"
+       [ -z "$start_from" ] && {
+               echo "-s requires a start tree" 1>&2
+               exit 1
+       }
+       shift
+}
+
+tool_dir=$(dirname "$0")
+. "$tool_dir/common.sh"
+
+log()
+{
+       echo "$@" | tee -a "$LOG_FILE"
+}
+
+execute()
+{
+       log "$" "$@"
+       "$@" 2>&1 | tee -a "$LOG_FILE"
+       return "${PIPESTATUS[0]}"
+}
+
+[ -n "$start_from" ] || {
+       cp /dev/null "$LOG_FILE"
+       execute date -R
+       execute git checkout master
+       execute git reset --hard stable
+       printf 'Name\t\tSHA1\n----\t\t----\n' > "$SHA1_FILE"
+
+}
+
+heads=$(awk -F '\t' '/^#/ { next; } $2=="quilt" || $2=="git" { printf("%s/%s ", $3, $5); } $2=="branch" { printf("branch/%s ", $1); }' "$CTRL_FILE")
+
+need_build=false
+
+for h in $heads; do
+       tree=${h%%/*}
+
+       [ -n "$start_from" ] && {
+               if [ "$tree" = "$start_from" ]; then
+                       start_from=""
+               else
+                       continue
+               fi
+       }
+
+       [ "$tree" = "branch" ] && {
+               git branch -f "${h#branch/}"
+               continue
+       }
+
+       hlog=$(git log -1 --oneline "${h/\/*://}") 2>/dev/null
+       old_head=$(git rev-parse HEAD)
+       [ -f "../pre-merge/$tree" ] && {
+               for p in $(cat "../pre-merge/$tree"); do
+                       "$bin_dir/do_patch" -n "$p" || {
+                               linux-next-notify "premerge patch failed"
+                               bash -i || exit
+                       }
+               done
+       }
+       log Merging "$h" "($hlog)"
+       execute git merge "$h" || {
+               echo Merge failed 1>&2
+               echo "$h" >>../merge.debug
+               git diff >>../merge.debug 2>&1
+
+               check_unmerged_files "$tree"
+
+               git diff 2>&1 | egrep -q '<<<<<|^\*' && {
+                       linux-next-notify "new conflict found merging $tree"
+                       if [ -f "../merge-fixes/$tree" ]; then
+                               echo "Merge fixes exist for this tree:"
+                               cat "../merge-fixes/$tree"
+                       fi
+                       bash -i || exit
+               }
+#              [ "$(git status --porcelain)" ] && {
+                       GIT_EDITOR=: execute git commit -v -a || {
+                               linux-next-notify "next commit failed for $tree"
+                               bash -i || exit
+                       }
+                       execute git diff -M --stat --summary 'HEAD^..'
+#              }
+       }
+       [ -f "../merge-fixes/$tree" ] && {
+               for p in $(cat "../merge-fixes/$tree"); do
+                       "$bin_dir/merge_fix" -n "$p" || {
+                               linux-next-notify "merge fix failed for $tree"
+                               bash -i || exit
+                       }
+               done
+       }
+       tab="\t"
+       [ $(echo "$tree" | wc -c) -le 8 ] && tab="\t\t"
+       printf "%s$tab%s\n" $tree $(git rev-parse "${h/\/*://}^{}") >> $SHA1_FILE
+       $no_build && continue
+       $need_build || {
+               # See if we need to build after merging this tree
+               new_head=$(git rev-parse HEAD)
+               [ "$old_head" = "$new_head" ] ||
+                       [ "$(git diff ${old_head}.. | wc -c)" -eq 0 ] ||
+                               need_build=true
+       }
+       $need_build ||
+               continue
+       do_build=$(awk -F '\t' '/^[^#]/ && $3=="'$tree'" { print $6; }' "$CTRL_FILE")
+       [ "$do_build" = "yes" ] ||
+               continue
+       git push -f "${build_host}${build_host:+:}${build_dir}" master:refs/heads/next || {
+               echo git push failed 1>&2
+               linux-next-notify "push failed for $tree"
+               bash -i || exit
+       }
+       [ -x "../pre-build/$tree" ] && {
+               "../pre-build/$tree" || {
+                       echo Prebuild script failed 1>&2
+                       linux-next-notify "pre-build script failed for $tree"
+                       bash -i || exit
+               }
+       }
+       "$bin_dir/do_build" "$tree" || {
+               echo Build failed 1>&2
+               linux-next-notify "build failed for $tree"
+               bash -i || exit
+       }
+
+       need_build=false
+done
+
+exit 0