board_status.sh: Clean up output, show what the script is doing
[coreboot.git] / util / gitconfig / rebase.sh
blob26cec55fde25ad58e7d54b023215253c2f02540a
1 #!/bin/sh
3 # rebase.sh - rebase helper script
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; version 2 of the License.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
15 # Adapt to your remote branch:
16 BRANCH="cros/chromeos-2015.07"
18 # When pulling in patches from another tree from a gerrit repository,
19 # do the following at the end of a larger cherry-pick series:
20 # git remote add ...
21 # git checkout -b upstreaming
22 # git cherry-pick ...
23 # git rebase -i --exec util/gitconfig/rebase.sh master
24 # Alternatively, you can run util/gitconfig/rebase.sh after every
25 # individual cherry-pick.
27 commit_message() {
28 git log -n 1 | grep "^ " | cut -c5-
31 CHID=$( commit_message | grep -i "^Change-Id: I" )
32 CID=$( git log -n1 --grep "^$CHID$" --pretty=%H $BRANCH )
33 GUID="$(git config user.name) <$(git config user.email)>"
35 # TBD: Don't add Original- to empty lines, and possibly make script more
36 # solid for commits with an unexpected order of meta data lines.
38 commit_message | tac | awk '/^$/ {
39 if (end==0)
40 print "Original-Commit-Id: '"$CID"'\nSigned-off-by: '"$GUID"'";
41 end=1
42 }; {
43 if (end==0)
44 print "Original-" $0;
45 else
46 print $0;
47 }' | tac | git commit --amend -F -