[tools] master update

tomas at openssl.org tomas at openssl.org
Mon Nov 1 13:02:42 UTC 2021


The branch master has been updated
       via  3189d5753970fa290365b02acb535ea5ef09e995 (commit)
       via  485aa62c661197601a7648a9c6bc7b8350270bb6 (commit)
       via  670fbf0eec6cbca664de2ec5e17208499bf99ca2 (commit)
      from  f6070cac86caad71cde3b62cd3fd0e35c724eae3 (commit)


- Log -----------------------------------------------------------------
commit 3189d5753970fa290365b02acb535ea5ef09e995
Author: Dr. David von Oheimb <David.von.Oheimb at siemens.com>
Date:   Thu Oct 7 16:00:40 2021 +0200

    ghmerge: Avoid checking out ref branch if not needed
    
    Reviewed-by: Paul Dale <pauli at openssl.org>
    Reviewed-by: Tomas Mraz <tomas at openssl.org>
    (Merged from https://github.com/openssl/tools/pull/94)

commit 485aa62c661197601a7648a9c6bc7b8350270bb6
Author: Dr. David von Oheimb <David.von.Oheimb at siemens.com>
Date:   Thu Oct 7 15:54:44 2021 +0200

    ghmerge: Improve robustness and clarity regarding which ref branch is used
    
    Reviewed-by: Paul Dale <pauli at openssl.org>
    Reviewed-by: Tomas Mraz <tomas at openssl.org>
    (Merged from https://github.com/openssl/tools/pull/94)

commit 670fbf0eec6cbca664de2ec5e17208499bf99ca2
Author: Dr. David von Oheimb <David.von.Oheimb at siemens.com>
Date:   Thu Oct 7 15:43:21 2021 +0200

    ghmerge: Correct saving and restoring original state
    
    Also properly catch the error that copy-of-... already exists
    
    Reviewed-by: Paul Dale <pauli at openssl.org>
    Reviewed-by: Tomas Mraz <tomas at openssl.org>
    (Merged from https://github.com/openssl/tools/pull/94)

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

Summary of changes:
 review-tools/ghmerge | 64 ++++++++++++++++++++++++++++++----------------------
 1 file changed, 37 insertions(+), 27 deletions(-)

diff --git a/review-tools/ghmerge b/review-tools/ghmerge
index 7f0746e..7d1fc25 100755
--- a/review-tools/ghmerge
+++ b/review-tools/ghmerge
@@ -22,7 +22,7 @@ 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_1_1_1-stable"
+  ghmerge 12345 slontis --ref openssl-3.0"
     exit 9
 }
 
@@ -155,64 +155,74 @@ if [ -z "$WHO" -o -z "$BRANCH" -o -z "$REPO" ]; then
     exit 1
 fi
 
-if [ "$REF" = "" ]; then
-    REF=`git rev-parse --abbrev-ref HEAD` # usually this will be 'master' or, e.g., 'OpenSSL_1_1_1-stable'
-else
-    echo -n "Press Enter to checkout $REF: "; read foo
-    git checkout $REF
-fi
-
-echo -n "Press Enter to pull the latest $REMOTE/$REF: "; read foo
-git pull $REMOTE $REF || (git rebase --abort; exit 1)
-
+ORIG_REF=`git rev-parse --abbrev-ref HEAD` # usually this will be 'master'
+STASH_OUT=`git stash`
 WORK="copy-of-${WHO}-${BRANCH}"
 
+(git branch | grep -q "$WORK") && (echo "Branch already exists: $WORK"; exit 1)
+
 function cleanup {
     rv=$?
-    echo # new line
+    echo # make sure to enter new line, needed, e.g., after Ctrl-C
     [ $rv -ne 0 ] && echo -e "\nghmerge failed"
-    if [ "$WORK" != "$REF" ]; then
-        echo Restoring local $REF
-        git checkout -q $REF
-        git branch -qD $WORK 2>/dev/null
+    if [ "$REF" != "$ORIG_REF" ] || [ "$WORK_USED" != "" ]; then
+        echo Returning to previous branch $ORIG_REF
+        git checkout -q $ORIG_REF
+    fi
+    if [ "$WORK_USED" != "" ]; then
+        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
     fi
-    git reset --hard $REMOTE/$REF # prune any leftover commits added locally
 }
 trap 'cleanup' EXIT
 
+[ "$REF" = "" ] && REF=$ORIG_REF
+if [ "$REF" != "$ORIG_REF" ]; then    
+    echo -n "Press Enter to checkout $REF: "; read foo
+    git checkout $REF
+fi
+
+echo -n "Press Enter to pull the latest $REMOTE/$REF: "; read foo
+git pull $REMOTE $REF || (git rebase --abort; exit 1)
+
+WORK_USED=$WORK
 # append new commits from $REPO/$BRANCH
 if [ "$PICK" != "yes" ]; then
     echo Rebasing $REPO/$BRANCH on $REF...
     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))
 else
     echo Cherry-picking $REPO/$BRANCH to $REF...
     git checkout -b $WORK $REF
+    WORK_USED=$WORK
     git fetch $REPO $BRANCH && git cherry-pick FETCH_HEAD
 fi
 
-echo Diff against $REF
-git diff $REF
+echo Diff against $REMOTE/$REF
+git diff $REMOTE/$REF
 
 if [ "$INTERACTIVE" == "yes" ] ; then
-    echo -n "Press Enter to interactively rebase $AUTOSQUASH on $REF: "; read foo
-    git rebase -i $AUTOSQUASH $REF || (git rebase --abort; exit 1)
-    echo "Calling addrev $ADDREVOPTS --prnum=$PRNUM $TEAM ${REF}.."
-    addrev $ADDREVOPTS --prnum=$PRNUM $TEAM ${REF}..
+    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..
 fi
 
-echo Log since $REF
-git log $REF..
+echo Log since $REMOTE/$REF
+git log $REMOTE/$REF..
 
 git checkout $REF
 if [ "$INTERACTIVE" != "yes" ] ; then
-    echo -n "Press Enter to non-interactively merge --squash $BRANCH to $REF: "; read foo
+    echo -n "Press Enter to non-interactively merge --squash $BRANCH to $REMOTE/$REF: "; read foo
     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}..
 else
-    # echo -n "Press Enter to merge to $REF: "; read foo
+    # echo -n "Press Enter to merge to $REMOTE/$REF: "; read foo
     git merge --ff-only $WORK
 fi
 


More information about the openssl-commits mailing list