ghmerge: Add --ref option to checkout given reference at first
authorDr. David von Oheimb <David.von.Oheimb@siemens.com>
Thu, 8 Oct 2020 07:43:00 +0000 (09:43 +0200)
committerPauli <paul.dale@oracle.com>
Mon, 16 Nov 2020 09:31:51 +0000 (19:31 +1000)
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/72)

review-tools/ghmerge

index 76db96a649731cbcbbba562b089aad8e5479cab9..cd1251f396a74dcf964726af72cd991a3e48918c 100755 (executable)
@@ -12,6 +12,7 @@ if [ "$REMOTE" = "" ] ; then
     echo Cannot find git remote with URL including 'git.openssl.org'
     exit 1
 fi
+REL=""
 
 if [ ! -d .git ] ; then
     echo Not at a top-level git directory
@@ -44,6 +45,13 @@ while true ; do
         fi
         shift; REMOTE=$1; shift
         ;;
+    --ref)
+        if [ $# -lt 2 ] ; then
+            echo "Missing argument of '$1'"
+            exit 1
+        fi
+        shift; REL=$1; shift
+        ;;
     --)
         shift
         break
@@ -88,11 +96,17 @@ if [ -z "$WHO" -o -z "$BRANCH" -o -z "$REPO" ]; then
     exit 1
 fi
 
-REL=`git rev-parse --abbrev-ref HEAD`
+if [ "$REL" = "" ]; then
+    REL=`git rev-parse --abbrev-ref HEAD` # usually will be 'HEAD' or e.g., OpenSSL_1_1_1-stable
+else
+    echo -n "Press Enter to checkout $REL: "; read foo
+    git checkout $REL
+fi
 WORK="${WHO}-${BRANCH}"
 
-echo -n "Press Enter to pull the latest branch '$REL' from $REMOTE: "; read foo
-git pull $REMOTE $REL
+
+echo -n "Press Enter to pull the latest $REMOTE/$REL: "; read foo
+git pull $REMOTE || (git rebase --abort; exit 1)
 
 function cleanup {
     rv=$?