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.
This is a draft PR that is still somewhat rough around the edges. It replaces the
libgit2
logic inget_diff
withgitoxide
. A few things don’t work yet, but the code is already capable of generating correct diffs in some cases. I hope to get this PR into a reviewable/mergable state by the end of next week, but I won’t make any promises. :-)This will hopefully also address #2665.
Update 2025-08-08
I’m now down to just 4 tests not passing! Also, as I’d hoped, this PR addesses #2665, completely eliminating any CPU load because binary files are ignored by the diff algorithm.
There’s a few remaining issues/open questions:
gitoxide
does not provide structured diffs yet which is why this PR, as a workaround, resorts to string matching on a given hunk’s lines. This will hopefully be addressed upstream through Extract UnifiedDiffSink GitoxideLabs/gitoxide#2102. Oncegitoxide
has dedicated data structures, I should be able to simplify this PR considerably.gitoxide
does not provide extended headers such as@@ -315,6 +315,12 @@ impl ConsumeHunk for FileDiff {
the same waygit2
does (unless I’m missing something). Theimpl ConsumeHunk for FileDiff {
is not part of what we get fromgitoxide
. As far as I can see, this only affects the UI.gitoxide
produces different diffs thangit2
in certain cases which is known as the “slider problem”. I hope to be able to address this upstream as well, but it will take time and it will block this PR if we’re aiming forgit2
compatibility (and I think there’s strong reasons to do that).