[PATCH] D47760: utils/release: Add merge-git.sh

Tom Stellard via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 4 21:45:14 PDT 2018


tstellar created this revision.
tstellar added a reviewer: hansw.

This script allows you to use git to backport a commit to a stable
branch while generating the exact same commit message (ignoring
whitespace) that you would get from using the merge.sh script with svn.


Repository:
  rL LLVM

https://reviews.llvm.org/D47760

Files:
  utils/release/merge-git.sh


Index: utils/release/merge-git.sh
===================================================================
--- /dev/null
+++ utils/release/merge-git.sh
@@ -0,0 +1,94 @@
+#!/bin/bash
+#===-- merge-git.sh - Test the LLVM release candidates ---------------------===#
+#
+#                     The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License.
+#
+#===------------------------------------------------------------------------===#
+#
+# Merge a revision into a project.
+#
+#===------------------------------------------------------------------------===#
+
+
+usage() {
+    echo "usage: `basename $0` [OPTIONS]"
+    echo "  -proj PROJECT  The project to merge the result into"
+    echo "  -rev NUM       The revision to merge into the project"
+    echo "  -revert        Revert rather than merge the commit"
+    echo "  -srcdir        The root of the project checkout"
+}
+
+while [ $# -gt 0 ]; do
+    case $1 in
+        -rev | --rev | -r )
+            shift
+            rev=$1
+            ;;
+        -proj | --proj | -project | --project | -p )
+            shift
+            proj=$1
+            ;;
+        --srcdir | -srcdir | -s)
+            shift
+            srcdir=$1
+            ;;
+        -h | -help | --help )
+            usage
+            ;;
+        -revert | --revert )
+            revert="yes"
+            ;;
+        * )
+            echo "unknown option: $1"
+            echo ""
+            usage
+            exit 1
+            ;;
+    esac
+    shift
+done
+
+if [ "x$rev" = "x" -o "x$proj" = "x" ]; then
+    echo "error: need to specify project and revision"
+    echo
+    usage
+    exit 1
+fi
+
+if ! svn ls http://llvm.org/svn/llvm-project/$proj/trunk > /dev/null 2>&1 ; then
+    echo "error: invalid project: $proj"
+    exit 1
+fi
+
+# Rebuild revision map
+git_hash=`git svn find-rev r$rev origin/master` &>/dev/null
+
+git_hash=`git svn find-rev r$rev origin/master`
+
+if [ -z "$git_hash" ]; then
+    echo "error: could not determine git commit for r$rev"
+    exit 1
+fi
+
+commit_msg=`svn log -r $rev https://llvm.org/svn/llvm-project/`
+ammend="--amend"
+
+git cherry-pick $git_hash
+if [ $? -ne 0 ]; then
+  echo ""
+  echo "** cherry-pick failed enter 'e' to exit or 'c' when you have finished resolving the conflicts:"
+  read option
+  case $option in
+    c)
+      ammend=""
+      ;;
+    *)
+      exit 1
+      ;;
+  esac
+fi
+         
+git commit $ammend -m "Merging r$rev:" -m "$commit_msg"


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47760.149905.patch
Type: text/x-patch
Size: 2520 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180605/217059f4/attachment.bin>


More information about the llvm-commits mailing list