Skip to content

Elide common lines in string diffs #42

@evanrelf

Description

@evanrelf

When a long string differs between derivations - usually some long shell script written in a multi-line string - nix-diff prints the entire string contents, even if only a few lines of that long string have changed.

It would be nice if the parts in common were elided, like diff does with files.


I've reproduced this in a gist to illustrate: https://gist.github.com/evanrelf/2b1b1772c5f83ca102c89d29e4839aa3

I have two derivations that write similar (long) shell scripts using writeShellScript. Only one line is different between the Nix source code and the resulting shell scripts.

diff -u a.nix b.nix and diff -u $(nix-build a.nix) $(nix-build b.nix) are both very short; they elide parts in common.

nix-diff $(nix-instantiate a.nix) $(nix-instantiate b.nix) prints the whole string.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions