Repository navigation
Fix external git diff-files being called repeatedly for the same file (Issue #530) - #599
Merged
Merged
Conversation
goneng
marked this pull request as ready for review
September 11, 2026 16:06
goneng
force-pushed
the
fix-repeated-diff-on-stage
branch
from
September 11, 2026 17:55
67bb6fe to
744e037
Compare
This was referenced Sep 11, 2026
goneng
force-pushed
the
fix-repeated-diff-on-stage
branch
from
September 12, 2026 08:42
744e037 to
90c4e78
Compare
… (issue gitx#530) Answer the commit view from the diff it was last given while nothing it was read from has changed, instead of starting another git for a file that has not moved. Staging one file re-renders the commit view three times: - once as the selection moves on, and - once for each of the two index refreshes that follow. Each render asks for the diff of the file now on screen, so the same `diff-files -U3 -- <path>` ran three times over an untouched file, which is what issue gitx#530 reports seeing in the log. The refresh output cannot tell whether a file's content changed, only how it is staged, so the file and the index are stat'ed instead: size and modification time to the nanosecond, alongside the path, the tree being compared against and the requested context. - Read a diff through a one entry cache keyed on all of that - Fall back to reading it every time when the index cannot be located, since then there is nothing to notice a change against - Cover both halves: a diff nothing could have changed is asked for once, and an edit, a rewritten index, a different context size or an amend are each asked for again
goneng
force-pushed
the
fix-repeated-diff-on-stage
branch
from
September 12, 2026 09:36
90c4e78 to
2eeff63
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The commit view re-renders on every index update, and each render asks git for
the diff of the file on screen.
Staging one file does that three times over an untouched file, which is
what #530 reports seeing in the log.
and index are all unchanged
file is staged but not whether its content changed
Test plan:
diff-files -U3 -- <path>ran 3 times before and runs 1 time afterrunning app
PBGitIndexDiffCacheTests,make unit-testis 55 green