summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Georgi <pgeorgi@google.com>2015-04-03 17:06:48 -0700
committerStefan Reinauer <stefan.reinauer@coreboot.org>2015-04-10 09:01:30 +0200
commit1707a164c9c3d92c0fbbc25efcc392420cc5d1e6 (patch)
treea00b6479db434557c0a9ce9083dfd3d27864c0ef
parent120aec0902663d2ed942c1542217791c46b8e406 (diff)
downloadcoreboot-1707a164c9c3d92c0fbbc25efcc392420cc5d1e6.tar.xz
git: add rebase helper script
This is a script we have been using to rewrite commit messages when upstreaming coreboot patches from the Chromium OS tree into coreboot upstream. Change-Id: I5442279c099dafe55cc97ccf09ee2bc2df4eca5f Signed-off-by: Stefan Reinauer <stefan.reinauer@coreboot.org> Signed-off-by: Patrick Georgi <patrick@georgi-clan.de> Reviewed-on: http://review.coreboot.org/9299 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi <pgeorgi@google.com>
-rwxr-xr-xutil/gitconfig/rebase.sh47
1 files changed, 47 insertions, 0 deletions
diff --git a/util/gitconfig/rebase.sh b/util/gitconfig/rebase.sh
new file mode 100755
index 0000000000..4bc32a4cde
--- /dev/null
+++ b/util/gitconfig/rebase.sh
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+# rebase.sh - rebase helper script
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+
+# Adapt to your remote branch:
+BRANCH="cros/chromeos-2013.04"
+
+# When pulling in patches from another tree from a gerrit repository,
+# do the following at the end of a larger cherry-pick series:
+# git remote add ...
+# git checkout -b upstreaming
+# git cherry-pick ...
+# git rebase -i --exec util/gitconfig/rebase.sh master
+# Alternatively, you can run util/gitconfig/rebase.sh after every
+# individual cherry-pick.
+
+commit_message() {
+ git log -n 1 | grep "^ " | cut -c5-
+}
+
+CHID=$( commit_message | grep -i "^Change-Id: I" )
+CID=$( git log -n1 --grep "^$CHID$" --pretty=%H $BRANCH )
+GUID="$(git config user.name) <$(git config user.email)>"
+
+# TBD: Don't add Original- to empty lines, and possibly make script more
+# solid for commits with an unexpected order of meta data lines.
+
+commit_message | tac | awk '/^$/ {
+ if (end==0)
+ print "Original-Commit-Id: '"$CID"'\nSigned-off-by: '"$GUID"'";
+ end=1
+ }; {
+ if (end==0)
+ print "Original-" $0;
+ else
+ print $0;
+ }' | tac | git commit --amend -F -