]> git.ozlabs.org Git - next-scripts/commitdiff
do_merge: make merging a tree an explicit operation
authorStephen Rothwell <sfr@canb.auug.org.au>
Wed, 18 Sep 2024 03:28:21 +0000 (13:28 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 18 Sep 2024 03:28:21 +0000 (13:28 +1000)
do_merge

index 3ab889192b87fe6581efe119b83364575d72544f..96310aa3338177a1371287e114f96a5104cc5fb3 100755 (executable)
--- a/do_merge
+++ b/do_merge
@@ -69,37 +69,39 @@ fi
 
 heads=$(awk -F '\t' '
        /^#/ { next; }
-       $2=="git" { printf("%s/%s ", $3, $5); }
+       $2=="git" { printf("git/%s/%s ", $3, $5); }
        $2=="branch" { printf("branch/%s ", $1); }
        $2=="switch" { printf("switch/%s/%s ", $3, $4); }' "$CTRL_FILE")
 
 need_build=false
 
 for h in $heads; do
-       tree=${h%%/*}
-       branch=${h#"$tree"/}
+       op=${h%%/*}
+       args=${h#*/}
+       arg1=${args%%/*}
+       arg2=${args#*/}
 
        if [ -n "$previous_tree" ]; then
-               if [ "$tree" = "$previous_tree" ]; then
+               if [ "$op" = 'git' ] && [ "$arg1" = "$previous_tree" ]; then
                        previous_tree=''
                fi
                continue
        elif [ -n "$start_from" ]; then
-               if [ "$tree" = "$start_from" ]; then
+               if [ "$op" = 'git' ] && [ "$arg1" = "$start_from" ]; then
                        start_from=""
                else
                        continue
                fi
        fi
 
-       if [ "$tree" = "branch" ]; then
-               git branch -f "$branch"
-               linux-next-notify "update branch $branch"
+       if [ "$op" = "branch" ]; then
+               git branch -f "$arg1"
+               linux-next-notify "update branch $arg1"
                continue
        fi
 
-       if [ "$tree" = 'switch' ]; then
-               new_branch=${branch%%/*}
+       if [ "$op" = 'switch' ]; then
+               new_branch=$arg1
                if [ "$new_branch" = 'master' ]; then
                        old_branch=$(git branch --show-current)
                        if ! [ "$old_branch" = 'master' ]; then
@@ -108,7 +110,7 @@ for h in $heads; do
                                fi
                        fi
                else
-                       base=${branch#"$new_branch"/}
+                       base=$arg2
                        if ! git checkout -B "$new_branch" "$base"; then
                                fix_up "git checkout $new_branch failed"
                        fi
@@ -116,7 +118,11 @@ for h in $heads; do
                continue
        fi
 
-       h=${h%/}
+# $op == "git"
+
+       tree=$arg1
+       branch=$arg2
+       h="$tree${branch:+/$branch}"
        hlog=$(git log -1 --oneline "$h") 2>/dev/null
        old_head=$(git rev-parse HEAD)
        if [ -f "../pre-merge/$tree" ]; then
@@ -128,7 +134,7 @@ for h in $heads; do
        fi
        log Merging "$h" "($hlog)"
        check_dups "$tree" HEAD "$h" | tee -a "$LOG_FILE"
-       msg=$(printf "Merge branch '%s' of %s" "${h#*/}" "$(get_url "$tree")")
+       msg=$(printf "Merge branch '%s' of %s" "$branch" "$(get_url "$tree")")
        if ! execute git merge -m "$msg" "$h"; then
                echo Merge failed 1>&2
                echo "$h" >>../merge.debug