]> git.ozlabs.org Git - next-scripts/commitdiff
make the dup checking more realistic master
authorStephen Rothwell <sfr@canb.auug.org.au>
Mon, 21 Jul 2025 22:00:45 +0000 (08:00 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Mon, 21 Jul 2025 22:00:45 +0000 (08:00 +1000)
remove dups we have already seen in earlier trees

check_dups.sh
common.sh

index 85e716e40dd299fbd422f1da1e390997e8763491..ac1cb35b2f351c5104069b39e413fd4b00825453 100644 (file)
@@ -1,21 +1,20 @@
 #
-# shared check_dups funciont
+# shared check_dups funcion
 #
 
 check_dups()
 {
        # "In POSIX sh, 'local' is undefined."
        # shellcheck disable=SC3043
-       local name base sha dfile
+       local name base sha dfile o ol oh
 
        name="$1"
        base="$2"
        sha="$3"
-       dlfile="$top_dir/duplicates/linus/$name"
        if [ "$base" = "HEAD" ]; then
                dfile="$top_dir/duplicates/next/$name"
        else
-               dfile="$dlfile"
+               dfile="$top_dir/duplicates/linus/$name"
        fi
 
        # if there is anything in this tree, then check for duplicates
@@ -26,8 +25,34 @@ check_dups()
 
        dups=$(git cherry "$base" "$sha" | sed -n 's/^- //p' |
                xargs -r -n 1 "$tools_dir"/clog | sort)
-       if [ "$base" = "HEAD" ] && [ -f "$dlfile" ]; then
-               dups=$(printf '%s\n' "$dups" | comm -23 - "$dlfile")
+
+       if ! [ -z "$dups" ]; then
+               for o in $(get_branches "$name"); do
+                       ol="$top_dir/duplicates/linus/$o"
+                       if [ -f "$ol" ]; then
+                               dups=$(printf '%s\n' "$dups" | comm -23 - "$ol")
+                       fi
+                       if [ -z "$dups" ]; then
+                               break
+                       fi
+                       if ! [ "$base" = "HEAD" ]; then
+                               continue
+                       fi
+                       ol="$top_dir/duplicates/linus/$name"
+                       if [ -f "$ol" ]; then
+                               dups=$(printf '%s\n' "$dups" | comm -23 - "$ol")
+                       fi
+                       if [ -z "$dups" ]; then
+                               break
+                       fi
+                       oh="$top_dir/duplicates/next/$o"
+                       if [ -f "$oh" ]; then
+                               dups=$(printf '%s\n' "$dups" | comm -23 - "$oh")
+                       fi
+                       if [ -z "$dups" ]; then
+                               break
+                       fi
+               done
        fi
        if [ -z "$dups" ]; then
                rm -f "$dfile"
index 272d2690a4add9521564f9c9d909c1a550aeab02..e35290157feb32e41c56e93885db67c7bca325f7 100644 (file)
--- a/common.sh
+++ b/common.sh
@@ -82,7 +82,7 @@ get_control_field()
 
 get_branches()
 {
-       awk -F "$_TAB" '/^[^-#]/ && $2=="git"{ print $3; }' "$CTRL_FILE"
+       awk -F "$_TAB" -v stop="$1" '/^[^-#]/ && $2=="git" { if ($3==stop) { exit 0 }; print $3 }' "$CTRL_FILE"
 }
 
 get_pending_branches()