# Add allow_empty commits, detached worktree creation, and new git operations \(\#53213\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/fb2bff879ce45b14f1cd6589edf1703e7ed4b37b)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: fb2bff879ce45b14f1cd6589edf1703e7ed4b37b

Requested commit: fb2bff879ce45b14f1cd6589edf1703e7ed4b37b

Commit: fb2bff879ce45b14f1cd6589edf1703e7ed4b37b

Tree: a0882ea2d85296cfc36915138a26d358000e3dfc

Author: Richard Feldman

Committer: GitHub

## Message

```
Add allow_empty commits, detached worktree creation, and new git operations (#53213)

Extend the git API with several new capabilities needed for worktree
archival and restoration:

- Add `allow_empty` flag to `CommitOptions` for creating WIP marker
commits
- Change `create_worktree` to accept `Option<String>` branch, enabling
detached worktree creation when `None` is passed
- Add `head_sha()` to read the current HEAD commit hash
- Add `update_ref()` and `delete_ref()` for managing git references
- Add `stage_all_including_untracked()` to stage everything before a WIP
commit
- Implement all new operations in `FakeGitRepository` with functional
commit history tracking, reset support, and ref management
- Update existing call sites for the new `CommitOptions` field and
`create_worktree` signature

Part 1 of 3 in the persist-worktree stack. These are nonbreaking API
additions with no behavioral changes to existing code.

Release Notes:

- N/A

---------

Co-authored-by: Anthony Eid <anthony@zed.dev>
```

## Parents

- [5bd78e3f8eb9070ce9a8d7fdc71df7508633baae](https://git.cafe/gitcafe/zed/commit/5bd78e3f8eb9070ce9a8d7fdc71df7508633baae?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/fb2bff879ce45b14f1cd6589edf1703e7ed4b37b?format=markdown)
