Skip to content

project: Fix spurious git diff for symlinked files - #58655

Merged
smitbarmase merged 3 commits into
mainfrom
fix-git-diff-for-symlink
Jun 5, 2026
Merged

project: Fix spurious git diff for symlinked files#58655
smitbarmase merged 3 commits into
mainfrom
fix-git-diff-for-symlink

Conversation

@smitbarmase

@smitbarmase smitbarmase commented Jun 5, 2026

Copy link
Copy Markdown
Member

Opening a symlinked file showed the whole file as changed in the git gutter/diff. Git stores only the symlink's target path as that entry's blob, while the buffer holds the resolved target's contents, so diffing the two is meaningless.

We now skip loading a git diff base whenever a buffer's worktree entry is a symlink i.e. its canonical_path is set.

Release Notes:

  • Fixed symlinked files showing the entire file as changed in the git diff/gutter.

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Jun 5, 2026
@zed-community-bot zed-community-bot Bot added the staff Pull requests authored by a current member of Zed staff label Jun 5, 2026
Comment thread crates/git/src/repository.rs Outdated
@smitbarmase

This comment was marked as outdated.

Comment thread crates/fs/src/fake_git_repo.rs
@smitbarmase smitbarmase changed the title git: Skip diff base for symlinked files project: Fix spurious git diff for symlinked files Jun 5, 2026

@Anthony-Eid Anthony-Eid left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm a big fan of how you moved the check up to the worktree

@smitbarmase
smitbarmase added this pull request to the merge queue Jun 5, 2026
Merged via the queue into main with commit 0ee1a80 Jun 5, 2026
36 checks passed
@smitbarmase
smitbarmase deleted the fix-git-diff-for-symlink branch June 5, 2026 16:32
@Anthony-Eid

Copy link
Copy Markdown
Contributor

/cherry-pick preview

zed-zippy Bot added a commit that referenced this pull request Jun 5, 2026
…ick to preview) (#58679)

Cherry-pick of #58655 to preview

----
Opening a symlinked file showed the whole file as changed in the git
gutter/diff. Git stores only the symlink's target path as that entry's
blob, while the buffer holds the resolved target's contents, so diffing
the two is meaningless.

We now skip loading a git diff base whenever a buffer's worktree entry
is a symlink i.e. its `canonical_path` is set.

Release Notes:

- Fixed symlinked files showing the entire file as changed in the git
diff/gutter.

Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
TomPlanche pushed a commit to TomPlanche/zed that referenced this pull request Jun 8, 2026
)

Opening a symlinked file showed the whole file as changed in the git
gutter/diff. Git stores only the symlink's target path as that entry's
blob, while the buffer holds the resolved target's contents, so diffing
the two is meaningless.

We now skip loading a git diff base whenever a buffer's worktree entry
is a symlink i.e. its `canonical_path` is set.

Release Notes:

- Fixed symlinked files showing the entire file as changed in the git
diff/gutter.
This was referenced Jun 18, 2026
liusuren123 pushed a commit to liusuren123/zed that referenced this pull request Jun 24, 2026
) (cherry-pick to preview) (zed-industries#58679)

Cherry-pick of zed-industries#58655 to preview

----
Opening a symlinked file showed the whole file as changed in the git
gutter/diff. Git stores only the symlink's target path as that entry's
blob, while the buffer holds the resolved target's contents, so diffing
the two is meaningless.

We now skip loading a git diff base whenever a buffer's worktree entry
is a symlink i.e. its `canonical_path` is set.

Release Notes:

- Fixed symlinked files showing the entire file as changed in the git
diff/gutter.

Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
jonx pushed a commit to jonx/zed-aros that referenced this pull request Jul 17, 2026
)

Opening a symlinked file showed the whole file as changed in the git
gutter/diff. Git stores only the symlink's target path as that entry's
blob, while the buffer holds the resolved target's contents, so diffing
the two is meaningless.

We now skip loading a git diff base whenever a buffer's worktree entry
is a symlink i.e. its `canonical_path` is set.

Release Notes:

- Fixed symlinked files showing the entire file as changed in the git
diff/gutter.
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
) (cherry-pick to preview) (zed-industries#58679)

Cherry-pick of zed-industries#58655 to preview

----
Opening a symlinked file showed the whole file as changed in the git
gutter/diff. Git stores only the symlink's target path as that entry's
blob, while the buffer holds the resolved target's contents, so diffing
the two is meaningless.

We now skip loading a git diff base whenever a buffer's worktree entry
is a symlink i.e. its `canonical_path` is set.

Release Notes:

- Fixed symlinked files showing the entire file as changed in the git
diff/gutter.

Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
)

Opening a symlinked file showed the whole file as changed in the git
gutter/diff. Git stores only the symlink's target path as that entry's
blob, while the buffer holds the resolved target's contents, so diffing
the two is meaningless.

We now skip loading a git diff base whenever a buffer's worktree entry
is a symlink i.e. its `canonical_path` is set.

Release Notes:

- Fixed symlinked files showing the entire file as changed in the git
diff/gutter.
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 staff Pull requests authored by a current member of Zed staff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants