From 8b9ae4a6483b09ae920a1eb04362207e4fb5b7f0 Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Fri, 26 Jul 2019 14:49:31 +1000 Subject: [PATCH] change some style use if cond ... instead of cond && etc --- do_merge | 99 ++++++++++++++++++++++++++++++++------------------------ 1 file changed, 56 insertions(+), 43 deletions(-) diff --git a/do_merge b/do_merge index ab12c59..243fc50 100755 --- a/do_merge +++ b/do_merge @@ -33,110 +33,123 @@ execute() return "${PIPESTATUS[0]}" } -[ -n "$start_from" ] || { +if [ -z "$start_from" ]; then 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" +fi -} - -heads=$(awk -F '\t' '/^#/ { next; } $2=="quilt" || $2=="git" { printf("%s/%s ", $3, $5); } $2=="branch" { printf("branch/%s ", $1); }' "$CTRL_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 [ -n "$start_from" ]; then if [ "$tree" = "$start_from" ]; then start_from="" else continue fi - } + fi - [ "$tree" = "branch" ] && { + if [ "$tree" = "branch" ]; then git branch -f "${h#branch/}" continue - } + fi - hlog=$(git log -1 --oneline "${h/\/*://}") 2>/dev/null + hlog=$(git log -1 --oneline "$h") 2>/dev/null old_head=$(git rev-parse HEAD) - [ -f "../pre-merge/$tree" ] && { + if [ -f "../pre-merge/$tree" ]; then while read -r p <&7; do if ! "$bin_dir/do_patch" -n "$p"; then linux-next-notify "premerge patch failed" bash -i || exit fi 7<&- done 7<"../pre-merge/$tree" - } + fi log Merging "$h" "($hlog)" - execute git merge "$h" || { + if ! execute git merge "$h"; then echo Merge failed 1>&2 echo "$h" >>../merge.debug git diff >>../merge.debug 2>&1 check_unmerged_files "$tree" - git diff 2>&1 | grep -E -q '<<<<<|^\*' && { + if git diff 2>&1 | grep -E -q '<<<<<|^\*'; then 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 || { + fi +# if [ "$(git status --porcelain)" ]; then + if ! execute git commit --no-edit -v -a; then linux-next-notify "next commit failed for $tree" bash -i || exit - } + fi execute git diff -M --stat --summary 'HEAD^..' -# } - } - [ -f "../merge-fixes/$tree" ] && { +# fi + fi + if [ -f "../merge-fixes/$tree" ]; then while read -r p <&7; do if ! "$bin_dir/merge_fix" -n "$p"; then linux-next-notify "merge fix failed for $tree" bash -i || exit fi 7<&- done 7<"../merge-fixes/$tree" - } + fi + tab=$'\t' - [ "${#tree}" -le 8 ] && tab=$'\t\t' - printf '%s%s%s\n' "$tree" "$tab" "$(git rev-parse "${h/\/*://}^{}")" >> "$SHA1_FILE" - $no_build && continue - $need_build || { + if [ "${#tree}" -le 8 ]; then + tab=$'\t\t' + fi + printf '%s%s%s\n' "$tree" "$tab" "$(git rev-parse "$h^{}")" >> "$SHA1_FILE" + + if $no_build; then + continue + fi + + if ! $need_build; then # 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 || + if [ -n "$(git diff "$old_head"..)" ]; then + need_build=true + fi + fi + if ! $need_build; then continue + fi + do_build=$(awk -F '\t' '/^[^#]/ && $3=="'"$tree"'" { print $6; }' "$CTRL_FILE") - [ "$do_build" = "yes" ] || + if [ "$do_build" != "yes" ]; then continue - git push -f "${build_host}${build_host:+:}${build_dir}" master:refs/heads/next || { + fi + + repo="${build_host:+$build_host:}${build_dir}" + if ! git push -f "$repo" master:refs/heads/next; then 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" || { + fi + + if [ -x "../pre-build/$tree" ] && + ! "../pre-build/$tree"; then + echo Prebuild script failed 1>&2 + linux-next-notify "pre-build script failed for $tree" + bash -i || exit + fi + if ! "$bin_dir/do_build" "$tree"; then echo Build failed 1>&2 linux-next-notify "build failed for $tree" bash -i || exit - } + fi need_build=false done -- 2.39.5