# Remove git diff base from symlinked files \(\#10037\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 63e566e56e94bea885dbfdcb216dc88dffee1019

Requested commit: 63e566e56e94bea885dbfdcb216dc88dffee1019

Commit: 63e566e56e94bea885dbfdcb216dc88dffee1019

Tree: 4cded3f33c823db7fc862bdf11aa7f82263b6f42

Author: Kirill Bulatov

Committer: GitHub

## Message

```
Remove git diff base from symlinked files (#10037)

Closes https://github.com/zed-industries/zed/issues/4730

![image](https://github.com/zed-industries/zed/assets/2690773/d3c5317f-8120-45b5-b57c-c0fb5d8c066d)

To the left is a symlink, to the right — the real file.
The issue was due to the fact, that symlinks files contain the file path
to the real file, and git (properly) treats that symlink file contents
as diff base, returning in `load_index_text` (via `let content =
repo.find_blob(oid)?.content().to_owned();`) the contents of that
symlink file — the path.

The fix checks for FS metadata before fetching the git diff base, and
skips it entirely for symlinks: Zed opens the symlink file contents
instead, fully obscuring the git symlink diff hunks.

Interesting, that VSCode behaves as Zed before the fix; while the fix
makes Zed behave like Intellij* IDEs now.

Release Notes:

- Fixed git diff hunks appearing in the symlinked files
([4730](https://github.com/zed-industries/zed/issues/4730))
```

## Parents

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

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