Skip to content
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

Add options to Diff and DiffChunk. #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pgweiss
Copy link

@pgweiss pgweiss commented Mar 2, 2020

This commit adds options to Diff and DiffChunks. The only option I've implemented is Transform, which is a function to modify lines before diffing.

I find myself often having to modify files before diffing so that I can ignore differences I don't care about and concentrate on those I do. One example might be diffing the log output of a program running at different times, where you want to ignore the timestamp. There are many others. However, the problem with modifying the lines before diffing is that I'd like the output and context lines to refer to the original lines before they were modified. That is what the Transform option does.

Note that if a transform is not provided then no copying is done, and there is no change to the calling convention for existing callers. If there are additional options in the future, they can be added to the options structure.

The only implemented option is Transform, which allows modifying the
lines before diffing. This allows one to ignore irrelevant changes,
e.g. timestamps in log files.
@pgweiss pgweiss closed this Mar 2, 2020
@pgweiss pgweiss reopened this Mar 2, 2020
@kylelemons
Copy link
Owner

Unfortunately, changing an exported signature is a breaking change to the API. If you need transformations, I recommend package cmp. I will tag this as a breaking change in case we accumulate enough to be worth a v2 branch.

@kylelemons kylelemons added the breaking_change Breaking change; potential feature for a v2 branch label Aug 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking_change Breaking change; potential feature for a v2 branch cla: yes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants