From f9198124718b6962fac5d2bfc355da5802d83b7c Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Mon, 16 Sep 2024 10:39:27 +1000 Subject: [PATCH] do_merge: fix restarting when the next control line is switch or branch --- do_merge | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) 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 -- 2.39.5