X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=do_merge;h=eee20322459ff7cd976a2c319089258f7d51dc18;hb=e8d4ba815a033ff46dc0891daac5c309d0480d6c;hp=b9ed8f968c18696079e24a4c9b392a5946747e3d;hpb=46293c6471c02a8ba76fb7f80dcedc6c5645466b;p=next-scripts diff --git a/do_merge b/do_merge index b9ed8f9..eee2032 100755 --- a/do_merge +++ b/do_merge @@ -17,32 +17,33 @@ start_from="" shift } -. "$(dirname $0)/common.sh" +tool_dir=$(dirname "$0") +. "$tool_dir/common.sh" log() { - echo "$@" | tee -a $LOG_FILE + echo "$@" | tee -a "$LOG_FILE" } execute() { - log "$" $@ - $@ 2>&1 | tee -a $LOG_FILE - return ${PIPESTATUS[0]} + log "$" "$@" + "$@" 2>&1 | tee -a "$LOG_FILE" + return "${PIPESTATUS[0]}" } do_rebase() { rbase=${1#*/} - rbase=${rbase%%:*} - rtop=${1#*:} - rbid=$(git rev-parse $2/$rbase) - rtid=$(git rev-parse $2/$rtop) + rbase="$2/${rbase%%:*}" + rtop="$2/${1#*:}" + rbid=$(git rev-parse "$rbase") + rtid=$(git rev-parse "$rtop") [ "$rbid" = "$rtid" ] && { echo Empty tree return } - [ "$(git rev-list HEAD..$2/$rtop)" ] || { + [ "$(git rev-list HEAD..$rtop)" ] || { echo Already merged return } @@ -52,27 +53,27 @@ do_rebase() } log '$' cd ../rebase-tmp cd ../rebase-tmp - execute git fetch --no-tags ../next refs/remotes/$2/$rtop:$2/$rtop || { + execute git fetch --no-tags ../next "refs/remotes/$rtop:$rtop" || { echo Fetch of top failed 1>&2 bash -i || exit } - execute git fetch --no-tags ../next refs/remotes/$2/$rbase:$2/$rbase || { + execute git fetch --no-tags ../next "refs/remotes/$rbase:$rbase" || { echo Fetch of base failed 1>&2 bash -i || exit } - execute git checkout $2/$rtop || { + execute git checkout "$rtop" || { echo Checkout of top failed 1>&2 bash -i || exit } - execute git rebase --onto master $2/$rbase || { + execute git rebase --onto master "$rbase" || { echo Rebase failed 1>&2 bash -i || exit } log '$' cd ../next cd ../next - execute git pull -f ../rebase-tmp $2/$rtop || { + execute git pull -f ../rebase-tmp "$rtop" || { echo Pull failed 1>&2 - echo $h >>../merge.debug + echo "$h" >>../merge.debug git diff >>../merge.debug 2>&1 git diff 2>&1 | egrep -q '<<<<<|^\*' && { bash -i || exit @@ -82,15 +83,15 @@ do_rebase() } [ -n "$start_from" ] || { - cp /dev/null $LOG_FILE + 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 + printf 'Name\t\tSHA1\n----\t\t----\n' > "$SHA1_FILE" } -heads=$(grep -v '^#' $CTRL_FILE | awk -F '\t' '$2=="quilt" || $2=="git" { printf("%s/%s ", $3, $5); }') +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 @@ -105,25 +106,30 @@ for h in $heads; do fi } - hlog=$(git log -1 --oneline ${h/\/*://}) 2>/dev/null + [ "$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" || { - notify-send -u critical -t 0 "premerge patch failed" + linux-next-notify "premerge patch failed" bash -i || exit } done } - log Merging $h "($hlog)" + log Merging "$h" "($hlog)" case "$h" in *:*) - do_rebase $h $tree + do_rebase "$h" "$tree" ;; *) - execute git merge $h || { + execute git merge "$h" || { echo Merge failed 1>&2 - echo $h >>../merge.debug + echo "$h" >>../merge.debug git diff >>../merge.debug 2>&1 um_files=$(git diff 2>&1 | sed -n 's/^\* Unmerged path //p') [ "$um_files" ] && [ -f "../merge-files/$tree" ] && { @@ -132,8 +138,7 @@ for h in $heads; do "$bin_dir/do_rm" $rm_files } git diff 2>&1 | egrep -q '<<<<<|^\*' && { - notify-send -t 0 -u critical "linux-next new conflict found merging $tree!" - pushover "linux-next new conflict found merging $tree!" + 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" @@ -142,8 +147,7 @@ for h in $heads; do } # [ "$(git status --porcelain)" ] && { GIT_EDITOR=: execute git commit -v -a || { - notify-send -t 0 -u critical "linux-next commit failed for $tree!" - pushover "linux-next commit failed for $tree!" + linux-next-notify "next commit failed for $tree" bash -i || exit } execute git diff -M --stat --summary 'HEAD^..' @@ -154,8 +158,7 @@ for h in $heads; do [ -f "../merge-fixes/$tree" ] && { for p in $(cat "../merge-fixes/$tree"); do "$bin_dir/merge_fix" -n "$p" || { - notify-send -t 0 -u critical "linux-next merge fix failed for $tree!" - pushover "linux-next merge fix failed for $tree!" + linux-next-notify "merge fix failed for $tree" bash -i || exit } done @@ -173,32 +176,27 @@ for h in $heads; do } $need_build || continue - do_build=$(grep -v '^#' $CTRL_FILE | awk -F ' ' '$3=="'$tree'" { print $6; }') + 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 - notify-send -t 0 -u critical "linux-next push failed for $tree!" - pushover "linux-next push failed for $tree!" + linux-next-notify "push failed for $tree" bash -i || exit } [ -x "../pre-build/$tree" ] && { "../pre-build/$tree" || { echo Prebuild script failed 1>&2 - notify-send -t 0 -u critical "linux-next pre-build script failed for $tree!" - pushover "linux-next pre-build script failed for $tree!" + linux-next-notify "pre-build script failed for $tree" bash -i || exit } } - "$bin_dir/do_build" || { + "$bin_dir/do_build" "$tree" || { echo Build failed 1>&2 - notify-send -t 0 -u critical "linux-next build failed for $tree!" - pushover "linux-next build failed for $tree!" + linux-next-notify "build failed for $tree" bash -i || exit } - notify-send -u normal "Merge and build of $tree successful" - need_build=false done