Skip to content

restack appears to enter infinite loop when it encounters a merge conflict #33

@jacobsimpson-addepar

Description

@jacobsimpson-addepar

When I amend to an older commit in the stack that results in a merge conflict, I get repeated errors indicating a rebase is in progress:

branchless: git rebase b5ed1de43634dc9e64ab9a0e0d1555f6a2c41297 06e73bfc36ab4f7b83a6abbda1e24c55aa3435c5 --onto 69feacd33c46f8c4bdf053d7f778e2077bdfee56
Auto-merging README.md
CONFLICT (content): Merge conflict in README.md
Rebasing (1/1)^Mbranchless: processing 1 update to a branch/ref
branchless: processing 1 update to a branch/ref
error: could not apply 06e73bf... Make line 2 extra verbose
Resolve all conflicts manually, mark them as resolved with
"git add/rm <conflicted_files>", then run "git rebase --continue".
You can instead skip this commit: run "git rebase --skip".
To abort and get back to the state before "git rebase", run "git rebase --abort".
branchless: processing 1 update to a branch/ref
Recorded preimage for 'README.md'
branchless: processing 1 update to a branch/ref
Could not apply 06e73bf... Make line 2 extra verbose
branchless: resolve rebase, then run 'git restack' again
branchless: git rebase b5ed1de43634dc9e64ab9a0e0d1555f6a2c41297 06e73bfc36ab4f7b83a6abbda1e24c55aa3435c5 --onto 69feacd33c46f8c4bdf053d7f778e2077bdfee56
fatal: It seems that there is already a rebase-merge directory, and
I wonder if you are in the middle of another rebase.  If that is the
case, please try
        git rebase (--continue | --abort | --skip)
If that is not the case, please
        rm -fr ".git/rebase-merge"
and run me again.  I am stopping in case you still have something
valuable there.

branchless: resolve rebase, then run 'git restack' again
branchless: git rebase b5ed1de43634dc9e64ab9a0e0d1555f6a2c41297 06e73bfc36ab4f7b83a6abbda1e24c55aa3435c5 --onto 69feacd33c46f8c4bdf053d7f778e2077bdfee56
fatal: It seems that there is already a rebase-merge directory, and
I wonder if you are in the middle of another rebase.  If that is the
case, please try
        git rebase (--continue | --abort | --skip)
If that is not the case, please
        rm -fr ".git/rebase-merge"
and run me again.  I am stopping in case you still have something
valuable there.

The last bit repeats endlessly.

Repro:

mkdir -p origin-repo
cd origin-repo
git init .
printf "one\ntwo\nthree\n" > README.md
git add .
git commit -am "Initial commit."
cd ..
git clone origin-repo/.git cloned-repo
cd cloned-repo
git branchless init
git checkout -b feature-1
cp README.md tmp && sed '2s/^/lin /' < tmp > README.md && rm tmp
git commit -am "Update line 2."
git checkout -b feature-2
cp README.md tmp && sed '2s/^/this is /' < tmp > README.md && rm tmp
git commit -am "Make line 2 extra verbose"
git prev
cp README.md tmp && sed '2s/^lin /line /' < tmp > README.md && rm tmp
git amend -a
git restack

If you run into this in the wild:

  1. Break the loop w/ Ctrl-C
  2. Resolve the conflict by editing the conflicted file (README.md in the repro).
  3. git add README.md
  4. git rebase --continue
  5. git restack

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions