Skip to content

Rebase worktree onto new stacked base after setBaseBranch #775

Closed

Description

@currentbits

Summary

#187 / #774 records ThreadInfo.baseBranch and lets the user change it after create (threads.setBaseBranch). Changing the base retargets later merge/PR. A bound worktree is retargeted onto the new start-point.

Plan

  • When setBaseBranch succeeds and worktreePath is set, retarget the worktree before persisting the new base.
  • Dirty porcelain: refuse with WORKTREE_DIRTY; recorded base and HEAD stay put.
  • Clean tree with unique thread-branch commits: git rebase --onto <newBase> <oldStart> so those commits stay on top of the new base.
  • Clean tree with no unique commits: reset onto the new start-point (or repo default when cleared).
  • Rebase conflict: abort + rollback; recorded base and worktree HEAD unchanged.
  • Still refuse after the first PR.
  • Do not change the Git-tab default target (origin/HEAD → main when unset).

Tests

  • setBaseBranch on a clean worktree with no unique commits moves HEAD to the new base.
  • Dirty worktree is refused and the recorded base is left unchanged.
  • A worktree with a unique commit keeps that commit on top of the new base (HEAD is the rebased tip, not the base tip).
  • Rebase conflict leaves the recorded base and worktree HEAD unchanged.

Follow-up to #774 and #187

Activity

  1. added
    enhancement
    plan:doing
    on Aug 29, 2026
  2. currentbits commented on Aug 29, 2026

    @currentbits
    OwnerAuthor

    Implemented on coder/fork-fork-fork-merge-worktree-lands-on-t-248af4.

    setBaseBranch now retargets a bound worktree before persisting ThreadInfo.baseBranch:

    • Clean tree: git reset --hard onto the new base (or repo default when cleared). HEAD moves.
    • Dirty tree: WORKTREE_DIRTY, recorded base left unchanged.

    Git-tab Merge with no recorded base is still origin/HEAD → main. Unique commits on the thread branch are dropped (recreate, not rebase); that is a follow-up.

  3. added
    plan:done
    and removed
    plan:doing
    on Aug 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementplan:done

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions