From 1d8aa0d6e5e090fe35cde30dd5a2c46fdec95d80 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 3 Sep 2026 12:53:06 -0700 Subject: [PATCH] update-from-lore: enhance "afresh" mode $ update-from-lore $URL [topic [base]] With one or two args, require to be on a detached HEAD. With three args, the HEAD is detached to the third argument, base. The patch series named by $URL is applied there. Further, with two or three args, create the topic branch with the resulting commit. --- update-from-lore.sh | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/update-from-lore.sh b/update-from-lore.sh index 6b361c0b85..7842c6a87a 100755 --- a/update-from-lore.sh +++ b/update-from-lore.sh @@ -1,15 +1,38 @@ #!/bin/sh afresh () { - if git symbolic-ref -q HEAD + URL="${1?URL}" + shift + if test $# != 0 + then + branch="$1" + shift + fi + if test $# = 1 + then + git checkout --detach "$1" + shift + elif git symbolic-ref -q HEAD then echo >&2 "HEAD not detached" exit 1 fi - b4 am -o- -t "$1" | + + if test $# != 0 + then + echo >&2 "$0 URL topic-name [base]" + exit 1 + fi + + b4 am -o- -t "$URL" | tee ./+b4am.mbx | git am -s3 && rm -f ./+b4am.mbx + status=$? + if test $status = 0 && test -n "$branch" + then + git checkout -b "$branch" + fi exit $? } @@ -19,7 +42,7 @@ redo_or_afresh () { git checkout "$1" || exit return else - afresh "$1" + afresh "$@" return fi } @@ -39,9 +62,9 @@ do shift done -case "$#" in +case $# in 0) : happy ;; -1) redo_or_afresh "$1" ;; +1|2|3) redo_or_afresh "$@" ;; *) echo >&2 "$0: extra arguments" ;; esac