From 76cd9bdf45f9dc0f7e8820071d609bb299cb0bdc Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 17 Sep 2023 15:07:32 +0100 Subject: [PATCH] git-psykorebase: determine branch names with bash pattern substitution (#1073) Co-authored-by: Dan Goodliffe --- bin/git-psykorebase | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/bin/git-psykorebase b/bin/git-psykorebase index 778adcc..5c9a3da 100755 --- a/bin/git-psykorebase +++ b/bin/git-psykorebase @@ -50,15 +50,13 @@ fi if [[ "$CONTINUE" == "yes" ]]; then TARGET_BRANCH=$(current_branch) - set "$(echo "$TARGET_BRANCH" | sed -e "s/-rebased-on-top-of-/\n/g")" - if [[ $# != 2 ]]; then + SECONDARY_BRANCH=${TARGET_BRANCH%"-rebased-on-top-of-"*} + PRIMARY_BRANCH=${TARGET_BRANCH#*"-rebased-on-top-of-"} + if [[ "${SECONDARY_BRANCH}-rebased-on-top-of-${PRIMARY_BRANCH}" != $TARGET_BRANCH ]]; then echo "Couldn't continue rebasing on ${TARGET_BRANCH}" exit 30 # Impossible to detect PRIMARY_BRANCH AND SECONDARY_BRANCH fi - SECONDARY_BRANCH=$1 - PRIMARY_BRANCH=$2 - echo "Continuing rebasing of $SECONDARY_BRANCH on top of $PRIMARY_BRANCH" git commit || exit 51 git branch -d "${SECONDARY_BRANCH}" || exit 52