Overview
Implement advanced branch operations to enable switching branches, merging, and rebasing, matching isomorphic-git feature parity.
Commands to Implement
Acceptance Criteria (AC)
- AC1: Checkout Functionality - Can switch between branches, preserving working tree changes
- AC2: Merge Functionality - Can perform fast-forward and recursive merges with conflict detection
- AC3: Rebase Functionality - Can rebase a branch onto another with proper commit replay
- AC4: Branch Listing - Can list all branches and identify current branch
- AC5: Merge Conflict Handling - Properly detects and reports merge conflicts without auto-resolving
- AC6: Abort Operations - Can abort in-progress merge/rebase operations
Definition of Done (DoD)
Interop Test Method
// Setup test repo
const repoDir = '/tmp/test-branch-ops';
await tsGit.init({ fs, dir: repoDir, defaultBranch: 'main' });
// Create commits on main and feature branches...
// Test merge
await tsGit.merge({ fs, dir: repoDir, ours: 'main', theirs: 'feature' });
const tsGitLog = await tsGit.log({ fs, dir: repoDir, depth: 3 });
// Compare with canonical git
execSync('git merge feature', { cwd: '/tmp/ref-repo' });
const refLog = execSync('git log --oneline -3', { cwd: '/tmp/ref-repo' }).toString();
// Verify merge commit structure matches
Validation Strategy:
- Create identical repo state in ts-git and canonical git
- Perform branch operations (checkout, merge, rebase)
- Compare resulting commit graph, tree state, and branch refs
- Test conflict scenarios with prepared conflict files
Priority
High - Essential for collaborative workflows
Dependencies
- Requires plumbing commands (cat-file, update-index) for tree manipulation
Overview
Implement advanced branch operations to enable switching branches, merging, and rebasing, matching isomorphic-git feature parity.
Commands to Implement
checkout- Switch branches or restore working tree filesswitch- Switch branches (modern alternative to checkout)merge- Merge one branch into anotherabortMerge- Abort an in-progress mergerebase- Reapply commits on top of another base tiplistBranches- List all local (and optionally remote) branchesdeleteBranch- Delete a branchcurrentBranch- Get the current branch nameAcceptance Criteria (AC)
Definition of Done (DoD)
Interop Test Method
Validation Strategy:
Priority
High - Essential for collaborative workflows
Dependencies