]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
script/ceph-backport: do not assume ref layout for checkout
authorPatrick Donnelly <pdonnell@redhat.com>
Thu, 27 Jun 2024 16:18:06 +0000 (12:18 -0400)
committerPatrick Donnelly <pdonnell@redhat.com>
Fri, 28 Jun 2024 20:28:27 +0000 (16:28 -0400)
The local repository may have a different layout from the defaults
for remote repository references. As for myself, I have:

    [remote "upstream"]
        url = git@github.com:ceph/ceph.git
        fetch = +refs/*:refs/remotes/upstream/*

So I have a local mirror of the full ceph.git repsository and upstream branches are
available via `refs/remotes/upstream/heads/<branch>`.

So, fetch the desired branch and use FETCH_HEAD instead. This is not 100% the same
as the merge branch for the wip- branch becomes:

    [branch "wip-66572-squid"]
        remote = origin
        merge = refs/heads/wip-66572-squid

So the remote tracking branch is now the origin. Rebasing to a newer <release> branch
must be done manually:

    git rebase upstream/heads/<release>

Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
src/script/ceph-backport.sh

index f4f88499409f35fbfaa80d1da6bc2a482eacfa03..bf2d1061426b19733c31de89e09ed922009e37b1 100755 (executable)
@@ -258,13 +258,13 @@ function cherry_pick_phase {
     fi
 
     set -x
-    git fetch "$upstream_remote"
+    git fetch "$upstream_remote" "refs/heads/${milestone}"
 
     if git show-ref --verify --quiet "refs/heads/$local_branch" ; then
         if [ "$FORCE" ] ; then
             if [ "$non_interactive" ] ; then
                 git checkout "$local_branch"
-                git reset --hard "${upstream_remote}/${milestone}"
+                git reset --hard FETCH_HEAD
             else
                 echo
                 echo "A local branch $local_branch already exists and the --force option was given."
@@ -276,7 +276,7 @@ function cherry_pick_phase {
                 [ "$yes_or_no_answer" ] && yes_or_no_answer="${yes_or_no_answer:0:1}"
                 if [ "$yes_or_no_answer" = "y" ] ; then
                     git checkout "$local_branch"
-                    git reset --hard "${upstream_remote}/${milestone}"
+                    git reset --hard FETCH_HEAD
                 else
                     info "OK, bailing out!"
                     false
@@ -289,7 +289,7 @@ function cherry_pick_phase {
             false
         fi
     else
-        git checkout "${upstream_remote}/${milestone}" -b "$local_branch"
+        git checkout -b "$local_branch" FETCH_HEAD
     fi
 
     git fetch "$upstream_remote" "pull/$original_pr/head:pr-$original_pr"