-
Notifications
You must be signed in to change notification settings - Fork 27
Implement a fuzzy diffing option for interdiff #147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
It's difficult to conditionally add additional arguments to the patch execution in apply_patch() because they are placed within a compound literal array. Make the arguments more extensible by creating a local array and an index variable to place the next argument into the array. This way, it's much easier to change the number of arguments provided at runtime.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #147 +/- ##
==========================================
- Coverage 85.78% 85.74% -0.05%
==========================================
Files 15 15
Lines 8112 8264 +152
Branches 1620 1664 +44
==========================================
+ Hits 6959 7086 +127
- Misses 1153 1178 +25
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@twaugh codecov aside, what do you think about the fuzzy feature? Are you (un)opposed to the idea? |
This implements a --fuzzy option to make interdiff perform a fuzzy comparison between two diffs. This is very helpful, for example, for comparing a backport patch to its upstream source patch to assist a human reviewer in verifying the correctness of the backport. To achieve fuzzy diffing: Instead of creating a different dummy original file for p1 and p2 and applying p1 to p2's original file and p2 to p1's original file, use p1's original file for both cases when fuzzy diffing. This way, interdiff can rely upon the patch command to fuzz the line offset and context differences between hunks in p1 and p2. And then the final diff command at the end will show the remaining differences using the same base file, so it won't report hunks as differing just because of differing line offsets. The diff command can't do any fuzzy diffing, hence why we need to rely on the patch command for this capability. The fuzzy diffing option also handles rejected hunks by showing them in the output as a differing hunk. And it tries to avoid *additionally* showing the *reverse* of the rejected hunks by applying the rejected hunks with maximum fuzz, so that the final diff command doesn't show them.
205fb3d to
e45063a
Compare
|
I like it a lot actually, and it's definitely something people have asked for before (in fact I think it's often assumed it will just work). Does it avoid exposing 'unline's? |
|
Yes, it doesn't expose any unlines. |
Allow the user to append =N to `--fuzzy` to specify the maximum number of context lines for `patch` to fuzz.
This implements a --fuzzy option to make interdiff perform a fuzzy comparison between two diffs. This is very helpful, for example, for comparing a backport patch to its upstream source patch to assist a human reviewer in verifying the correctness of the backport.