Skip to content

Merge auto-syncs a behind local default branch instead of refusing #791

Closed

Description

@currentbits

Problem

assertDefaultNotBehindOrigin (electron/worktrees.js, #770) hard-refuses every Git-tab Merge once local main is behind origin/main. The squash-landing workflow (leftover worktrees land on origin via a squash from another checkout, e.g. #784) leaves local main BOTH ahead (duplicate commits) and behind permanently, so the refusal fires on every merge until someone hand-fixes the checkout. Meanwhile new worktrees keep forking from the stale base, re-shipping already-fixed bugs.

Fix

Replace the refusal with a tiered auto-sync in the checkout that holds the default branch:

  1. behind>0, ahead==0 → fast-forward (merge --ff-only).
  2. behind>0, ahead>0 → probe git merge-tree --write-tree; clean → merge --no-edit origin/<branch>.
  3. probe conflicts → keep refusing, but name the likely cause (local commits already squash-landed upstream) and the remedy (backup branch + reset --hard origin/<branch>).

Never sync into a dirty checkout: tracked modifications fall back to the refusal.

Activity

  1. currentbits commented on Aug 29, 2026

    @currentbits
    OwnerAuthor

    Implemented on branch coder/fork-fork-i-got-this-feedback-i-got-this-a6b98b: assertDefaultNotBehindOrigin became syncDefaultWithOrigin (electron/worktrees.js). Behind-only fast-forwards; diverged auto-merges when merge-tree --write-tree proves it clean; dirty checkout or conflicts still refuse, now with the backup-branch + reset --hard remedy in the message. 4 new tests in electron/test/worktrees.test.js replace the old #770 refusal test; suite 63/63. The live blockage that motivated this is also cleared: /Users/willem/code/coder-release-build main was reset to origin/main (backup branch backup-diverged-69c6cb2) after verifying its 18 ahead commits were all content-landed via the 9866118 squash.

  2. added
    plan:done
    and removed
    plan:doing
    on Sep 6, 2026
  3. currentbits commented on Sep 6, 2026

    @currentbits
    OwnerAuthor

    Shipped. electron/worktrees.js syncDefaultWithOrigin replaced the old refuse-when-behind gate: behind-only fast-forwards; diverged auto-merges only when merge-tree is clean; dirty checkout or conflicts still refuse.

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

    plan:done

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions