]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-backport.sh: cherry-pick individual commits 30097/head
authorJan Fajerski <jfajerski@suse.com>
Tue, 3 Sep 2019 11:26:20 +0000 (13:26 +0200)
committerJan Fajerski <jfajerski@suse.com>
Tue, 3 Sep 2019 13:14:15 +0000 (15:14 +0200)
In git 2.23.0 (possibly earlier too) cherry-pick seems to interact with
rev-list and submodules in unexpected ways, where the cherry-pick of a
commit range (<sha1>..<sha1>) fails with "changes would be overwritten"
in a submodule. CP'ing individual commits avoids this.

Signed-off-by: Jan Fajerski <jfajerski@suse.com>
src/script/ceph-backport.sh

index 5cd603e14ecbfc34d082df81304ee68b757a6805..8893ece701e79e6d5613469af3e79963ec67002f 100755 (executable)
@@ -232,6 +232,7 @@ function populate_original_pr {
 }
 
 function prepare {
+    local offset=0
     populate_original_issue
     if [ -z "$original_issue" ] ; then
         error "Could not find original issue"
@@ -265,7 +266,12 @@ function prepare {
 
     debug "Cherry picking $number commits from ${github_endpoint}/pull/${original_pr} into local branch $local_branch"
     debug "If this operation does not succeed, you will need to resolve the conflicts manually"
-    git cherry-pick -x pr-$original_pr~$number..pr-$original_pr
+    let offset=$number-1 || true # don't fail on set -e when result is 0
+    for ((i=$offset; i>=0; i--))
+    do
+        debug "Cherry-picking commit $(git log --oneline --max-count=1 --no-decorate)"
+        git cherry-pick -x "pr-$original_pr~$i"
+    done
     info "Cherry picked $number commits from ${github_endpoint}/pull/${original_pr} into local branch $local_branch"
 
     exit 0