2 #===-- merge-git.sh - Merge commit to the stable branch --------------------===#
4 # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 # See https://llvm.org/LICENSE.txt for license information.
6 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 #===------------------------------------------------------------------------===#
10 # This script will merge an svn revision to a git repo using git-svn while
11 # preserving the svn commit message.
13 # NOTE: This script has only been tested with the per-project git repositories
14 # and not with the monorepo.
16 # In order to use this script, you must:
17 # 1) Checkout the stable branch you would like to merge the revision into.
18 # 2) Correctly configure the branch as an svn-remote by adding the following to
19 # your .git/config file for your git repo (replace xy with the major/minor
20 # version of the release branch. e.g. release_50 or release_60):
22 #[svn-remote "release_xy"]
23 #url = https://llvm.org/svn/llvm-project/llvm/branches/release_xy
24 #fetch = :refs/remotes/origin/release_xy
26 # Once the script completes successfully, you can push your changes with
29 #===------------------------------------------------------------------------===#
33 echo "usage: `basename $0` [OPTIONS]"
34 echo " -rev NUM The revision to merge into the project"
37 while [ $# -gt 0 ]; do
47 echo "unknown option: $1"
56 if [ -z "$rev" ]; then
57 echo "error: need to specify a revision"
63 # Rebuild revision map
64 git svn find-rev r
$rev origin
/master
&>/dev
/null
66 git_hash
=`git svn find-rev r$rev origin/master`
68 if [ -z "$git_hash" ]; then
69 echo "error: could not determine git commit for r$rev"
73 commit_msg
=`svn log -r $rev https://llvm.org/svn/llvm-project/`
76 git cherry-pick
$git_hash
79 echo "** cherry-pick failed enter 'e' to exit or 'c' when you have finished resolving the conflicts:"
91 git commit
$ammend -m "Merging r$rev:" -m "$commit_msg"