Skip to content

Commit 97c49d6

Browse files
committed
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 = [email protected]: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 <[email protected]>
1 parent cf51417 commit 97c49d6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/script/ceph-backport.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,13 +258,13 @@ function cherry_pick_phase {
258258
fi
259259

260260
set -x
261-
git fetch "$upstream_remote"
261+
git fetch "$upstream_remote" "refs/heads/${milestone}"
262262

263263
if git show-ref --verify --quiet "refs/heads/$local_branch" ; then
264264
if [ "$FORCE" ] ; then
265265
if [ "$non_interactive" ] ; then
266266
git checkout "$local_branch"
267-
git reset --hard "${upstream_remote}/${milestone}"
267+
git reset --hard FETCH_HEAD
268268
else
269269
echo
270270
echo "A local branch $local_branch already exists and the --force option was given."
@@ -276,7 +276,7 @@ function cherry_pick_phase {
276276
[ "$yes_or_no_answer" ] && yes_or_no_answer="${yes_or_no_answer:0:1}"
277277
if [ "$yes_or_no_answer" = "y" ] ; then
278278
git checkout "$local_branch"
279-
git reset --hard "${upstream_remote}/${milestone}"
279+
git reset --hard FETCH_HEAD
280280
else
281281
info "OK, bailing out!"
282282
false
@@ -289,7 +289,7 @@ function cherry_pick_phase {
289289
false
290290
fi
291291
else
292-
git checkout "${upstream_remote}/${milestone}" -b "$local_branch"
292+
git checkout -b "$local_branch" FETCH_HEAD
293293
fi
294294

295295
git fetch "$upstream_remote" "pull/$original_pr/head:pr-$original_pr"

0 commit comments

Comments
 (0)