diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
commit | 698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch) | |
tree | 173a775858bd501c378080a10dca74132f05bc50 /src/tools/cherry-pick.sh | |
parent | Initial commit. (diff) | |
download | rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip |
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/cherry-pick.sh')
-rwxr-xr-x | src/tools/cherry-pick.sh | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/tools/cherry-pick.sh b/src/tools/cherry-pick.sh new file mode 100755 index 000000000..90539a963 --- /dev/null +++ b/src/tools/cherry-pick.sh @@ -0,0 +1,34 @@ +#!/bin/bash +set -euo pipefail +IFS=$'\n\t' + +print_error() { + echo "Error: \`$1\` is not a valid commit. To debug, run:" + echo + echo " git rev-parse --verify $1" + echo +} + +full_sha() { + git rev-parse \ + --verify \ + --quiet \ + "$1^{object}" || print_error $1 +} + +commit_message_with_backport_note() { + message=$(git log --format=%B -n 1 $1) + echo $message | awk "NR==1{print; print \"\n(backport-of: $1)\"} NR!=1" +} + +cherry_pick_commit() { + sha=$(full_sha $1) + git cherry-pick $sha > /dev/null + git commit \ + --amend \ + --file <(commit_message_with_backport_note $sha) +} + +for arg ; do + cherry_pick_commit $arg +done |