Show type-changed files in commit diffs (#60422)
# Objective Zed ignores files marked by Git as type-changed (T), causing commits containing only these changes to show 0 Changed Files. For example, commit d7cc949e61351a6028f933abbaea39f67af9dfb2 changes crates/eval_utils/LICENSE-GPL from a regular file to a symlink, but Zed displays no changes. ## Solution Handle TypeChanged files like modified files by loading both their old and new contents. ## Testing - Added parser coverage for the T status. - Added a repository test for a regular-file-to-symlink change. - Ran cargo test -p git. - Ran ./script/clippy -p git. - Manually verified the example commit on macOS. ## Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content adheres to Zed's UI standards ([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) and [icon](https://github.com/zed- industries/zed/blob/main/crates/icons/README.md) guidelines) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable ## Showcase Before: <img width="200" alt="image" src="https://github.com/user-attachments/assets/277c5938-5c2c-47b7-902d-9061a14c062a" /> After: <img width="200" alt="image" src="https://github.com/user-attachments/assets/f99d0005-0712-4843-814e-d73b11f64782" /> ——— Release Notes: - Fixed type-changed files not appearing in Git Graph and commit views.
This commit is contained in:
1 parent
b4d9194fce
commit
04de6dab7c
2 files changed
+60
-2
No files matched your search
@@ -109,6 +109,7 @@ pub fn parse_git_diff_name_status(content: &str) -> impl Iterator<Item = (&str,
|
||||
let path = parts.next()?;
|
||||
let status = match status_str {
|
||||
"M" => StatusCode::Modified,
|
||||
"T" => StatusCode::TypeChanged,
|
||||
"A" => StatusCode::Added,
|
||||
"D" => StatusCode::Deleted,
|
||||
_ => continue,
|
||||
@@ -127,6 +128,7 @@ mod tests {
|
||||
fn test_parse_git_diff_name_status() {
|
||||
let input = concat!(
|
||||
"M\x00Cargo.lock\x00",
|
||||
"T\x00LICENSE-GPL\x00",
|
||||
"M\x00crates/project/Cargo.toml\x00",
|
||||
"M\x00crates/project/src/buffer_store.rs\x00",
|
||||
"D\x00crates/project/src/git.rs\x00",
|
||||
@@ -142,6 +144,7 @@ mod tests {
|
||||
output,
|
||||
&[
|
||||
("Cargo.lock", StatusCode::Modified),
|
||||
("LICENSE-GPL", StatusCode::TypeChanged),
|
||||
("crates/project/Cargo.toml", StatusCode::Modified),
|
||||
("crates/project/src/buffer_store.rs", StatusCode::Modified),
|
||||
("crates/project/src/git.rs", StatusCode::Deleted),
|
||||
|
||||
Reference in new issue
Block a user