Skip to content

Look into using difftastic for better diffs #57

Description

@jimwins

Activity

  1. Girgias commented on Nov 9, 2024

    @Girgias
    Member

    Possibly one immediate improvement would be to ignore whitespace changes? Might also need to do something like that for the (new) rev-check @alfsb

  2. alfsb commented on Nov 9, 2024

    @alfsb
    Member

    Although it has to do with revchecks, both doc-base and web-doc, as they generate links, I think it can be initially developed exclusively in web-doc, by extrincating diff capabilities from https://doc.php.net/revcheck.php into a separate prettydiff.php file, and going from there. A diff page that does not contain headers and navbar for all languages, already helps.

    About whitespaces in diffs, I think this can be an option. The separated diff page may contain, for example, checkboxes for Colored output and Ignore whitespace, that if checked, causes the page to reload with new setup.

    Whitespace is always a PITA, because it is always important. While it is good to be able to observe only textual differences, having a way to observe WS changes has also its value. For example, the pt_BR translation has a tool to trim right and sync left white space, on line basis, to automatize indentation syncing..

  3. alfsb commented on Nov 9, 2024

    @alfsb
    Member

    About specifically ignoring whitespace changes, it would be possible, but with caveats. Some internal whitespaces changes are important (for example, ws inside some tags that breaks automatic linking) and even changes that may or may not be synced in translations (for example) https://github.com/php/doc-en/pull/3837/files

    But most or inter textual ws changes can be ignored. It's possible, for example, in the case of outdated files, to compare the contents of two versions of an en file, the last and the annotated in revtag, but trimming all lines and blank lines before comparison. If two "trimmed" files compare equals, there are no textual changes, and these files would not be marked outdated.

    But it will slow, even more so as these cases of "line trim equals" accumulate. Some form of automatic hash bumping will be necessary after a while.

  4. jimwins commented on Nov 9, 2024

    @jimwins
    MemberAuthor

    We're already using --ignore-space-at-eol for the diff, we could look at the other options the stock git diff has for ignoring whitespace changes.

    Maybe we could also use --word-diff=plain or --word-diff=porcelain to show changed words instead of just lines.

  5. alfsb commented on Nov 9, 2024

    @alfsb
    Member

    The descriptions of --ignore-space-change/-b options are a bit misleading. It will ignore ws changes on existing ws runs, but will report insertion or remotion of ws runs. This suffices for detecting significant ws changes and also ignoring insignificant ws changes in most cases that we are interested in.

    It will ignore ws changing within lines, and that's unfortunate.

    An option like --ignore-space-at-sol exists only as patchs. Maybe exists a combination of -w and --word-diff-regex=, so that makes git consider one "word" any text between lines, with ws within but excluding ws after and before new lines, but neither my git or regex knowledge is high enough to create this regex.

  6. alfsb commented on Nov 10, 2024

    @alfsb
    Member

    git diff -b does a good job for (almost) all cases. I may implement some "only prefix/suffix" ws change on revcheck, to ignore some cases with it.

    image

    It also would be an inicial alternative for while, or if difftastic is not possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions