Skip to content

Better diffs for indent changes. #91

Open

Description

@blainekasten

Currently, one of the hardest diffs to review, is when a bunch of code gets indented positively or negatively. It's hard to tell if the user actually made a change somewhere in the indent code because it all mostly looks the same.

Here is prime example: https://gist.github.com/blainekasten/cfd44975df7c294c54e6/revisions

Hardly any code was changed, just de-indented.

It would help if we could see the actual code that changed, and then indent changes were hidden and noted. Something that looked more like this:

- removedThisFunction(function() {
+  de-indented containing content 2 spaces
- });

Activity

  1. mrdoob commented on Jan 19, 2016

    @mrdoob
    Contributor
  2. blainekasten commented on Jan 19, 2016

    @blainekasten
    Author

    Wow. Completely am. That seems weird that it's a mostly hidden feature. It seems like it should be first-class. I don't think anyone benefits from seeing just tabbing changes.

  3. mrdoob commented on Jan 19, 2016

    @mrdoob
    Contributor

    I agree, they should really add a switch in the UI somewhere for this.

  4. Stargator commented on Jan 19, 2016

    @Stargator

    👍

  5. jawshooah commented on Feb 15, 2016

    @jawshooah

    In the meantime, there is a Chrome extension that adds a button for you.

  6. danielbartsch commented on Mar 8, 2018

    @danielbartsch

    Well there's a huge disadvantage with this method.

    You cannot comment on lines in PRs.
    I mean, that's clear, because for people who don't add ?w=1, the diff might look different. But wouldn't a sufficient solution be to let the user decide which default diff representation is set?

    In some (most) programming languages, the indent doesn't matter at all functionality wise. It would be cool to be able to set the default view (with or without whitespace diff) for a repo

  7. il--ya commented on Dec 1, 2018

    @il--ya

    @mrdoob, There is a tickbox now to ignore whitespace on PR and commit diff pages (still missing on gist.github.com).
    image
    @blainekasten, the real problem is not the indentation per se, but the fact that Github's diff viewer doesn't try very hard to align the lines - it only looks for identical lines to align the blocks, and then pads the smaller block with empty lines at the bottom. It doesn't try to align not-quite-identical lines. The only exception is made for the white space, but it is a manual option and it is quite blunt too as it ignores all whitespace regardless of how good the matching is overall.
    What is required is a more flexible, fuzzy line alignment algorithm in general, which would try harder to align less than ideally matching lines and take into account how that affects matching of the nearby lines as well.

  8. timotheecour commented on Feb 24, 2020

    @timotheecour

    I've made a PR that shows exactly the problem with all options I currently know of: see timotheecour/Nim#37
    the actual diff contains a single large re-indented block; and a single re-indented line within that large block; none of the tools work well in this case: git diff --color-moved-ws=allow-indentation-change --color-moved HEAD^ or https://github.com/timotheecour/Nim/pull/37/files?w=1 all have significant drawbacks, as explained in that PR

  9. sophiebits commented on Aug 8, 2022

    @sophiebits

    For what it's worth, Reviewable handles @timotheecour's example well:

    screenshot of diff in Reviewable showing the entire re-indented block, where the one re-indented line can also be identified by color highlighting

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