2 # cross-repo-cherrypick - rebase helper script
4 # SPDX-License-Identifier: GPL-2.0-only
6 # Adapt to your remote branch:
9 # When pulling in patches from another tree from a gerrit repository,
10 # do the following at the end of a larger cherry-pick series:
12 # git checkout -b upstreaming
14 # git rebase -i --exec util/scripts/cross-repo-cherrypick master
15 # Alternatively, you can run util/scripts/cross-repo-cherrypick after every
16 # individual cherry-pick.
18 # use $0 --cros to add a stub BUG/BRANCH/TEST block
21 git log
-n 1 |
grep "^ " | cut
-c5-
24 ORIGIN_HOST
=$
( commit_message |
grep "^Reviewed-on: " |
head -1 |cut
-d/ -f3 )
25 case "${ORIGIN_HOST}" in
28 MESSAGE_PREFIX
="UPSTREAM: "
30 chromium-review.googlesource.com
)
36 # lines must be backwards due to tac(1)
38 if test "$1" = "--cros"; then
39 if test -z "$(commit_message | grep -E '^(BUG|TEST)=')"; then
40 SPLICE_CMD
='print "\nTEST=none\nBRANCH=none\nBUG=none\n"'
44 CHID
=$
( commit_message |
grep -i "^Change-Id: I" )
45 CID
=$
( git log
-n1 --grep "^$CHID$" --pretty=%H
$BRANCH )
46 GUID
="$(git config user.name) <$(git config user.email)>"
48 # TBD: Don't add Original- to empty lines, and possibly make script more
49 # solid for commits with an unexpected order of meta data lines.
51 (printf "${MESSAGE_PREFIX}"; commit_message
) |
tac |
awk '/^$/ {
53 print "GitOrigin-RevId: '"${CID}"'\nSigned-off-by: '"${GUID}"'";
57 }; /^(BUG|BRANCH|TEST)=/ {
59 print "GitOrigin-RevId: '"${CID}"'\nSigned-off-by: '"${GUID}"'";
74 }' |
tac | git commit
--amend -F -