Skip to content

Conversation

@abobov
Copy link

@abobov abobov commented Dec 12, 2025

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! 🚀

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
Copy link
Author

abobov commented Dec 13, 2025

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

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