pick-to-branch: Improve fix of behavior on failed cherry-pick
authorDr. David von Oheimb <David.von.Oheimb@siemens.com>
Wed, 17 Nov 2021 13:38:19 +0000 (14:38 +0100)
committerDr. David von Oheimb <David.von.Oheimb@siemens.com>
Mon, 22 Nov 2021 14:12:23 +0000 (15:12 +0100)
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/tools/pull/99)

review-tools/pick-to-branch

index 18a25e56db78a4adbb22b8e0cdf39f91c16b491e..ac4176a9c1a2b56549fda1b7f8e07a8577ce0885 100755 (executable)
@@ -84,6 +84,9 @@ function cleanup {
     rv=$?
     echo # make sure to enter new line, needed, e.g., after Ctrl-C
     [ $rv -ne 0 ] && echo -e "pick-to-branch failed"
+    if [ "$CHERRYPICKING" == 1 ] ; then
+        git cherry-pick --abort 2>/dev/null || true
+    fi
     if [ "$branch" != "$ORIG_REF" ]; then
         echo Returning to previous branch $ORIG_REF
         git checkout -q $ORIG_REF
@@ -98,7 +101,9 @@ trap 'cleanup' EXIT
 git checkout --quiet master
 git checkout $branch
 git pull --ff-only
+CHERRYPICKING=1
 git cherry-pick -e -x $id || (git cherry-pick --abort; exit 1)
+CHERRYPICKING=
 
 while true
 do