]> git.ozlabs.org Git - next-scripts/commitdiff
do_merge: fix restarting when the next control line is switch or branch
authorStephen Rothwell <sfr@canb.auug.org.au>
Mon, 16 Sep 2024 00:39:27 +0000 (10:39 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Mon, 16 Sep 2024 00:39:27 +0000 (10:39 +1000)
do_merge

index 3a2e45d566933929b8546d052a9411e93a9a720b..3ab889192b87fe6581efe119b83364575d72544f 100755 (executable)
--- a/do_merge
+++ b/do_merge
@@ -9,6 +9,10 @@ while getopts 'ns:' opt; do
                no_build=true
                ;;
        s)
+               if [ -f "$SHA1_FILE" ]; then
+                       printf '%s: %s exists, so -s is invalid\n' "$0" "$SHA1_FILE" 1>&2
+                       exit 1
+               fi
                start_from="$OPTARG"
                ;;
        *)
@@ -54,14 +58,8 @@ fix_up()
 }
 
 if [ -f "$SHA1_FILE" ]; then
-       last=$(tail -n1 "$SHA1_FILE" | cut -f1 -d"$_TAB")
-       start_from=$(get_branches | sed -n '/^'"$last"'$/{n;p;}')
-       if [ -z "$start_from" ]; then
-               printf '%s: %s exists but cannot find next tree\n' "$0" "$SHA1_FILE" 1>&2
-               exit 1
-       fi
-fi
-if [ -z "$start_from" ]; then
+       previous_tree=$(tail -n1 "$SHA1_FILE" | cut -f1 -d"$_TAB")
+elif [ -z "$start_from" ]; then
        cp /dev/null "$LOG_FILE"
        execute date -R
        execute git checkout master
@@ -81,7 +79,12 @@ for h in $heads; do
        tree=${h%%/*}
        branch=${h#"$tree"/}
 
-       if [ -n "$start_from" ]; then
+       if [ -n "$previous_tree" ]; then
+               if [ "$tree" = "$previous_tree" ]; then
+                       previous_tree=''
+               fi
+               continue
+       elif [ -n "$start_from" ]; then
                if [ "$tree" = "$start_from" ]; then
                        start_from=""
                else