Skip to content

title_bar: Fix project name shown for repo.git bare clones on Windows remotes - #66199

Merged
Veykril merged 2 commits into
zed-industries:mainfrom
lingyaochu:title_bar_bare
Oct 27, 2026
Merged

Veykril merged 2 commits into
zed-industries:mainfrom
lingyaochu:title_bar_bare

Conversation

@lingyaochu

Copy link
Copy Markdown
Collaborator

Summary

For a repo named test_repo, if it is bare cloned without renaming the common dir, the common dir is test_repo.git, and Zed treats the directory itself as the identity path:

/// - If `common_dir`'s last component starts with `.` (e.g. `.git` for a
/// normal checkout, or `.bare` for a bare clone), the parent directory is
/// returned. Both of these are internal Git directories; the parent is the
/// meaningful project root.
/// - Otherwise (e.g. `zed.git` for a bare clone), `common_dir` itself is
/// returned — it is already a meaningful on-disk path.
pub fn repo_identity_path(common_dir: &Path, path_style: PathStyle) -> &Path {
let is_dot_entry = path_style
.file_name(common_dir)
.is_some_and(|n| n.to_string_lossy().starts_with('.'));
if is_dot_entry {
path_style.parent(common_dir).unwrap_or(common_dir)
} else {
common_dir
}
}

The title bar then uses the identity path to display the project name, with the name determined by the std lib’s method:

let display_name = if identity.extension() == Some(std::ffi::OsStr::new("git")) {
identity.file_stem()
} else {
path_style.file_name(identity)
};

When connecting from a Unix client to a Windows remote host, the identity path could be, for example, C:\User\test\test_repo.git. Applying std’s path methods to it yields an extension of git and a file stem of C:\User\test\test_repo, so the project name is displayed as C:\User\test\test_repo instead of test_repo.

This PR introduces two new PathStyle methods to handle retrieving file_stem() and extension() cross-platform. They mirror the std lib’s behavior using the already introduced Path components.

Testing

New unit tests for PathStyle::file_stem() and PathStyle::extension() are introduced to guard its behavior. The title bar shown is locally tested:

Before After
Before After

Self-review

  • I've reviewed my diff for quality, security, reliability, and performance.
  • UI changes follow the checklist.
  • Tests cover the new or changed behavior.

Release Notes:

  • Fixed project names in the title bar for repo.git bare clones on remote Windows hosts.

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Oct 27, 2026
@zed-community-bot zed-community-bot Bot added the community champion Issues filed by our amazing community champions! 🫶 label Oct 27, 2026

@Veykril Veykril left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Veykril
Veykril added this pull request to the merge queue Oct 27, 2026
Merged via the queue into zed-industries:main with commit f2a60bb Oct 27, 2026
52 checks passed
@lingyaochu
lingyaochu deleted the title_bar_bare branch October 27, 2026 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement community champion Issues filed by our amazing community champions! 🫶

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants