feat: compare directory diffs by file content instead of mtime#306
Merged
esmuellert merged 2 commits intoesmuellert:mainfrom Mar 5, 2026
Merged
feat: compare directory diffs by file content instead of mtime#306esmuellert merged 2 commits intoesmuellert:mainfrom
esmuellert merged 2 commits intoesmuellert:mainfrom
Conversation
- Directory diff mode now verifies modified files by reading and comparing file bytes instead of relying on mtime metadata.
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.
Summary
This PR improves non-git directory comparison (
:CodeDiff dir ...) by switching modified-file detection from metadata-based checks to content-based checks.Previously, directory diff mode treated files as modified using
size + mtime.Now it compares file bytes directly (chunked reads), which makes results accurate as timestamps are unreliable.
What changed
mtimefrom directory scan metadata.Implementation details
The comparison is implemented with libuv file APIs to keep it fast.
Benchmark
Ran a benchmark on the TensorFlow repository (HEAD vs a random branch). The benchmark was executed without using the git index, and the comparison contained 812 changed files.
3.205 s ± 0.043 s[User: 2.039 s, System: 1.164 s]3.152 s … 3.323 s15