Repository navigation
feat(gix)!: add worktree locking and a lock override that preserves changes - #3058
Conversation
02ca536 to
51ee379
Compare
…hanges <!-- agent --> Expose `Worktree::set_lock(Option<&BStr>)` and `worktree::Proxy::set_lock()` so callers can protect linked worktrees from pruning, moving, or removal, including when their checkout is offline. Implement file handling in `gix_worktree::set_lock()`: preserve byte-oriented reasons, append Git's trailing newline when needed, and make unlocking idempotent. Reject the main worktree in the porcelain and avoid writing through lock-file symlinks. Previously `Force::OverrideLock` also discarded local changes and initialized submodules. Add `Force::OverrideLockKeepChanges` to bypass just the lock check, retaining status and submodule validation. This expands an exhaustive public enum, so adapt the Tix caller in the same commit; existing CLI force levels retain their behavior. Git reference: `v2.56.0-116-g6de20f6092` (`6de20f6092dcf9bdb1c8efe03db4b70c82b423dd`), `builtin/worktree.c` lock/unlock/removal, `wrapper.c` newline encoding, and `t/t2403-worktree-move.sh`. Git's `worktree remove -ff` bypasses both lock and cleanliness checks; the new mode deliberately permits bypassing only the lock. exposes a pre-existing unresolved `with_fetch_options` link in clone docs. Assisted-by: GPT 6.1 Sol Co-authored-by: GPT 6.1 Sol <codex@openai.com>
51ee379 to
862e9c3
Compare
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 862e9c3b8c
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "Codex (@codex) review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "Codex (@codex) address that feedback".
Tasks
This section is for Byron only. Models continuing this PR must not add, remove, check, uncheck, rename, or reorder checkboxes here.
Everything below this line was generated by
Codex GPT-6.Created by Codex on behalf of Byron. Byron will review before this is ready to merge.
Linked worktrees can now be locked, have their reason updated, or be unlocked through
Worktree::set_lock(Option<&BStr>)andworktree::Proxy::set_lock(). The shared implementation isgix_worktree::set_lock(), with Git-compatible byte-oriented reasons, idempotent unlocking, and protection against writing through lock-file symlinks. The proxy also supports offline checkouts; the porcelain rejects main-worktree locking.Force::OverrideLockKeepChangesremoves clean locked worktrees while rejecting staged, unstaged, untracked, or initialized-submodule state. ExistingOverrideLockand CLI force levels retain their destructive behavior. Adding the enum variant requires downstream exhaustive-match updates; this PR includes the Tix adaptation.Reported issue
Validation
gixworktree tests and 47gix-worktreeintegration tests pass, including interoperability with Git and preservation of local changes.lockedwas a FIFO. Existing non-regular files are now rejected before opening, with a bounded isolated regression that failed on the original implementation.gix,gix-worktree, andgix-tix.gixwith and without worktree mutation, and forgix-worktree.gix'sblocking-network-clientfeature. Default-feature-only docs expose an existing unrelatedwith_fetch_optionslink failure in clone documentation.Git reference:
v2.56.0-116-g6de20f6092(6de20f6092dcf9bdb1c8efe03db4b70c82b423dd),builtin/worktree.c,wrapper.c, andt/t2403-worktree-move.sh. Git'sworktree remove -ffbypasses both lock and cleanliness checks; the new enum variant allows bypassing only the lock. Concurrent updates to a worktree's lock must be serialized by the caller, as documented.