Skip to content

feat: show a picture's old and new version next to each other in its diff - #53

Merged
Lars- merged 1 commit into
mainfrom
feat/image-diffs
Nov 18, 2026
Merged

Lars- merged 1 commit into
mainfrom
feat/image-diffs

Conversation

@Lars-

@Lars- Lars- commented Nov 18, 2026

Copy link
Copy Markdown
Owner

What this changes

A changed picture used to show only "Binary file". Now a PNG, JPEG, GIF, WebP, BMP or ICO shows its old version on the left and its new one on the right, each with its size in pixels and in bytes (for example Old · 256 × 256 · 11.1 KB). A picture is shown as large as it is, or smaller when it does not fit. A new file has none on the left, a deleted one on the right, and a version that cannot be decoded says why. This works in the uncommitted changes (unstaged, staged, untracked), in a commit and under a file's history, and the pictures follow changes made outside while the diff is open.

The two versions are read with gitoxide (Repo::versions: the index, HEAD, a commit and its first parent, or the working tree) and decoded on a background thread, so a large picture never holds up the window. Decoding uses the image crate, which eframe already depends on for PNG; this enables its JPEG, GIF, WebP, BMP and ICO decoders. A picture larger than the largest texture is scaled down for display; its real size is still shown.

This is part 3 of "Better diffs" on the roadmap; syntax colouring becomes part 4.

How it is tested

  • A core test reads both versions for every kind of diff against a real repository: a staged file before the first commit, a commit that added a file, a rename (old version under the old name), a deletion, staged and unstaged changes, a file deleted from the working tree and an untracked file.

  • A new app test commits a small PNG, changes it and adds a broken one, then checks the captions and the painted sizes of both pictures, that a change made outside shows by itself (it fails without reading the pictures again after a reload), that a broken file explains itself and that the commit that added the picture has nothing before it. A small test covers how sizes in bytes read.

  • Tried in the app on Linux: a changed PNG icon, a new JPEG, the 1920 × 1080 screenshot in the commit history of this repository, and a change made outside while the diff was open.

  • cargo fmt --all, cargo clippy --workspace --all-targets -- -D warnings and cargo test --workspace pass

  • It adds as little code as the change needs, and removes what it makes unnecessary

  • Nothing in it comes from GitKraken or another closed-source client (see CONTRIBUTING.md)

@Lars-
Lars- merged commit 2a8d2f8 into main Nov 18, 2026
7 checks passed
@Lars-
Lars- deleted the feat/image-diffs branch November 18, 2026 10:22
@Lars- Lars- mentioned this pull request Nov 18, 2026
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