Wilfred / difftastic

a structural diff that understands syntax 🟥🟩
https://difftastic.wilfred.me.uk/
MIT License
19.94k stars 317 forks source link

Parsable output #691

Open gerhardol opened 3 months ago

gerhardol commented 3 months ago

Difftastic could be used to show an alternative view of differences also in other tools. The "unstable" json output could maybe be used, but then you get no context information and have to be reconstructed. (I find the output having incomplete contents too, but have not investigated.)

I am considering adding Difftastic to https://github.com/gitextensions/gitextensions, discussed in https://github.com/gitextensions/gitextensions/issues/11618 Support that is reasonable is to parse the line numbers with the type of change. It is a little too much guessing right now, it would be nice if this was easier to parse.

Suggestion:

        .arg(
            Arg::new("porcelain").long("porcelain")
                .possible_values(["0", "1"])
                .default_value("0")
                .env("DFT_PORCELAIN")
                .value_name("WHEN")
                .help("Use porcelain output, partly parseble.")
        )

First two characters define the type of information Letters could be used instead to simplify regex

h: header third char starts second column size followed by single space, 0 if only one column (this should be inserted for each new file) space: No info, like line after header or no info in second column . (period): No status change, context +: Added info -: Removed c: continued line

The second char will always be space unless there are two columns An alternative would be one character and have "second column" on the second line with another marker.

Other: