From ed16f8131507c00a058568fc1d34169262ae40a4 Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Wed, 24 Jul 2019 14:43:38 +1000 Subject: [PATCH] abstract out check_unmerged files --- common.sh | 15 +++++++++++++++ do_merge | 9 +++------ import-akpm | 11 +++++------ merge_akpm | 9 +++------ 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/common.sh b/common.sh index 9f18277..7eaa486 100644 --- a/common.sh +++ b/common.sh @@ -54,4 +54,19 @@ get_contacts() awk -F '\t' '/^[^#]/ && $3=="'"$1"'" { print $1; }' $CTRL_FILE } +check_unmerged_files() +{ + local tree="$1" + local um_files + local rm_files + + um_files=$(git diff 2>&1 | sed -n 's/^\* Unmerged path //p') + if [ "$um_files" ] && [ -f "../merge-files/$tree" ]; then + rm_files=$(grep -F "$um_files" "../merge-files/$tree") + if [ "$rm_files" ]; then + "$bin_dir/do_rm" $rm_files + fi + fi +} + true diff --git a/do_merge b/do_merge index eee2032..1618be3 100755 --- a/do_merge +++ b/do_merge @@ -131,12 +131,9 @@ for h in $heads; do echo Merge failed 1>&2 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" ] && { - rm_files=$(grep -F "$um_files" "../merge-files/$tree") - [ "$rm_files" ] && - "$bin_dir/do_rm" $rm_files - } + + check_unmerged_files "$tree" + git diff 2>&1 | egrep -q '<<<<<|^\*' && { linux-next-notify "new conflict found merging $tree" if [ -f "../merge-fixes/$tree" ]; then diff --git a/import-akpm b/import-akpm index ef85f1f..ac57504 100755 --- a/import-akpm +++ b/import-akpm @@ -2,6 +2,9 @@ export LOG_FILE=../akpm-import.log +# shellcheck source=./common.sh +. "$(dirname "$0")/common.sh" '' + log() { echo "$@" | tee -a $LOG_FILE @@ -67,12 +70,8 @@ for f in $patches; do execute git branch tmp-akpm/current || $SHELL -i || exit execute git merge --no-edit --no-stat "$dnb" || { - umf=$(git diff 2>&1 | sed -n 's/^\* Unmerged path //p') - [ "$umf" ] && [ -f "../merge-files/akpm-current" ] && { - rmf=$(grep -F "$umf" "../merge-files/akpm-current") - [ "$rmf" ] && - "$bin_dir/do_rm" $rmf - } + check_unmerged_files akpm-current + git diff 2>&1 | grep -E -q '<<<<<|^\*' && { $SHELL -i || exit } diff --git a/merge_akpm b/merge_akpm index 0c3684d..4b9be3a 100755 --- a/merge_akpm +++ b/merge_akpm @@ -36,12 +36,9 @@ execute git merge --no-ff akpm-current/current || { echo Merge failed 1>&2 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/akpm-current" ] && { - rm_files=$(grep -F "$um_files" "../merge-files/akpm-current") - [ "$rm_files" ] && - "$bin_dir/do_rm" $rm_files - } + + check_unmerged_files akpm-current + git diff 2>&1 | egrep -q '<<<<<|^\*' && { bash -i || exit } -- 2.39.5