Skip to content

fix: separate "(binary file)" suffix from filename in hyperlinks - #2075

Open
abobov wants to merge 1 commit into
dandavison:mainfrom
abobov:fix-binary-file-hyperlinks
Open

abobov wants to merge 1 commit into
dandavison:mainfrom
abobov:fix-binary-file-hyperlinks

Conversation

@abobov

@abobov abobov commented Dec 12, 2025

Copy link
Copy Markdown

Issue

I noticed a small issue with hyperlinks when viewing diffs of binary files. When --hyperlinks is enabled, binary files show a suffix (binary file) in their filename. However, this suffix was being included as part of the filename in the hyperlink, making the links point to non-existent paths.

For example, a binary file named logo.png would generate a hyperlink to logo.png (binary file) instead of just logo.png. This makes the link unusable since that exact path doesn't exist in the repository.

Solution

I've fixed this by:

  • Adding a dedicated binary_files flag to track binary status separately
  • Building the file description with clean hyperlinks first
  • Appending the (binary file) indicator after the hyperlink is created

This ensures hyperlinks point to the actual file paths while still clearly indicating they're binary files.

This is my first contribution to a Rust project, and I'm excited to help improve delta! I'd appreciate any feedback on the implementation. Thanks for creating such an incredible tool that makes my daily development work so much better! 🚀

@abobov

abobov commented Dec 13, 2025

Copy link
Copy Markdown
Author

I wanted to share a quick demo to better illustrate the issue I described in the PR description.

Sample diff:

diff --git c/logo.png i/logo.png
new file mode 100644
index 0000000..f69082d
Binary files /dev/null and i/logo.png differ
demo.webm

@abobov
abobov force-pushed the fix-binary-file-hyperlinks branch from c4a56fc to 26154ed Compare March 20, 2026 18:23
@abobov

abobov commented Mar 25, 2026

Copy link
Copy Markdown
Author

Hi @dandavison! This PR is ready for review. Please let me know if it's okay to merge or if any changes are needed. Thanks!

@abobov
abobov force-pushed the fix-binary-file-hyperlinks branch from 26154ed to 3917456 Compare August 27, 2026 04:38
When viewing diffs of binary files with hyperlinks enabled, the "(binary
file)" suffix was incorrectly included as part of the filename in
hyperlinks. This caused links to point to non-existent file paths (e.g.,
"image.png (binary file)" instead of just "image.png").

The fix introduces a dedicated flag to track binary files separately,
builds the hyperlinks using the clean file paths, and only then appends
the "(binary file)" indicator outside the hyperlink. This ensures file
links work correctly while still providing the binary file indication.
@abobov
abobov force-pushed the fix-binary-file-hyperlinks branch from 3917456 to 2a814a3 Compare October 6, 2026 04:25

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant