Live data from Hacker News

Difftastic: A diff that understands syntax

github.com

141–150 of 224 posts

Re: Difftastic: A diff that understands syntax

#141
Personally I long for a syntactic merge-tool. Every time Syncthing hiccups for some reason, I'm up for a merge session with my Org-mode files, in the vein of: ‘These properties look just like those ones, only with a different timestamp... Oh lookie, and the heading is totally changed. Let me merge this new heading all over the old one, and then pop in the old one after it.’ Dammit, it's just a whole new heading added with properties. This happens with every language heavy on markup.

However, I'm not sure if Org markup lends itself to structuring that would allow proper diffing—even with just the headings.

Re: Difftastic: A diff that understands syntax

#142

Does a `magit` plugin exist for Emacs users? The author of this package is also the author of a couple of popular Emacs packages but I did not see any mention of Emacs.

It won't be able to form the basis of a magit plugin because it does not target traditional diff format.

Re: Difftastic: A diff that understands syntax

#143
post #141

Personally I long for a syntactic merge-tool. Every time Syncthing hiccups for some reason, I'm up for a merge session with my Org-mode files, in the vein of: ‘These properties look just like those ones, only with a different timestamp... Oh lookie, and the heading is totally changed. Let me merge this new heading all over the old one, and then pop in the old one after it.’ Dammit, it's just a whole new heading added…

Be good to have different git merge strategies per file type.

e.g. A merge that knows properties files support the same property added in different places but only once is needed. And another strategy if order is significant.

Cool to have an HTML merge that recognises the tree structure and supports merging tags and having the indentation follow some rules.

I believe git supports merge strategies, its been on my todo list forever.

Re: Difftastic: A diff that understands syntax

#144
post #22

This looks really cool and I can't wait to try it, tho... a bit of a PITA to get running. ;) Took a while to figure out how to build, and had to install 400MB of dependencies first.... Edit: And after installing cargo, watching it fail to build, then determining I must need a newer version of cargo, so I built that from source... it fails. Apparently I need to install `rustc-mozilla` and not `rustc`. "obviously". Thi…

A huge part of the appeal of Rust and Go tools is that you can just ship a binary, it's frustrating that it's not available here.

Re: Difftastic: A diff that understands syntax

#146

Earlier quoted context omitted.

The problem is when a file also needs to be normalized - e.g. object keys in a different order, YAML syntax expansion. It can be very useful to indicate when a JSON file is identical to another JSON file but some of the properties or array items are out of order and that requires more in-depth knowledge of the data format. Let's not mention that you could UTF-8 encode characters or write out the same character using…

I'm not too familiar with YAML, so can't answer to that. But re JSON: > object keys in a different order They can't be "in a different order" as JSON keys are not ordered. They can be whatever order, and would still be considered the same. > array items are out of order Then it's different, as JSON arrays are ordered. ["a", "b"] is not the same as ["b", "a"] while {a: 1, b: 1} and {b: 1, a: 1} is the same. > you coul…

[deleted]

Re: Difftastic: A diff that understands syntax

#147

Earlier quoted context omitted.

The problem is when a file also needs to be normalized - e.g. object keys in a different order, YAML syntax expansion. It can be very useful to indicate when a JSON file is identical to another JSON file but some of the properties or array items are out of order and that requires more in-depth knowledge of the data format. Let's not mention that you could UTF-8 encode characters or write out the same character using…

I'm not too familiar with YAML, so can't answer to that. But re JSON: > object keys in a different order They can't be "in a different order" as JSON keys are not ordered. They can be whatever order, and would still be considered the same. > array items are out of order Then it's different, as JSON arrays are ordered. ["a", "b"] is not the same as ["b", "a"] while {a: 1, b: 1} and {b: 1, a: 1} is the same. > you coul…

> They can't be "in a different order" as JSON keys are not ordered. They can be whatever order, and would still be considered the same.

This is what GP is saying, I'm pretty sure. Object member order is non-semantic in json, so in order to do a semantic diff (one that understands structure), you need to canonicalize the order of the two sides. Simply diffing the output of jq doesn't do that, because (afaik) jq doesn't alter the order.

Basically, if you want this to come up the same:

    {"a":"b","c":"d"}
    {"c":"d","a":"b"}
you need more than just `diff $(jq) $(jq)`.

Can argue about whether a tool like difftastic should do that, I guess, but I would personally lean towards that it should be smart enough to see this because it's precisely the sort of thing that both humans and line-based diff can be awful at seeing.

Re: Difftastic: A diff that understands syntax

#148
post #139

Earlier quoted context omitted.

Same here. Looked into repo -> no binary in release or Github actions spinned up a Ubuntu 18.04 instance -> git clone, git checkout 0.24.0 installed rust using curl | sh method build fails: https://termbin.com/29xy removed the instance and gonna check it again 6 months later

In another comment you're asking about vim support. So let me get this straight: You're using vim, yet you're unable to resolve the error message = note: /usr/bin/ld: cannot find Scrt1.o: No such file or directory /usr/bin/ld: cannot find crti.o: No such file or directory Have you tried googling for "ubuntu crti.o: No such file or directory" ?

Using vim has nothing to do with ones ability to troubleshoot compiler/ubuntu issues. Plus both compiler and ubuntu issues can be massive PITA to solve even if you're familiar with them. Personally, if I'm trying to install something on whim to try it out and I start getting "no such file or directory" errors I'd be upset that something is going wrong.

Re: Difftastic: A diff that understands syntax

#149
post #21
post #18

Earlier quoted context omitted.

This tool is built on tree-sitter ( https://tree-sitter.github.io/tree-sitter/ ), so presumably it doesn't need to maintain parsers at all. I've thought before this is how diffing should be done, and speculated that tree-sitter would make it more feasible. At this point, whenever I think some language-aware tool ought to exist, my first thought is "Does the language server protocol or tree-sitter make this more feasi…

Someone still has to build and maintain the parsers, you are just outsourcing this. And I added a bit to my comment, I tend to believe that parsing is the easy part, but that is admittedly more a gut feeling and not based on any real knowledge of that problem space.

That's certainly a good point.

Languages usually change slowly, though, so once a good baseline grammar is in place, maintenance is unlikely to be a huge load.

Furthermore, with tools like tree-sitter and the language server protocol, multiple communities benefit from their continued existence, so there's a bigger pool of contributors to the parser.

Re: Difftastic: A diff that understands syntax

#150
post #139

Earlier quoted context omitted.

Same here. Looked into repo -> no binary in release or Github actions spinned up a Ubuntu 18.04 instance -> git clone, git checkout 0.24.0 installed rust using curl | sh method build fails: https://termbin.com/29xy removed the instance and gonna check it again 6 months later

In another comment you're asking about vim support. So let me get this straight: You're using vim, yet you're unable to resolve the error message = note: /usr/bin/ld: cannot find Scrt1.o: No such file or directory /usr/bin/ld: cannot find crti.o: No such file or directory Have you tried googling for "ubuntu crti.o: No such file or directory" ?

>Have you tried googling for "ubuntu crti.o: No such file or directory" ?

Depending on the project, there is a certain threshold of trying-to-make-something-work which I'm willing to undertake in order to test an app.

But you are right. I'm sorry if my OG comment may come arrogant to the devs who do stuff for free. (♥ to the devs)

[edit]: ok, I tried again, `sudo apt update && sudo apt install build-essential` before installing rust and `cargo install`ing.

Error again:

https://dpaste.com/FTG7FSRQF

Post reply on HN