From efc19c85ebda28b90c369a7a6132a0093dfe5e02 Mon Sep 17 00:00:00 2001 From: Christian Stimming Date: Sat, 31 Jan 2009 10:24:34 +0000 Subject: [PATCH] Add shell script to easily back-port commits in git-svn from trunk to other branches. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@17856 57a11ea4-9604-0410-9ed3-97b8803252fd --- util/git-backport.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 util/git-backport.sh diff --git a/util/git-backport.sh b/util/git-backport.sh new file mode 100755 index 0000000000..5c65ec9cbd --- /dev/null +++ b/util/git-backport.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +REV=$1 +: ${ORIGBRANCH=trunk} +: ${WHOAMI=`whoami`} + +TMPFILE=tmplog.tmp +#TMPFILE2=tmplog2.tmp + +# Cherry-pick the other commit +ORIGID=`git svn find-rev r${REV} ${ORIGBRANCH}` +if [ -z "${ORIGID}" ] ; then + echo "Revision ${REV} not found in branch ${ORIGBRANCH}" + exit 1 +fi +git cherry-pick ${ORIGID} + +# Create new log message by modifying the old one +git log --pretty=format:"[$REV] %s%n%n%b" HEAD^..HEAD \ + | grep -v '^BP$' | grep -v 'git-svn-id:' > ${TMPFILE} +OTHERAUTHOR=`git log --pretty=format:"%an" HEAD^..HEAD` +if [ "${WHOAMI}" != "${OTHERAUTHOR}" ]; then + echo -e "\nOriginal commit by ${OTHERAUTHOR}." >> ${TMPFILE} +fi + +# Commit new log message +git commit --amend -F ${TMPFILE} + +# Clean up temporary files +rm -f ${TMPFILE}