diff --git a/tools/tools/git/git-arc.sh b/tools/tools/git/git-arc.sh --- a/tools/tools/git/git-arc.sh +++ b/tools/tools/git/git-arc.sh @@ -59,7 +59,7 @@ Commands: create [-l] [-r [,...]] [-s subscriber[,...]] [|] list | - patch [-c] [ ...] + patch [-bc] [ ...] stage [-b branch] [|] update [-l] [-m message] [|] @@ -75,8 +75,11 @@ create -- Create new Differential revisions from the specified commits. list -- Print the associated Differential revisions for the specified commits. - patch -- Try to apply a patch from a Differential revision to the - currently checked out tree. + patch -- Try to apply a patch from one or more Differential revisions. + By default, the patch is applied to the currently checked-out + tree unless the -b option is supplied. With -b, a new branch is + created for each revision. The -c option commits the applied + patch using the review's metadata. stage -- Prepare a series of commits to be pushed to the upstream FreeBSD repository. The commits are cherry-picked to a branch (main by default), review tags are added to the commit log message, and @@ -146,6 +149,11 @@ $ git arc patch -c D12345 + Apply the patch in review D12345 to a new branch, and commit it using the + review's title, summary and author. + + $ git arc patch -bc D12345 + List the status of reviews for all the commits in the branch "feature": $ git arc list main..feature @@ -626,15 +634,20 @@ gitarc__patch() { - local rev commit + local rev commit nobranch if [ $# -eq 0 ]; then err_usage fi + nobranch="--nobranch" commit=false - while getopts c o; do + while getopts bc o; do case "$o" in + b) + require_clean_work_tree "patch -b" + nobranch="" + ;; c) require_clean_work_tree "patch -c" commit=true @@ -647,9 +660,10 @@ shift $((OPTIND-1)) for rev in "$@"; do - arc patch --skip-dependencies --nocommit --nobranch --force "$rev" + if ! arc patch --skip-dependencies ${nobranch:+$nobranch} --nocommit --force "$rev"; then + break + fi echo "Applying ${rev}..." - [ $? -eq 0 ] || break if ${commit}; then patch_commit $rev fi