Skip to content

fix: atomic Worktree.Checkout — prevent inconsistent state on sparse checkout failure - #4

Open
johneapen80 wants to merge 1 commit into
jaasielitaigq:mainfrom
johneapen80:fix/sparse-checkout-atomic
Open

fix: atomic Worktree.Checkout — prevent inconsistent state on sparse checkout failure#4
johneapen80 wants to merge 1 commit into
jaasielitaigq:mainfrom
johneapen80:fix/sparse-checkout-atomic

Conversation

@johneapen80

Copy link
Copy Markdown

Fixes inconsistent repository state during Worktree.Checkout() sparse checkout operations.

Root cause: In Checkout(), setHEADToCommit was called BEFORE Reset(). If Reset failed mid-operation, HEAD already pointed to the target commit while working tree and index were not updated — leaving repository in inconsistent state.

Fix: Atomic checkout — Reset first (which handles setHEAD internally), only update HEAD on success, and restore original HEAD on failure.

Closes #1

…e checkout failure

Order of operations: Reset first (with internal setHEAD) → only update HEAD on success → restore original HEAD on failure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🎯 Prevent inconsistent repository state when Worktree.Checkout() sparse checkout updates fail mid-operation

1 participant