Repository navigation
Fix the index being read twice over for a write GitX made itself - #602
Merged
Merged
Conversation
goneng
force-pushed
the
fix-self-inflicted-index-refresh
branch
4 times, most recently
from
September 13, 2026 04:33
de82576 to
c11db69
Compare
goneng
force-pushed
the
fix-self-inflicted-index-refresh
branch
from
September 13, 2026 06:34
c11db69 to
b8aea4b
Compare
Staging writes the index and reads it straight back, and a second later the repository watcher reported that same write, so the whole index was read again for nothing. * Note which index a refresh is about to read, by the stat fingerprint the diff cache already relies on * Act on an index event only when the index on disk is no longer the one that refresh read * Leave working directory events alone, since a file on disk carries no fingerprint the view could have recorded Opening a repository now runs one index refresh rather than three, and staging a file one rather than two. An index written by anyone else still reaches the view, tested with git add, git reset and git commit run from a terminal.
goneng
force-pushed
the
fix-self-inflicted-index-refresh
branch
from
September 13, 2026 07:34
b8aea4b to
3f7d41f
Compare
goneng
marked this pull request as ready for review
September 13, 2026 07:51
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.
Staging writes the index and reads it straight back, and a second later the repository watcher
reported that same write, so the whole index was read again for nothing.
The index now notes the stat fingerprint of the file a refresh is about to read, and
an index event is acted on only when the index on disk is no longer that one.
Impact of the change
External git commands:
git addfrom a terminalgit reset <file>from a terminalgit commitfrom a terminal(traced from a running GitX)
Only GitX's own writes are skipped.
Working directory events are left alone either way, since a file on disk carries
no fingerprint the view could have recorded.
The
git resetrow is the interesting one:it writes the index and touches nothing else, and still refreshes.
Test plan
PBGitCommitControllerRefreshTests: 4 tests on which events reacha refresh, of which
testTheIndexThatWasJustReadIsNotReadAgainfailswithout the change
PBGitIndexRefreshTestson the fingerprint bookkeeping,including an index that cannot be statted being reported as changed
make unit-test: 67 tests, 0 failurestable above, staging from the UI and writing the index from a terminal