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
A commit is its own ancestor. Share this helper with M4.
Implement merge(branch_name) in this order:
Missing target: RefNotFoundError.
Target equals the current tip, or is already its ancestor: return None; change nothing.
Current tip is the target's ancestor, or the current branch is unborn: checkout the target tree, then update the current branch ref. Return None.
Otherwise raise MiniGitError("three-way merge is not implemented yet"); change nothing.
Register minigit merge <branch>. Keep HEAD on the current branch after merging. Branch creation and listing keep their existing behavior.
Run scripts/quality-check.sh. Open a PR linked to this issue and request a teammate review.
Tests
Switch between two real snapshots; check files, index, HEAD, and unchanged branch tips.
Fast-forward updates the current ref and files without creating a commit.
Check same-tip merges, already-merged targets, unborn branches, and diverged history.
Check ancestry through a second parent.
Staged edits or checkout failure leave refs and HEAD unchanged.
Team checkpoint
Commit A on main, create feature, switch to it, and commit B. Switch to main: files show A. Merge feature: files show B, both refs point to B, and status is clean.
Done when
Branch switching and fast-forward merge pass with real M1/M2.
Ancestry helper is ready for M4.
Team checkpoint passes.
Quality check passes; PR open and review requested.
Owner: @DanisLol
Files:
minigit/commits.py,tests/test_commits.pyDepends on: #18 and #23 (M2 checkout)
Branch:
week4/m3-checkout-and-fast-forwardMake branch switching restore files. Add fast-forward merging: move the current branch to a later commit without creating a merge commit.
Steps
mainafter Week 3 - M3: Real tree commits + history helpers #18 merges. Use a fake checkout for ordering tests until M2 lands.get_head_tree().MiniGitError.switch_branch(name): read the target ref, read its commit, callself.tree.checkout(commit.tree), then write HEAD.RefNotFoundError.is_ancestor(ancestor_hash: str, descendant_hash: str) -> bool.walk_history; follow every parent.merge(branch_name)in this order:RefNotFoundError.None; change nothing.None.MiniGitError("three-way merge is not implemented yet"); change nothing.minigit merge <branch>. Keep HEAD on the current branch after merging. Branch creation and listing keep their existing behavior.scripts/quality-check.sh. Open a PR linked to this issue and request a teammate review.Tests
Team checkpoint
Commit A on
main, createfeature, switch to it, and commit B. Switch tomain: files show A. Mergefeature: files show B, both refs point to B, andstatusisclean.Done when