From: Stephen Rothwell Date: Mon, 16 Sep 2024 00:39:27 +0000 (+1000) Subject: do_merge: fix restarting when the next control line is switch or branch X-Git-Url: https://git.ozlabs.org/?a=commitdiff_plain;h=f9198124718b6962fac5d2bfc355da5802d83b7c;p=next-scripts do_merge: fix restarting when the next control line is switch or branch --- diff --git a/do_merge b/do_merge index 3a2e45d..3ab8891 100755 --- 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