You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
🤖 Fix code review: eliminate inverse deltas when branch is behind base (#340)
## Problem
When a branch is behind `origin/main` and the "Uncommitted" checkbox is
enabled in Code Review, inverse deltas (deletions) appear for commits
that landed on `origin/main` after branching.
**Root cause:** Toggling "Uncommitted" switched between different git
diff modes:
- `git diff origin/main...HEAD` (three-dot, stable merge-base) when
uncommitted=false
- `git diff origin/main` (two-dot, tip comparison) when uncommitted=true
The two-dot diff compares the tip of `origin/main` to the working
directory, showing commits Y, Z, W as deletions since they exist on main
but not in the feature branch.
## Solution
Use explicit `git merge-base` when `includeUncommitted` is true:
```bash
# includeUncommitted=false (committed only)
git diff origin/main...HEAD
# includeUncommitted=true (committed + uncommitted)
git diff $(git merge-base origin/main HEAD)
```
**Benefits:**
- **Stable merge-base:** Doesn't change when base ref moves forward
- **Single unified diff:** Avoids duplicate hunks from concatenation
- **Clear semantics:** "Uncommitted" literally means "include working
directory changes"
## Test Coverage
Added comprehensive test: "should not show inverse deltas when branch is
behind base ref"
- Creates feature branch from main
- Adds 3 commits to main after branching (simulates branch falling
behind)
- Adds committed + uncommitted changes to feature branch
- Verifies: Shows only feature changes, NOT inverse deltas from main
All 662 tests pass ✓
_Generated with `cmux`_
0 commit comments