tj / tj/git-extras

git psykorebase --continue is broken on macOS

Open
#856 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

pull request is welcome
Dominant language
Shell
Stars
18.1k
Forks
1.2k
Avg merge
5d 17h
Merged PRs (30d)
1

Description

Problem

psykorebasing a branch on another, and having a resolved conflict:

$ git psykorebase --continue
Couldn't continue rebasing on ...

Analysis

psykorebase depends on sed, however the macOS version does not have the feature needed.

psykorebase has this line under the --continue flag:

    set $(echo "$TARGET_BRANCH" | sed -e "s/-rebased-on-top-of-/\n/g")

which is supposed to be splitting the branch name into two lines, to be later used as branch names.

macOS sed has a problem with the \n substitution, as it expects the literal newline character after \ not n, so the above code substitutes n instead of newline.

Relevant macOS documentation

$ man sed
SED(1)                    BSD General Commands Manual                   SED(1)

NAME
     sed -- stream editor
...
     [2addr]s/regular expression/replacement/flags
...
             A line can be split by substituting a newline character into it.  To specify a newline character in the replacement string, precede it with a back-slash.

sed compatibility comparison/guide

https://riptutorial.com/sed/topic/9436/bsd-macos-sed-vs--gnu-sed-vs--the-posix-sed-specification

In replacement strings used with the s command, assume that NO control-character escape sequences are supported, so, again, include control chars. as literals, as above.

Linux only:
sed 's/-/\t/' <<<$'a-b' # -> 'a<tab>b'
macOS and Linux:
sed 's/-/'$'\t''/' <<<'a-b'
sed 's/-/'"$(printf '\t')"'/' <<<'a-b'

In this case the working solution is a bit more complex (tested only on macOS):

    set $(echo "$TARGET_BRANCH" | sed -e "$(printf 's/-rebased-on-top-of-/\\\n/g')")

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in the psykorebase implementation at the --continue flag and inspect how TARGET_BRANCH is split with sed. Reproduce the failure on macOS, then verify that a resolved conflict can continue successfully without breaking the existing Linux behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, shell
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.