These changes update Zed's Git Panel to be able to detect unsafe git repositories, where the user running Zed doesn't own the `.git` directory, and show a dedicated empty view in the Git Panel that not only explains the situation but also allows the user to choose whether to trust this directory, which will end up running `git config --global --add safe.directory <path>`. While testing those changes, it was noted that attempting to add or reset files after trusting the directory would fail, as expected, but the UI wouldn't react to the fact that those operations failed. What this means is, if the user tried to add a file, the UI would show a checkmark for that file and, after the operation failed, the checkmark would remain. We now revert that, for both `git add` and `git reset`. Some more technical notes on this change: - Introduce `project::git_store::GitAccess` enum to express whether we actually have access to the repository, exposed via `git::Repository::access`, which probes the backend with a `git status` command and classifies the result. - On unsafe repositories, `project::git_store::LocalRepositoryState::new` fails to spawn the git worker, which now cleanly signals `GitAccess::No` rather than leaving the panel in a broken state. - Updated `git_ui::git_panel::GitPanel::render_empty_state` with a third alternative, when `GitAccess::No`, that basically renders a view explaining why the repository is considered unsafe, together with buttons for git's documentation on safe directories and a button to add the repository's folder as a safe directory - Updated `project::git_store::GitStore` to now watch `~/.gitconfig` and `$XDG_CONFIG_HOME/git/config`. Watching this files allows the Git Panel to react when the git configuration is updated, which will be the case if the user decides to trust the repository. When either changes, a `GitStoreEvent::GlobalConfigurationUpdated` event is emitted and the panel refetches repository state. - Added `project::git_store::Repository::refetch_repo_state` field, which stores a closure to allow recreating the `Repository::repository_state` and the job sender after the repository's directory is trusted, without requiring a project reload. - Added a `fs::Fs::git_config` trait method, wrapping a real `git config` invocation. In order to be able to call this, both `git_store::GitStore::git_config` and `project::Project::git_config` wrappers have also been introduced. Worth mentioning that this isn't yet supported for remote projects or collab guests. - Updated `fs::Fs::git_clone` argument order to match `fs::Fs::git_config` and `fs::Fs::git_init`. - Added a new `project::git_store::pending_op::PendingOps::last_op_errored` method that allows determining whether the last pending operation failed. This now allows us to filter out failed operations when determining whether `git add` or `git reset` failed, so that we can fall through to the real git status. - Updated `git_ui::git_panel::GitPanel::change_file_stage` to now call `update_counts` in its error branch so the cached staged counters stay consistent with the reverted per-entry state, seeing as we now handle reverting the UI state if an operation fails. - Fixed `fs::RealFs::git_init` to fall back to the provided branch name when `git config --global --get init.defaultBranch` fails, for example, when the user hsan't configured one. Co-authored-by: cameron <cameron.studdstreet@gmail.com> Closes #42286 Release Notes: - Added a dedicated empty state in the Git Panel for unsafe repositories, with a "Trust Directory" button that adds the repository to `safe.directory` - Fixed stage and unstage checkboxes in the Git Panel not reverting when a `git add` or `git reset` command failed --------- Co-authored-by: cameron <cameron.studdstreet@gmail.com> Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
Zed
Welcome to Zed, a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Installation
On macOS, Linux, and Windows you can download Zed directly or install Zed via your local package manager (macOS/Linux/Windows).
Other platforms are not yet available:
- Web (tracking issue)
Developing Zed
Contributing
See CONTRIBUTING.md for ways you can contribute to Zed.
Also... we're hiring! Check out our jobs page for open roles.
Licensing
License information for third party dependencies must be correctly provided for CI to pass.
We use cargo-about to automatically comply with open source licenses. If CI is failing, check the following:
- Is it showing a
no license specifiederror for a crate you've created? If so, addpublish = falseunder[package]in your crate's Cargo.toml. - Is the error
failed to satisfy license requirementsfor a dependency? If so, first determine what license the project has and whether this system is sufficient to comply with this license's requirements. If you're unsure, ask a lawyer. Once you've verified that this system is acceptable add the license's SPDX identifier to theacceptedarray inscript/licenses/zed-licenses.toml. - Is
cargo-aboutunable to find the license for a dependency? If so, add a clarification field at the end ofscript/licenses/zed-licenses.toml, as specified in the cargo-about book.
Sponsorship
Zed is developed by Zed Industries, Inc., a for-profit company.
If you’d like to financially support the project, you can do so via GitHub Sponsors. Sponsorships go directly to Zed Industries and are used as general company revenue. There are no perks or entitlements associated with sponsorship.