Add commit categorization into three types:
- Feature branch representation (drop and re-pick)
- Already merged upstream (drop without re-picking)
- Personal-only (keep as-is)
Includes detection of merged upstream commits via git log --grep, and
explicit user categorization for ambiguous commits.
@@ -106,7 +106,15 @@ To enumerate branches: use `wt l` or `git worktree list` in worktree layouts, `g
git log --oneline upstream/<canonical>..HEAD
```
-### Step 3: Correlate personal commits to feature branches
+### Step 3: Correlate and categorize personal commits
+
+Each commit in the personal branch falls into one of three categories:
+
+1. **Feature branch representation**: matches a feature branch, drop and re-pick fresh
+2. **Already merged upstream**: exists in upstream's history, drop without re-picking
+3. **Personal-only**: matches nothing, stays as-is
+
+#### 3a: Match commits to feature branches
For each feature branch, find its commits beyond upstream:
@@ -118,9 +126,31 @@ The **oldest** commit's subject line identifies the feature branch in the person
**Only** branches with at least one commit ahead of upstream whose subject matches a commit in the personal branch should be included. Branches with no matching commit in personal are not represented there and should be ignored unless the user explicitly says to include new ones.
-If matches are ambiguous (e.g. multiple commits with very similar subjects across branches), flag this to the user before proceeding.
+#### 3b: Detect commits merged upstream
+
+For each unmatched commit in the personal branch, check if it was merged upstream:
+
+```sh
+git log --oneline --grep="<subject>" upstream/<canonical>
+```
+
+If the subject appears in upstream's history, the commit is likely merged and can be dropped without re-picking. Mark it as "merged upstream."
+
+#### 3c: Request user categorization for ambiguous commits
+
+After automatic correlation, some commits may remain ambiguous:
+
+- Subject matches multiple feature branches
+- Subject partially matches but isn't exact
+- No match found, but commit doesn't look like a personal customization
+
+**Do not guess.** Present all unmatched/ambiguous commits to the user and ask them to categorize each as:
+
+- **(a) Merged upstream** — drop without re-picking
+- **(b) Feature branch** — specify which branch; drop and re-pick
+- **(c) Personal-only** — keep as-is
-Commits in the personal branch that match no feature branch are personal-only customizations. They stay.
+Wait for the user to respond before proceeding to Step 4.
### Step 4: Present the plan