Support detached HEAD in cherry_pick_pull.sh

When the repo is in a detached HEAD state (`git checkout origin/master`)
the cherrypick script fails with:

  fatal: ref HEAD is not a symbolic ref

because HEAD isn't pointing at a specific branch. The script only needs
the current branch in order to return the user to the branch afterwards.
We can fallback to tracking the detached HEAD commit so the script
returns the user back to the same commit.
This commit is contained in:
Peter Rifel 2026-05-07 20:02:17 -05:00
parent 1445342fc9
commit 1fb549b4fe
No known key found for this signature in database

View file

@ -29,7 +29,7 @@ REPO_ROOT="$(git rev-parse --show-toplevel)"
declare -r REPO_ROOT
cd "${REPO_ROOT}"
STARTINGBRANCH=$(git symbolic-ref --short HEAD)
STARTINGBRANCH=$(git symbolic-ref --short HEAD 2>/dev/null || git rev-parse HEAD)
declare -r STARTINGBRANCH
declare -r REBASEMAGIC="${REPO_ROOT}/.git/rebase-apply"
DRY_RUN=${DRY_RUN:-""}