[tools] master update

tomas at openssl.org tomas at openssl.org
Mon Nov 22 13:55:14 UTC 2021


The branch master has been updated
       via  debabf50f5f2d7d0de575c69f8af642e9e84ae77 (commit)
       via  c728b5e389a29e30759acc1baa7dcf0d05b6f0d0 (commit)
       via  3bfc3b4bc4fbc9026afed38335f15b1b0cbbfd4c (commit)
       via  41d7c0e63bf92b762f0369f0a56e25dfc51b2061 (commit)
       via  9ce7e5fb4ed7546ba412d14422e4bf2713bc1440 (commit)
      from  b57692c1f0b653ba5e4cbb2ae581b6f9def2bb45 (commit)


- Log -----------------------------------------------------------------
commit debabf50f5f2d7d0de575c69f8af642e9e84ae77
Author: Dr. David von Oheimb <David.von.Oheimb at siemens.com>
Date:   Mon Nov 22 13:37:50 2021 +0100

    ghmerge: restore to original commit HEAD of target on error/abort
    
    Also add an empty line before the git log output for readability.
    
    Reviewed-by: Tomas Mraz <tomas at openssl.org>
    (Merged from https://github.com/openssl/tools/pull/97)

commit c728b5e389a29e30759acc1baa7dcf0d05b6f0d0
Author: Dr. David von Oheimb <David.von.Oheimb at siemens.com>
Date:   Mon Nov 22 12:52:44 2021 +0100

    ghmerge: correct assignment to WORK_USED
    
    Reviewed-by: Tomas Mraz <tomas at openssl.org>
    (Merged from https://github.com/openssl/tools/pull/97)

commit 3bfc3b4bc4fbc9026afed38335f15b1b0cbbfd4c
Author: Dr. David von Oheimb <David.von.Oheimb at siemens.com>
Date:   Mon Nov 22 12:31:18 2021 +0100

    ghmerge: Rename --ref to --target for clarity
    
    We are keeping --ref for backward compat.
    
    Reviewed-by: Tomas Mraz <tomas at openssl.org>
    (Merged from https://github.com/openssl/tools/pull/97)

commit 41d7c0e63bf92b762f0369f0a56e25dfc51b2061
Author: Dr. David von Oheimb <David.von.Oheimb at siemens.com>
Date:   Wed Nov 17 14:14:36 2021 +0100

    ghmerge: extend --cherry-pick with the number of commits to pick
    
    Reviewed-by: Paul Dale <pauli at openssl.org>
    Reviewed-by: Tomas Mraz <tomas at openssl.org>
    (Merged from https://github.com/openssl/tools/pull/97)

commit 9ce7e5fb4ed7546ba412d14422e4bf2713bc1440
Author: Dr. David von Oheimb <David.von.Oheimb at siemens.com>
Date:   Mon Oct 25 14:45:17 2021 +0200

    ghmerge: Fix behavior on failed cherry-pick, rebase, and pull
    
    Reviewed-by: Paul Dale <pauli at openssl.org>
    Reviewed-by: Tomas Mraz <tomas at openssl.org>
    (Merged from https://github.com/openssl/tools/pull/97)

-----------------------------------------------------------------------

Summary of changes:
 review-tools/ghmerge | 106 +++++++++++++++++++++++++++++++++------------------
 1 file changed, 68 insertions(+), 38 deletions(-)

diff --git a/review-tools/ghmerge b/review-tools/ghmerge
index 7d1fc25..1371bfb 100755
--- a/review-tools/ghmerge
+++ b/review-tools/ghmerge
@@ -11,8 +11,9 @@ Option style arguments:
 --tools             Merge a tools PR (rather than openssl PR)
 --web               Merge a web PR (rather than openssl PR)
 --remote <remote>   Repo to merge with (rather than git.openssl.org), usually 'upstream'
---ref <branch>      Branch to merge with (rather than current branch), usually 'master'
---cherry-pick       Use cherry-pick (rather than pull --rebase)
+--target <branch>   Merge target (rather than current branch), usually 'master'
+--ref <branch>      A synonym for --target
+--cherry-pick [<n>] Cherry-pick the last n (1 <= n <= 99, default: 1) commits, rather than rebasing
 --squash            Squash new commits non-interactively (allows editing msg)
 --noautosquash      Do not automatically squash fixups in interactive rebase
 --nobuild           Do not call 'openssbuild' before merging
@@ -22,7 +23,8 @@ Examples:
   ghmerge 12345 mattcaswell
   ghmerge 12345 paulidale t8m --nobuild --myemail=dev at ddvo.net
   ghmerge edd05b7^^^^..19692bb2c32 --squash -- 12345 levitte
-  ghmerge 12345 slontis --ref openssl-3.0"
+  ghmerge 12345 slontis --target openssl-3.0
+  ghmerge --nobuild --target openssl-3.0 --cherry-pick 3 16051 paulidale"
     exit 9
 }
 
@@ -33,7 +35,7 @@ PICK=no
 INTERACTIVE=yes
 AUTOSQUASH="--autosquash"
 REMOTE=""
-REF=""
+TARGET=""
 BUILD=yes
 [ -z ${CC+x} ] && CC="ccache gcc" # opensslbuild will otherwise use "ccache clang-3.6"
 
@@ -59,7 +61,11 @@ while [ $# -ne 0 ]; do
         WHAT=web ; BUILD=no ; shift
         ;;
     --cherry-pick)
-        PICK=yes ; shift
+        shift;
+        PICK=1;
+        if [ "$1" != "" ] && [ $1 -ge 1 ] 2>/dev/null && [ $1 -le 99 ]; then
+            PICK=$1 ; shift
+        fi
         ;;
     --noautosquash)
         AUTOSQUASH="" ; shift
@@ -77,12 +83,12 @@ while [ $# -ne 0 ]; do
         fi
         shift; REMOTE=$1; shift
         ;;
-    --ref)
+    --target|--ref)
         if [ $# -lt 2 ] ; then
             echo "Missing argument of '$1'"
             usage_exit
         fi
-        shift; REF=$1; shift
+        shift; TARGET=$1; shift
         ;;
     --)
         if [ $# -lt 3 ] ; then
@@ -165,7 +171,18 @@ function cleanup {
     rv=$?
     echo # make sure to enter new line, needed, e.g., after Ctrl-C
     [ $rv -ne 0 ] && echo -e "\nghmerge failed"
-    if [ "$REF" != "$ORIG_REF" ] || [ "$WORK_USED" != "" ]; then
+    if [ "$REBASING" == 1 ] ; then
+        git rebase --abort 2>/dev/null || true
+    fi
+    if [ "$CHERRYPICKING" == 1 ] ; then
+        echo "Hint: maybe --cherry-pick was not given a suitable <n> parameter."
+        git cherry-pick --abort 2>/dev/null || true
+    fi
+    if [ "$ORIG_TARGET_HEAD" != "" ]; then
+        echo Restoring original commit HEAD of $TARGET
+        git reset --hard "$ORIG_TARGET_HEAD"
+    fi
+    if [ "$TARGET" != "$ORIG_REF" ] || [ "$WORK_USED" != "" ]; then
         echo Returning to previous branch $ORIG_REF
         git checkout -q $ORIG_REF
     fi
@@ -173,61 +190,73 @@ function cleanup {
         git branch -qD $WORK_USED
     fi
     if [ "$STASH_OUT" != "No local changes to save" ]; then
-        git stash pop -q # restore original state, pruning any leftover commits added locally
+        git stash pop -q # restore original state of $ORIG_REF, pruning any leftover commits added locally
     fi
 }
 trap 'cleanup' EXIT
 
-[ "$REF" = "" ] && REF=$ORIG_REF
-if [ "$REF" != "$ORIG_REF" ]; then    
-    echo -n "Press Enter to checkout $REF: "; read foo
-    git checkout $REF
+[ "$TARGET" = "" ] && TARGET=$ORIG_REF
+if [ "$TARGET" != "$ORIG_REF" ]; then
+    echo -n "Press Enter to checkout $TARGET: "; read foo
+    git checkout $TARGET
 fi
 
-echo -n "Press Enter to pull the latest $REMOTE/$REF: "; read foo
-git pull $REMOTE $REF || (git rebase --abort; exit 1)
+echo -n "Press Enter to pull the latest $REMOTE/$TARGET: "; read foo
+REBASING=1
+git pull $REMOTE $TARGET || exit 1
+REBASING=
 
-WORK_USED=$WORK
 # append new commits from $REPO/$BRANCH
-if [ "$PICK" != "yes" ]; then
-    echo Rebasing $REPO/$BRANCH on $REF...
+if [ "$PICK" == "no" ]; then
+    echo Rebasing $REPO/$BRANCH on $TARGET...
     git fetch $REPO $BRANCH && git checkout -b $WORK FETCH_HEAD
     WORK_USED=$WORK
-    git rebase $REF || (echo 'Fix or Ctrl-d to abort' ; read || (git rebase --abort; exit 1))
+    REBASING=1
+    git rebase $TARGET || (echo 'Fix or Ctrl-d to abort' ; read || exit 1)
+    REBASING=
 else
-    echo Cherry-picking $REPO/$BRANCH to $REF...
-    git checkout -b $WORK $REF
+    echo Cherry-picking $REPO/$BRANCH to $TARGET...
+    git checkout -b $WORK $TARGET
     WORK_USED=$WORK
-    git fetch $REPO $BRANCH && git cherry-pick FETCH_HEAD
+    CHERRYPICKING=1
+    git fetch $REPO $BRANCH && (git cherry-pick FETCH_HEAD~$PICK..FETCH_HEAD || exit 1)
+    CHERRYPICKING=
 fi
 
-echo Diff against $REMOTE/$REF
-git diff $REMOTE/$REF
+echo Diff against $REMOTE/$TARGET
+git diff $REMOTE/$TARGET
 
 if [ "$INTERACTIVE" == "yes" ] ; then
-    echo -n "Press Enter to interactively rebase $AUTOSQUASH on $REMOTE/$REF: "; read foo
-    git rebase -i $AUTOSQUASH $REMOTE/$REF || (git rebase --abort; exit 1)
-    echo "Calling addrev $ADDREVOPTS --prnum=$PRNUM $TEAM $REMOTE/$REF.."
-    addrev $ADDREVOPTS --prnum=$PRNUM $TEAM $REMOTE/$REF..
+    echo -n "Press Enter to interactively rebase $AUTOSQUASH on $REMOTE/$TARGET: "; read foo
+    REBASING=1
+    git rebase -i $AUTOSQUASH $REMOTE/$TARGET || exit 1
+    REBASING=
+    echo "Calling addrev $ADDREVOPTS --prnum=$PRNUM $TEAM $REMOTE/$TARGET.."
+    addrev $ADDREVOPTS --prnum=$PRNUM $TEAM $REMOTE/$TARGET..
 fi
 
-echo Log since $REMOTE/$REF
-git log $REMOTE/$REF..
+echo
+echo Log since $REMOTE/$TARGET
+git log $REMOTE/$TARGET..
 
-git checkout $REF
+git checkout $TARGET
 if [ "$INTERACTIVE" != "yes" ] ; then
-    echo -n "Press Enter to non-interactively merge --squash $BRANCH to $REMOTE/$REF: "; read foo
+    echo -n "Press Enter to non-interactively merge --squash $BRANCH to $REMOTE/$TARGET: "; read foo
+    ORIG_TARGET_HEAD=`git show -s --format="%H"`
     git merge --ff-only --no-commit --squash $WORK
     AUTHOR=`git show --no-patch --pretty="format:%an <%ae>" $WORK`
     git commit --author="$AUTHOR"
-    addrev $ADDREVOPTS --prnum=$PRNUM $TEAM $REMOTE/${REF}..
+    addrev $ADDREVOPTS --prnum=$PRNUM $TEAM $REMOTE/${TARGET}..
 else
-    # echo -n "Press Enter to merge to $REMOTE/$REF: "; read foo
+    # echo -n "Press Enter to merge to $TARGET: "; read foo
+    echo
+    echo "Merging to $TARGET"
+    ORIG_TARGET_HEAD=`git show -s --format="%H"`
     git merge --ff-only $WORK
 fi
 
-echo New log since $REMOTE/$REF
-git log $REMOTE/$REF..
+echo New log since $REMOTE/$TARGET
+git log $REMOTE/$TARGET..
 
 if [ "$BUILD" == "yes" ] ; then
     echo Rebuilding...
@@ -235,7 +264,7 @@ if [ "$BUILD" == "yes" ] ; then
 fi
 
 while true ; do
-    echo -n "Enter 'y'/'yes' to push to $REMOTE/$REF or 'n'/'no' to abort: "
+    echo -n "Enter 'y'/'yes' to push to $REMOTE/$TARGET or 'n'/'no' to abort: "
     read x
     x="`echo $x | tr A-Z a-z`"
     if [ "$x" = "y" -o "$x" = "yes" -o "$x" = "n" -o "$x" = "no" ] ; then
@@ -244,5 +273,6 @@ while true ; do
 done
 
 if [ "$x" = "y" -o "$x" = "yes" ] ; then
-    git push -v $REMOTE $REF
+    git push -v $REMOTE $TARGET
+    ORIG_TARGET_HEAD=
 fi


More information about the openssl-commits mailing list