]> git.ozlabs.org Git - next-scripts/commitdiff
detect duplicate patches
authorStephen Rothwell <sfr@canb.auug.org.au>
Wed, 11 Jan 2023 01:05:11 +0000 (12:05 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 11 Jan 2023 01:05:11 +0000 (12:05 +1100)
common.sh
do_merge
fetch_trees
from_build_host

index 2d46df5ba4b41a763dccc5406df1a11cc80c2de0..1f66c136f5dc74092c245e8b802ef37d6274e1b7 100644 (file)
--- a/common.sh
+++ b/common.sh
@@ -134,4 +134,37 @@ check_unmerged_files()
        fi
 }
 
+check_dups()
+{
+       # "In POSIX sh, 'local' is undefined."
+       # shellcheck disable=SC3043
+       local name base sha dfile
+
+       name="$1"
+       base="$2"
+       sha="$3"
+       if [ "$base" = "HEAD" ]; then
+               dfile="$top_dir/duplicates/next/$name"
+       else
+               dfile="$top_dir/duplicates/linus/$name"
+       fi
+
+       # if there is anything in this tree, then check for duplicates
+       if [ "$(git rev-list --count --no-merges "$base".."$sha")" -eq 0 ]; then
+               rm -f "$dfile"
+               return;
+       fi
+
+       dups=$(git cherry "$base" "$sha" | sed -n 's/^- //p' |
+               xargs -r -n 1 "$tools_dir"/clog | sort)
+       if [ -z "$dups" ]; then
+               rm -f "$dfile"
+       elif ! [ -f "$dfile" ]; then
+               printf '%s\n' "$dups" | tee "$dfile"
+       elif ! printf '%s\n' "$dups" | cmp -s - "$dfile"; then
+               printf '%s\n' "$dups" | comm -23 - "$dfile"
+               printf '%s\n' "$dups" >"$dfile"
+       fi
+}
+
 true
index 84df69509fa56b8daa3ea85a1a2a9470d607c857..68ba9d793bbc4b6567564d451df57ba75fd9a40c 100755 (executable)
--- a/do_merge
+++ b/do_merge
@@ -18,7 +18,8 @@ while getopts 'ns:' opt; do
 done
 shift $((OPTIND - 1))
 
-. "$(dirname "$0")/common.sh"
+tools_dir=$(dirname "$0")
+. "$tools_dir/common.sh"
 
 log()
 {
@@ -89,6 +90,7 @@ for h in $heads; do
                done 7<"../pre-merge/$tree"
        fi
        log Merging "$h" "($hlog)"
+       check_dups "$tree" HEAD "$h"
        msg=$(printf "Merge branch '%s' of %s" "${h#*/}" "$(get_url "$tree")")
        if ! execute git merge -m "$msg" "$h"; then
                echo Merge failed 1>&2
index 12d50d03478275c5b911c0f8283e17ea0078f4dc..d1e3fa312909b8b4529426cb45582c36439cdb56 100755 (executable)
@@ -55,6 +55,7 @@ for name in $trees; do
                old_sha=$(git rev-parse "$name/$branch")
                "$fun" "$name"
                new_sha=$(git rev-parse "$name/$branch")
+               check_dups "$name" origin/master "$new_sha"
                if ! [ "$new_sha" = "$old_sha" ]; then
                        "$tools_dir"/check_commits ^origin/master "$old_sha..$new_sha"
                fi
index 6a2829a274a5f1d2d205cbf5cd89dbc9a372c722..e26bb834713781e8f30e1e79eca80cee7a2b27b4 100755 (executable)
@@ -5,6 +5,7 @@
 rsync -avHPSUXx --open-noatime --delete \
        --exclude "gitk.cache" \
        --exclude '.gitk-tmp**' \
+       --include '/duplicates/***' \
        --include '/patches/***' \
        --include '/mmotm/***' \
        --include '/next/***' \