From: Patrick Donnelly Date: Thu, 27 Jun 2024 16:18:06 +0000 (-0400) Subject: script/ceph-backport: do not assume ref layout for checkout X-Git-Tag: v20.0.0~1254^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=97c49d67eaf87b50f5d2117c22bc58ef84d65dee;p=ceph.git script/ceph-backport: do not assume ref layout for checkout 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/`. 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 branch must be done manually: git rebase upstream/heads/ Signed-off-by: Patrick Donnelly --- diff --git a/src/script/ceph-backport.sh b/src/script/ceph-backport.sh index f4f88499409..bf2d1061426 100755 --- a/src/script/ceph-backport.sh +++ b/src/script/ceph-backport.sh @@ -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"